From 8be8a8421dd01ece3c0c3f330352479de0c4a098 Mon Sep 17 00:00:00 2001 From: Johnny Lim Date: Wed, 19 Feb 2020 11:16:46 +0900 Subject: [PATCH 1/2] Polish See gh-20226 --- ...FoundryActuatorAutoConfigurationTests.java | 3 +- ...FoundryActuatorAutoConfigurationTests.java | 3 +- .../WebFluxMetricsAutoConfigurationTests.java | 9 +++--- .../WebMvcMetricsAutoConfigurationTests.java | 9 +++--- ...rsManagementContextConfigurationTests.java | 5 ++-- .../CassandraDataAutoConfigurationTests.java | 3 +- ...draReactiveDataAutoConfigurationTests.java | 3 +- .../kafka/KafkaAutoConfigurationTests.java | 2 +- .../TaskExecutionAutoConfigurationTests.java | 4 +-- .../servlet/WebMvcAutoConfigurationTests.java | 30 +++++++++---------- .../WebServicesAutoConfigurationTests.java | 3 +- .../autoconfigure/orm/jpa/DataJpaTest.java | 2 +- ...TestAutoConfigurationIntegrationTests.java | 5 ++-- .../docs/asciidoc/packaging-oci-image.adoc | 2 +- .../boot/task/TaskExecutorBuilderTests.java | 3 +- .../web/client/RestTemplateBuilderTests.java | 3 +- ...atingFilterProxyRegistrationBeanTests.java | 5 ++-- 17 files changed, 39 insertions(+), 55 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/ReactiveCloudFoundryActuatorAutoConfigurationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/ReactiveCloudFoundryActuatorAutoConfigurationTests.java index 62fe9f9f3a..4af8216115 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/ReactiveCloudFoundryActuatorAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/ReactiveCloudFoundryActuatorAutoConfigurationTests.java @@ -240,8 +240,7 @@ class ReactiveCloudFoundryActuatorAutoConfigurationTests { ExposableWebEndpoint endpoint = endpoints.iterator().next(); assertThat(endpoint.getOperations()).hasSize(2); WebOperation webOperation = findOperationWithRequestPath(endpoint, "health"); - Object invoker = ReflectionTestUtils.getField(webOperation, "invoker"); - assertThat(ReflectionTestUtils.getField(invoker, "target")) + assertThat(webOperation).extracting("invoker").extracting("target") .isInstanceOf(CloudFoundryReactiveHealthEndpointWebExtension.class); }); } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/CloudFoundryActuatorAutoConfigurationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/CloudFoundryActuatorAutoConfigurationTests.java index d895df495c..465c9e2175 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/CloudFoundryActuatorAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/CloudFoundryActuatorAutoConfigurationTests.java @@ -231,8 +231,7 @@ class CloudFoundryActuatorAutoConfigurationTests { ExposableWebEndpoint endpoint = endpoints.iterator().next(); assertThat(endpoint.getOperations()).hasSize(2); WebOperation webOperation = findOperationWithRequestPath(endpoint, "health"); - Object invoker = ReflectionTestUtils.getField(webOperation, "invoker"); - assertThat(ReflectionTestUtils.getField(invoker, "target")) + assertThat(webOperation).extracting("invoker").extracting("target") .isInstanceOf(CloudFoundryHealthEndpointWebExtension.class); }); } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/web/reactive/WebFluxMetricsAutoConfigurationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/web/reactive/WebFluxMetricsAutoConfigurationTests.java index 9a5b1a4392..9fab2e7f0c 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/web/reactive/WebFluxMetricsAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/web/reactive/WebFluxMetricsAutoConfigurationTests.java @@ -33,7 +33,6 @@ import org.springframework.boot.test.system.CapturedOutput; import org.springframework.boot.test.system.OutputCaptureExtension; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.test.util.ReflectionTestUtils; import org.springframework.test.web.reactive.server.WebTestClient; import static org.assertj.core.api.Assertions.assertThat; @@ -57,8 +56,8 @@ class WebFluxMetricsAutoConfigurationTests { this.contextRunner.run((context) -> { assertThat(context).getBeans(MetricsWebFilter.class).hasSize(1); assertThat(context).getBeans(DefaultWebFluxTagsProvider.class).hasSize(1); - assertThat(ReflectionTestUtils.getField(context.getBean(DefaultWebFluxTagsProvider.class), - "ignoreTrailingSlash")).isEqualTo(true); + assertThat(context.getBean(DefaultWebFluxTagsProvider.class)).extracting("ignoreTrailingSlash") + .isEqualTo(true); }); } @@ -67,8 +66,8 @@ class WebFluxMetricsAutoConfigurationTests { this.contextRunner.withPropertyValues("management.metrics.web.server.request.ignore-trailing-slash=false") .run((context) -> { assertThat(context).hasSingleBean(DefaultWebFluxTagsProvider.class); - assertThat(ReflectionTestUtils.getField(context.getBean(DefaultWebFluxTagsProvider.class), - "ignoreTrailingSlash")).isEqualTo(false); + assertThat(context.getBean(DefaultWebFluxTagsProvider.class)).extracting("ignoreTrailingSlash") + .isEqualTo(false); }); } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/web/servlet/WebMvcMetricsAutoConfigurationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/web/servlet/WebMvcMetricsAutoConfigurationTests.java index d2c1448c5a..df12e89bf3 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/web/servlet/WebMvcMetricsAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/web/servlet/WebMvcMetricsAutoConfigurationTests.java @@ -50,7 +50,6 @@ import org.springframework.boot.web.servlet.FilterRegistrationBean; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.Ordered; -import org.springframework.test.util.ReflectionTestUtils; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; import org.springframework.test.web.servlet.setup.MockMvcBuilders; @@ -84,8 +83,8 @@ class WebMvcMetricsAutoConfigurationTests { void definesTagsProviderAndFilterWhenMeterRegistryIsPresent() { this.contextRunner.run((context) -> { assertThat(context).hasSingleBean(DefaultWebMvcTagsProvider.class); - assertThat(ReflectionTestUtils.getField(context.getBean(DefaultWebMvcTagsProvider.class), - "ignoreTrailingSlash")).isEqualTo(true); + assertThat(context.getBean(DefaultWebMvcTagsProvider.class)).extracting("ignoreTrailingSlash") + .isEqualTo(true); assertThat(context).hasSingleBean(FilterRegistrationBean.class); assertThat(context.getBean(FilterRegistrationBean.class).getFilter()) .isInstanceOf(WebMvcMetricsFilter.class); @@ -97,8 +96,8 @@ class WebMvcMetricsAutoConfigurationTests { this.contextRunner.withPropertyValues("management.metrics.web.server.request.ignore-trailing-slash=false") .run((context) -> { assertThat(context).hasSingleBean(DefaultWebMvcTagsProvider.class); - assertThat(ReflectionTestUtils.getField(context.getBean(DefaultWebMvcTagsProvider.class), - "ignoreTrailingSlash")).isEqualTo(false); + assertThat(context.getBean(DefaultWebMvcTagsProvider.class)).extracting("ignoreTrailingSlash") + .isEqualTo(false); }); } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/security/servlet/SecurityRequestMatchersManagementContextConfigurationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/security/servlet/SecurityRequestMatchersManagementContextConfigurationTests.java index 1c08e3239c..dd8f8db92f 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/security/servlet/SecurityRequestMatchersManagementContextConfigurationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/security/servlet/SecurityRequestMatchersManagementContextConfigurationTests.java @@ -29,7 +29,6 @@ import org.springframework.boot.test.context.runner.WebApplicationContextRunner; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.security.web.util.matcher.RequestMatcher; -import org.springframework.test.util.ReflectionTestUtils; import static org.assertj.core.api.Assertions.assertThat; @@ -64,7 +63,7 @@ class SecurityRequestMatchersManagementContextConfigurationTests { this.contextRunner.withUserConfiguration(TestMvcConfiguration.class).run((context) -> { AntPathRequestMatcherProvider matcherProvider = context.getBean(AntPathRequestMatcherProvider.class); RequestMatcher requestMatcher = matcherProvider.getRequestMatcher("/example"); - assertThat(ReflectionTestUtils.getField(requestMatcher, "pattern")).isEqualTo("/custom/example"); + assertThat(requestMatcher).extracting("pattern").isEqualTo("/custom/example"); }); } @@ -75,7 +74,7 @@ class SecurityRequestMatchersManagementContextConfigurationTests { AntPathRequestMatcherProvider matcherProvider = context .getBean(AntPathRequestMatcherProvider.class); RequestMatcher requestMatcher = matcherProvider.getRequestMatcher("/example"); - assertThat(ReflectionTestUtils.getField(requestMatcher, "pattern")).isEqualTo("/admin/example"); + assertThat(requestMatcher).extracting("pattern").isEqualTo("/admin/example"); }); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/cassandra/CassandraDataAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/cassandra/CassandraDataAutoConfigurationTests.java index 47254d9ecc..6b7ab3d312 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/cassandra/CassandraDataAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/cassandra/CassandraDataAutoConfigurationTests.java @@ -79,8 +79,7 @@ class CassandraDataAutoConfigurationTests { void userTypeResolverShouldBeSet() { load(); CassandraMappingContext mappingContext = this.context.getBean(CassandraMappingContext.class); - assertThat(ReflectionTestUtils.getField(mappingContext, "userTypeResolver")) - .isInstanceOf(SimpleUserTypeResolver.class); + assertThat(mappingContext).extracting("userTypeResolver").isInstanceOf(SimpleUserTypeResolver.class); } @Test diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/cassandra/CassandraReactiveDataAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/cassandra/CassandraReactiveDataAutoConfigurationTests.java index db0111c749..aa19296d22 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/cassandra/CassandraReactiveDataAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/cassandra/CassandraReactiveDataAutoConfigurationTests.java @@ -75,8 +75,7 @@ class CassandraReactiveDataAutoConfigurationTests { void userTypeResolverShouldBeSet() { load("spring.data.cassandra.keyspaceName:boot_test"); CassandraMappingContext mappingContext = this.context.getBean(CassandraMappingContext.class); - assertThat(ReflectionTestUtils.getField(mappingContext, "userTypeResolver")) - .isInstanceOf(SimpleUserTypeResolver.class); + assertThat(mappingContext).extracting("userTypeResolver").isInstanceOf(SimpleUserTypeResolver.class); } private void load(String... environment) { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/kafka/KafkaAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/kafka/KafkaAutoConfigurationTests.java index dd5c4b0819..dbb998bf20 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/kafka/KafkaAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/kafka/KafkaAutoConfigurationTests.java @@ -389,7 +389,7 @@ class KafkaAutoConfigurationTests { assertThat(containerProperties.getMonitorInterval()).isEqualTo(45); assertThat(containerProperties.isLogContainerConfig()).isTrue(); assertThat(containerProperties.isMissingTopicsFatal()).isFalse(); - assertThat(ReflectionTestUtils.getField(kafkaListenerContainerFactory, "concurrency")).isEqualTo(3); + assertThat(kafkaListenerContainerFactory).extracting("concurrency").isEqualTo(3); assertThat(kafkaListenerContainerFactory.isBatchListener()).isTrue(); assertThat(context.getBeansOfType(KafkaJaasLoginModuleInitializer.class)).hasSize(1); KafkaJaasLoginModuleInitializer jaas = context.getBean(KafkaJaasLoginModuleInitializer.class); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/task/TaskExecutionAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/task/TaskExecutionAutoConfigurationTests.java index 8f75dd89be..cde404fb13 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/task/TaskExecutionAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/task/TaskExecutionAutoConfigurationTests.java @@ -41,7 +41,6 @@ import org.springframework.scheduling.annotation.AsyncResult; import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; -import org.springframework.test.util.ReflectionTestUtils; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; @@ -92,8 +91,7 @@ class TaskExecutionAutoConfigurationTests { this.contextRunner.withUserConfiguration(TaskDecoratorConfig.class).run((context) -> { assertThat(context).hasSingleBean(TaskExecutorBuilder.class); ThreadPoolTaskExecutor executor = context.getBean(TaskExecutorBuilder.class).build(); - assertThat(ReflectionTestUtils.getField(executor, "taskDecorator")) - .isSameAs(context.getBean(TaskDecorator.class)); + assertThat(executor).extracting("taskDecorator").isSameAs(context.getBean(TaskDecorator.class)); }); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfigurationTests.java index 16d63d8e0e..6bfe8263c8 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfigurationTests.java @@ -380,16 +380,15 @@ class WebMvcAutoConfigurationTests { @Test void defaultAsyncRequestTimeout() { - this.contextRunner.run((context) -> assertThat(ReflectionTestUtils - .getField(context.getBean(RequestMappingHandlerAdapter.class), "asyncRequestTimeout")).isNull()); + this.contextRunner.run((context) -> assertThat(context.getBean(RequestMappingHandlerAdapter.class)) + .extracting("asyncRequestTimeout").isNull()); } @Test void customAsyncRequestTimeout() { this.contextRunner.withPropertyValues("spring.mvc.async.request-timeout:12345") - .run((context) -> assertThat(ReflectionTestUtils - .getField(context.getBean(RequestMappingHandlerAdapter.class), "asyncRequestTimeout")) - .isEqualTo(12345L)); + .run((context) -> assertThat(context.getBean(RequestMappingHandlerAdapter.class)) + .extracting("asyncRequestTimeout").isEqualTo(12345L)); } @Test @@ -397,8 +396,8 @@ class WebMvcAutoConfigurationTests { this.contextRunner.withConfiguration(AutoConfigurations.of(TaskExecutionAutoConfiguration.class)) .run((context) -> { assertThat(context).hasSingleBean(AsyncTaskExecutor.class); - assertThat(ReflectionTestUtils.getField(context.getBean(RequestMappingHandlerAdapter.class), - "taskExecutor")).isSameAs(context.getBean("applicationTaskExecutor")); + assertThat(context.getBean(RequestMappingHandlerAdapter.class)).extracting("taskExecutor") + .isSameAs(context.getBean("applicationTaskExecutor")); }); } @@ -407,8 +406,8 @@ class WebMvcAutoConfigurationTests { this.contextRunner.withUserConfiguration(CustomApplicationTaskExecutorConfig.class) .withConfiguration(AutoConfigurations.of(TaskExecutionAutoConfiguration.class)).run((context) -> { assertThat(context).doesNotHaveBean(AsyncTaskExecutor.class); - assertThat(ReflectionTestUtils.getField(context.getBean(RequestMappingHandlerAdapter.class), - "taskExecutor")).isNotSameAs(context.getBean("applicationTaskExecutor")); + assertThat(context.getBean(RequestMappingHandlerAdapter.class)).extracting("taskExecutor") + .isNotSameAs(context.getBean("applicationTaskExecutor")); }); } @@ -416,9 +415,9 @@ class WebMvcAutoConfigurationTests { void asyncTaskExecutorWithMvcConfigurerCanOverrideExecutor() { this.contextRunner.withUserConfiguration(CustomAsyncTaskExecutorConfigurer.class) .withConfiguration(AutoConfigurations.of(TaskExecutionAutoConfiguration.class)) - .run((context) -> assertThat(ReflectionTestUtils - .getField(context.getBean(RequestMappingHandlerAdapter.class), "taskExecutor")) - .isSameAs(context.getBean(CustomAsyncTaskExecutorConfigurer.class).taskExecutor)); + .run((context) -> assertThat(context.getBean(RequestMappingHandlerAdapter.class)) + .extracting("taskExecutor") + .isSameAs(context.getBean(CustomAsyncTaskExecutorConfigurer.class).taskExecutor)); } @Test @@ -426,8 +425,8 @@ class WebMvcAutoConfigurationTests { this.contextRunner.withUserConfiguration(CustomAsyncTaskExecutorConfig.class) .withConfiguration(AutoConfigurations.of(TaskExecutionAutoConfiguration.class)).run((context) -> { assertThat(context).hasSingleBean(AsyncTaskExecutor.class); - assertThat(ReflectionTestUtils.getField(context.getBean(RequestMappingHandlerAdapter.class), - "taskExecutor")).isNotSameAs(context.getBean("customTaskExecutor")); + assertThat(context.getBean(RequestMappingHandlerAdapter.class)).extracting("taskExecutor") + .isNotSameAs(context.getBean("customTaskExecutor")); }); } @@ -643,8 +642,7 @@ class WebMvcAutoConfigurationTests { Validator validator = context.getBean(Validator.class); assertThat(validator).isInstanceOf(ValidatorAdapter.class); Validator target = ((ValidatorAdapter) validator).getTarget(); - assertThat(ReflectionTestUtils.getField(target, "targetValidator")) - .isSameAs(context.getBean("customJsr303Validator")); + assertThat(target).extracting("targetValidator").isSameAs(context.getBean("customJsr303Validator")); }); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/webservices/WebServicesAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/webservices/WebServicesAutoConfigurationTests.java index bf426aa0e5..d7ee1807e5 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/webservices/WebServicesAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/webservices/WebServicesAutoConfigurationTests.java @@ -25,7 +25,6 @@ import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.test.context.runner.WebApplicationContextRunner; import org.springframework.boot.web.servlet.ServletRegistrationBean; import org.springframework.context.ApplicationContext; -import org.springframework.test.util.ReflectionTestUtils; import org.springframework.ws.wsdl.wsdl11.SimpleWsdl11Definition; import org.springframework.xml.xsd.SimpleXsdSchema; @@ -72,7 +71,7 @@ class WebServicesAutoConfigurationTests { void customLoadOnStartup() { this.contextRunner.withPropertyValues("spring.webservices.servlet.load-on-startup=1").run((context) -> { ServletRegistrationBean registrationBean = context.getBean(ServletRegistrationBean.class); - assertThat(ReflectionTestUtils.getField(registrationBean, "loadOnStartup")).isEqualTo(1); + assertThat(registrationBean).extracting("loadOnStartup").isEqualTo(1); }); } diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/DataJpaTest.java b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/DataJpaTest.java index 1a9fef2c46..c12b3a743b 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/DataJpaTest.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/DataJpaTest.java @@ -104,7 +104,7 @@ public @interface DataJpaTest { /** * The {@link BootstrapMode} for the test repository support. Defaults to * {@link BootstrapMode#LAZY}. - * @return the {@link BootstrapMode} to use for test the repository + * @return the {@link BootstrapMode} to use for testing the repository */ @PropertyMapping("spring.data.jpa.repositories.bootstrap-mode") BootstrapMode bootstrapMode() default BootstrapMode.LAZY; diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/WebMvcTestAutoConfigurationIntegrationTests.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/WebMvcTestAutoConfigurationIntegrationTests.java index b1d652c33f..8561793111 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/WebMvcTestAutoConfigurationIntegrationTests.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/WebMvcTestAutoConfigurationIntegrationTests.java @@ -28,7 +28,6 @@ import org.springframework.boot.autoconfigure.task.TaskExecutionAutoConfiguratio import org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration; import org.springframework.context.ApplicationContext; import org.springframework.core.task.AsyncTaskExecutor; -import org.springframework.test.util.ReflectionTestUtils; import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter; import static org.assertj.core.api.Assertions.assertThat; @@ -75,8 +74,8 @@ class WebMvcTestAutoConfigurationIntegrationTests { @Test void asyncTaskExecutorWithApplicationTaskExecutor() { assertThat(this.applicationContext.getBeansOfType(AsyncTaskExecutor.class)).hasSize(1); - assertThat(ReflectionTestUtils.getField(this.applicationContext.getBean(RequestMappingHandlerAdapter.class), - "taskExecutor")).isSameAs(this.applicationContext.getBean("applicationTaskExecutor")); + assertThat(this.applicationContext.getBean(RequestMappingHandlerAdapter.class)).extracting("taskExecutor") + .isSameAs(this.applicationContext.getBean("applicationTaskExecutor")); } @Test diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/docs/asciidoc/packaging-oci-image.adoc b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/docs/asciidoc/packaging-oci-image.adoc index 289e7b5df3..82c25f4a09 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/docs/asciidoc/packaging-oci-image.adoc +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/docs/asciidoc/packaging-oci-image.adoc @@ -4,7 +4,7 @@ The plugin can create an https://github.com/opencontainers/image-spec[OCI image] using https://buildpacks.io/[Cloud Native Buildpacks]. Images can be built using the `build-image` goal and a local Docker installation. -The easiest way to get started is to to invoke `mvn spring-boot:build-image` on a project. +The easiest way to get started is to invoke `mvn spring-boot:build-image` on a project. It is possible to automate the creation of an image whenever the `package` phase is invoked, as shown in the following example: [source,xml,indent=0,subs="verbatim,attributes"] diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/task/TaskExecutorBuilderTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/task/TaskExecutorBuilderTests.java index 3d7838feea..871b3c9163 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/task/TaskExecutorBuilderTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/task/TaskExecutorBuilderTests.java @@ -24,7 +24,6 @@ import org.junit.jupiter.api.Test; import org.springframework.core.task.TaskDecorator; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; -import org.springframework.test.util.ReflectionTestUtils; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; @@ -76,7 +75,7 @@ class TaskExecutorBuilderTests { void taskDecoratorShouldApply() { TaskDecorator taskDecorator = mock(TaskDecorator.class); ThreadPoolTaskExecutor executor = this.builder.taskDecorator(taskDecorator).build(); - assertThat(ReflectionTestUtils.getField(executor, "taskDecorator")).isSameAs(taskDecorator); + assertThat(executor).extracting("taskDecorator").isSameAs(taskDecorator); } @Test diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/client/RestTemplateBuilderTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/client/RestTemplateBuilderTests.java index 57eb724cae..879231e907 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/client/RestTemplateBuilderTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/client/RestTemplateBuilderTests.java @@ -541,8 +541,7 @@ class RestTemplateBuilderTests { void readTimeoutCanBeConfiguredOnOkHttp3RequestFactory() { ClientHttpRequestFactory requestFactory = this.builder.requestFactory(OkHttp3ClientHttpRequestFactory.class) .setReadTimeout(Duration.ofMillis(1234)).build().getRequestFactory(); - assertThat(ReflectionTestUtils.getField(ReflectionTestUtils.getField(requestFactory, "client"), "readTimeout")) - .isEqualTo(1234); + assertThat(requestFactory).extracting("client").extracting("readTimeout").isEqualTo(1234); } @Test diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/DelegatingFilterProxyRegistrationBeanTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/DelegatingFilterProxyRegistrationBeanTests.java index 1a8912bee1..880966d212 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/DelegatingFilterProxyRegistrationBeanTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/DelegatingFilterProxyRegistrationBeanTests.java @@ -29,7 +29,6 @@ import org.springframework.mock.web.MockFilterConfig; import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.mock.web.MockHttpServletResponse; import org.springframework.mock.web.MockServletContext; -import org.springframework.test.util.ReflectionTestUtils; import org.springframework.web.context.support.GenericWebApplicationContext; import org.springframework.web.filter.DelegatingFilterProxy; import org.springframework.web.filter.GenericFilterBean; @@ -72,8 +71,8 @@ class DelegatingFilterProxyRegistrationBeanTests extends AbstractFilterRegistrat DelegatingFilterProxyRegistrationBean registrationBean = createFilterRegistrationBean(); Filter filter = registrationBean.getFilter(); assertThat(filter).isInstanceOf(DelegatingFilterProxy.class); - assertThat(ReflectionTestUtils.getField(filter, "webApplicationContext")).isEqualTo(this.applicationContext); - assertThat(ReflectionTestUtils.getField(filter, "targetBeanName")).isEqualTo("mockFilter"); + assertThat(filter).extracting("webApplicationContext").isEqualTo(this.applicationContext); + assertThat(filter).extracting("targetBeanName").isEqualTo("mockFilter"); } @Test From d65e06081f3a21727265e98df519ab52b0e11381 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Wed, 19 Feb 2020 09:35:28 +0100 Subject: [PATCH 2/2] Update copyright year of changed files See gh-20226 --- .../ReactiveCloudFoundryActuatorAutoConfigurationTests.java | 2 +- .../servlet/CloudFoundryActuatorAutoConfigurationTests.java | 2 +- ...urityRequestMatchersManagementContextConfigurationTests.java | 2 +- .../boot/autoconfigure/kafka/KafkaAutoConfigurationTests.java | 2 +- .../autoconfigure/task/TaskExecutionAutoConfigurationTests.java | 2 +- .../autoconfigure/web/servlet/WebMvcAutoConfigurationTests.java | 2 +- .../webservices/WebServicesAutoConfigurationTests.java | 2 +- .../org/springframework/boot/task/TaskExecutorBuilderTests.java | 2 +- .../boot/web/client/RestTemplateBuilderTests.java | 2 +- .../web/servlet/DelegatingFilterProxyRegistrationBeanTests.java | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/ReactiveCloudFoundryActuatorAutoConfigurationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/ReactiveCloudFoundryActuatorAutoConfigurationTests.java index 4af8216115..93836b307c 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/ReactiveCloudFoundryActuatorAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/ReactiveCloudFoundryActuatorAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/CloudFoundryActuatorAutoConfigurationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/CloudFoundryActuatorAutoConfigurationTests.java index 465c9e2175..a565106a26 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/CloudFoundryActuatorAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/CloudFoundryActuatorAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/security/servlet/SecurityRequestMatchersManagementContextConfigurationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/security/servlet/SecurityRequestMatchersManagementContextConfigurationTests.java index dd8f8db92f..fd54589bc6 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/security/servlet/SecurityRequestMatchersManagementContextConfigurationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/security/servlet/SecurityRequestMatchersManagementContextConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/kafka/KafkaAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/kafka/KafkaAutoConfigurationTests.java index dbb998bf20..fe2da15973 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/kafka/KafkaAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/kafka/KafkaAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/task/TaskExecutionAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/task/TaskExecutionAutoConfigurationTests.java index cde404fb13..fe440a6139 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/task/TaskExecutionAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/task/TaskExecutionAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfigurationTests.java index 6bfe8263c8..7f7790e21e 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/webservices/WebServicesAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/webservices/WebServicesAutoConfigurationTests.java index d7ee1807e5..27d64c3afc 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/webservices/WebServicesAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/webservices/WebServicesAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/task/TaskExecutorBuilderTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/task/TaskExecutorBuilderTests.java index 871b3c9163..ca4675ccce 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/task/TaskExecutorBuilderTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/task/TaskExecutorBuilderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/client/RestTemplateBuilderTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/client/RestTemplateBuilderTests.java index 879231e907..75b038ab33 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/client/RestTemplateBuilderTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/client/RestTemplateBuilderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/DelegatingFilterProxyRegistrationBeanTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/DelegatingFilterProxyRegistrationBeanTests.java index 880966d212..10450eb49e 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/DelegatingFilterProxyRegistrationBeanTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/DelegatingFilterProxyRegistrationBeanTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.