From f234d9c0ec7c6bf437be3104bc8d8480fbdb687a Mon Sep 17 00:00:00 2001 From: Johnny Lim Date: Wed, 27 Nov 2019 20:19:10 +0900 Subject: [PATCH] Remove ConditionEvaluationReportLoggingListener usage if possible See gh-19159 --- ...oudFoundryInfoEndpointWebExtensionTests.java | 17 +++++++---------- ...AbstractEndpointRequestIntegrationTests.java | 15 ++++++--------- .../NonAspectJAopAutoConfigurationTests.java | 13 +++++-------- .../mongo/MongoDataAutoConfigurationTests.java | 5 +---- .../jersey/JerseyAutoConfigurationTests.java | 3 --- 5 files changed, 19 insertions(+), 34 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/CloudFoundryInfoEndpointWebExtensionTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/CloudFoundryInfoEndpointWebExtensionTests.java index 18d717f487..8441baab9e 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/CloudFoundryInfoEndpointWebExtensionTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/CloudFoundryInfoEndpointWebExtensionTests.java @@ -31,12 +31,10 @@ import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoCon import org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration; import org.springframework.boot.autoconfigure.info.ProjectInfoAutoConfiguration; import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration; -import org.springframework.boot.autoconfigure.logging.ConditionEvaluationReportLoggingListener; import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration; import org.springframework.boot.autoconfigure.web.client.RestTemplateAutoConfiguration; import org.springframework.boot.autoconfigure.web.servlet.DispatcherServletAutoConfiguration; import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration; -import org.springframework.boot.logging.LogLevel; import org.springframework.boot.test.context.runner.WebApplicationContextRunner; import static org.assertj.core.api.Assertions.assertThat; @@ -62,14 +60,13 @@ class CloudFoundryInfoEndpointWebExtensionTests { @Test @SuppressWarnings("unchecked") void gitFullDetailsAlwaysPresent() { - this.contextRunner.withInitializer(new ConditionEvaluationReportLoggingListener(LogLevel.INFO)) - .run((context) -> { - CloudFoundryInfoEndpointWebExtension extension = context - .getBean(CloudFoundryInfoEndpointWebExtension.class); - Map git = (Map) extension.info().get("git"); - Map commit = (Map) git.get("commit"); - assertThat(commit).hasSize(4); - }); + this.contextRunner.run((context) -> { + CloudFoundryInfoEndpointWebExtension extension = context + .getBean(CloudFoundryInfoEndpointWebExtension.class); + Map git = (Map) extension.info().get("git"); + Map commit = (Map) git.get("commit"); + assertThat(commit).hasSize(4); + }); } } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/security/servlet/AbstractEndpointRequestIntegrationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/security/servlet/AbstractEndpointRequestIntegrationTests.java index f048926e1d..2e8d242442 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/security/servlet/AbstractEndpointRequestIntegrationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/security/servlet/AbstractEndpointRequestIntegrationTests.java @@ -30,10 +30,8 @@ import org.springframework.boot.actuate.endpoint.web.EndpointServlet; import org.springframework.boot.actuate.endpoint.web.annotation.ServletEndpoint; import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration; -import org.springframework.boot.autoconfigure.logging.ConditionEvaluationReportLoggingListener; import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration; import org.springframework.boot.autoconfigure.security.servlet.UserDetailsServiceAutoConfiguration; -import org.springframework.boot.logging.LogLevel; import org.springframework.boot.test.context.assertj.AssertableWebApplicationContext; import org.springframework.boot.test.context.runner.WebApplicationContextRunner; import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext; @@ -60,13 +58,12 @@ abstract class AbstractEndpointRequestIntegrationTests { @Test void toAllEndpointsShouldMatch() { - getContextRunner().withInitializer(new ConditionEvaluationReportLoggingListener(LogLevel.INFO)) - .withPropertyValues("spring.security.user.password=password").run((context) -> { - WebTestClient webTestClient = getWebTestClient(context); - webTestClient.get().uri("/actuator/e2").exchange().expectStatus().isUnauthorized(); - webTestClient.get().uri("/actuator/e2").header("Authorization", getBasicAuth()).exchange() - .expectStatus().isOk(); - }); + getContextRunner().withPropertyValues("spring.security.user.password=password").run((context) -> { + WebTestClient webTestClient = getWebTestClient(context); + webTestClient.get().uri("/actuator/e2").exchange().expectStatus().isUnauthorized(); + webTestClient.get().uri("/actuator/e2").header("Authorization", getBasicAuth()).exchange().expectStatus() + .isOk(); + }); } @Test diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/aop/NonAspectJAopAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/aop/NonAspectJAopAutoConfigurationTests.java index 561b1a5b0b..9c4c46ce10 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/aop/NonAspectJAopAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/aop/NonAspectJAopAutoConfigurationTests.java @@ -21,8 +21,6 @@ import org.junit.jupiter.api.Test; import org.springframework.aop.config.AopConfigUtils; import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.boot.autoconfigure.AutoConfigurations; -import org.springframework.boot.autoconfigure.logging.ConditionEvaluationReportLoggingListener; -import org.springframework.boot.logging.LogLevel; import org.springframework.boot.test.context.runner.ApplicationContextRunner; import org.springframework.boot.testsupport.classpath.ClassPathExclusions; @@ -41,12 +39,11 @@ class NonAspectJAopAutoConfigurationTests { @Test void whenAspectJIsAbsentAndProxyTargetClassIsEnabledProxyCreatorBeanIsDefined() { - this.contextRunner.withInitializer(new ConditionEvaluationReportLoggingListener(LogLevel.INFO)) - .run((context) -> { - BeanDefinition autoProxyCreator = context.getBeanFactory() - .getBeanDefinition(AopConfigUtils.AUTO_PROXY_CREATOR_BEAN_NAME); - assertThat(autoProxyCreator.getPropertyValues().get("proxyTargetClass")).isEqualTo(Boolean.TRUE); - }); + this.contextRunner.run((context) -> { + BeanDefinition autoProxyCreator = context.getBeanFactory() + .getBeanDefinition(AopConfigUtils.AUTO_PROXY_CREATOR_BEAN_NAME); + assertThat(autoProxyCreator.getPropertyValues().get("proxyTargetClass")).isEqualTo(Boolean.TRUE); + }); } @Test diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/mongo/MongoDataAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/mongo/MongoDataAutoConfigurationTests.java index 06512ca783..2e0a80d115 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/mongo/MongoDataAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/mongo/MongoDataAutoConfigurationTests.java @@ -31,9 +31,7 @@ import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoCon import org.springframework.boot.autoconfigure.data.mongo.city.City; import org.springframework.boot.autoconfigure.data.mongo.country.Country; import org.springframework.boot.autoconfigure.domain.EntityScan; -import org.springframework.boot.autoconfigure.logging.ConditionEvaluationReportLoggingListener; import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration; -import org.springframework.boot.logging.LogLevel; import org.springframework.boot.test.context.runner.ApplicationContextRunner; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; @@ -65,8 +63,7 @@ class MongoDataAutoConfigurationTests { private final ApplicationContextRunner contextRunner = new ApplicationContextRunner() .withConfiguration(AutoConfigurations.of(PropertyPlaceholderAutoConfiguration.class, - MongoAutoConfiguration.class, MongoDataAutoConfiguration.class)) - .withInitializer(new ConditionEvaluationReportLoggingListener(LogLevel.INFO)); + MongoAutoConfiguration.class, MongoDataAutoConfiguration.class)); @Test void templateExists() { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jersey/JerseyAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jersey/JerseyAutoConfigurationTests.java index 0edbf673cf..4ac47266e1 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jersey/JerseyAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jersey/JerseyAutoConfigurationTests.java @@ -23,8 +23,6 @@ import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration; -import org.springframework.boot.autoconfigure.logging.ConditionEvaluationReportLoggingListener; -import org.springframework.boot.logging.LogLevel; import org.springframework.boot.test.context.FilteredClassLoader; import org.springframework.boot.test.context.runner.WebApplicationContextRunner; import org.springframework.boot.web.servlet.FilterRegistrationBean; @@ -43,7 +41,6 @@ class JerseyAutoConfigurationTests { private final WebApplicationContextRunner contextRunner = new WebApplicationContextRunner() .withConfiguration(AutoConfigurations.of(JerseyAutoConfiguration.class)) - .withInitializer(new ConditionEvaluationReportLoggingListener(LogLevel.INFO)) .withUserConfiguration(ResourceConfigConfiguration.class); @Test