Merge pull request #20226 from izeye

* pr/20226:
  Update copyright year of changed files
  Polish

Closes gh-20226
pull/20230/head
Stephane Nicoll 5 years ago
commit fc3fb7fb44

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -240,8 +240,7 @@ class ReactiveCloudFoundryActuatorAutoConfigurationTests {
ExposableWebEndpoint endpoint = endpoints.iterator().next(); ExposableWebEndpoint endpoint = endpoints.iterator().next();
assertThat(endpoint.getOperations()).hasSize(2); assertThat(endpoint.getOperations()).hasSize(2);
WebOperation webOperation = findOperationWithRequestPath(endpoint, "health"); WebOperation webOperation = findOperationWithRequestPath(endpoint, "health");
Object invoker = ReflectionTestUtils.getField(webOperation, "invoker"); assertThat(webOperation).extracting("invoker").extracting("target")
assertThat(ReflectionTestUtils.getField(invoker, "target"))
.isInstanceOf(CloudFoundryReactiveHealthEndpointWebExtension.class); .isInstanceOf(CloudFoundryReactiveHealthEndpointWebExtension.class);
}); });
} }

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -231,8 +231,7 @@ class CloudFoundryActuatorAutoConfigurationTests {
ExposableWebEndpoint endpoint = endpoints.iterator().next(); ExposableWebEndpoint endpoint = endpoints.iterator().next();
assertThat(endpoint.getOperations()).hasSize(2); assertThat(endpoint.getOperations()).hasSize(2);
WebOperation webOperation = findOperationWithRequestPath(endpoint, "health"); WebOperation webOperation = findOperationWithRequestPath(endpoint, "health");
Object invoker = ReflectionTestUtils.getField(webOperation, "invoker"); assertThat(webOperation).extracting("invoker").extracting("target")
assertThat(ReflectionTestUtils.getField(invoker, "target"))
.isInstanceOf(CloudFoundryHealthEndpointWebExtension.class); .isInstanceOf(CloudFoundryHealthEndpointWebExtension.class);
}); });
} }

@ -33,7 +33,6 @@ import org.springframework.boot.test.system.CapturedOutput;
import org.springframework.boot.test.system.OutputCaptureExtension; import org.springframework.boot.test.system.OutputCaptureExtension;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.test.util.ReflectionTestUtils;
import org.springframework.test.web.reactive.server.WebTestClient; import org.springframework.test.web.reactive.server.WebTestClient;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
@ -57,8 +56,8 @@ class WebFluxMetricsAutoConfigurationTests {
this.contextRunner.run((context) -> { this.contextRunner.run((context) -> {
assertThat(context).getBeans(MetricsWebFilter.class).hasSize(1); assertThat(context).getBeans(MetricsWebFilter.class).hasSize(1);
assertThat(context).getBeans(DefaultWebFluxTagsProvider.class).hasSize(1); assertThat(context).getBeans(DefaultWebFluxTagsProvider.class).hasSize(1);
assertThat(ReflectionTestUtils.getField(context.getBean(DefaultWebFluxTagsProvider.class), assertThat(context.getBean(DefaultWebFluxTagsProvider.class)).extracting("ignoreTrailingSlash")
"ignoreTrailingSlash")).isEqualTo(true); .isEqualTo(true);
}); });
} }
@ -67,8 +66,8 @@ class WebFluxMetricsAutoConfigurationTests {
this.contextRunner.withPropertyValues("management.metrics.web.server.request.ignore-trailing-slash=false") this.contextRunner.withPropertyValues("management.metrics.web.server.request.ignore-trailing-slash=false")
.run((context) -> { .run((context) -> {
assertThat(context).hasSingleBean(DefaultWebFluxTagsProvider.class); assertThat(context).hasSingleBean(DefaultWebFluxTagsProvider.class);
assertThat(ReflectionTestUtils.getField(context.getBean(DefaultWebFluxTagsProvider.class), assertThat(context.getBean(DefaultWebFluxTagsProvider.class)).extracting("ignoreTrailingSlash")
"ignoreTrailingSlash")).isEqualTo(false); .isEqualTo(false);
}); });
} }

@ -50,7 +50,6 @@ import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered; import org.springframework.core.Ordered;
import org.springframework.test.util.ReflectionTestUtils;
import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import org.springframework.test.web.servlet.setup.MockMvcBuilders; import org.springframework.test.web.servlet.setup.MockMvcBuilders;
@ -84,8 +83,8 @@ class WebMvcMetricsAutoConfigurationTests {
void definesTagsProviderAndFilterWhenMeterRegistryIsPresent() { void definesTagsProviderAndFilterWhenMeterRegistryIsPresent() {
this.contextRunner.run((context) -> { this.contextRunner.run((context) -> {
assertThat(context).hasSingleBean(DefaultWebMvcTagsProvider.class); assertThat(context).hasSingleBean(DefaultWebMvcTagsProvider.class);
assertThat(ReflectionTestUtils.getField(context.getBean(DefaultWebMvcTagsProvider.class), assertThat(context.getBean(DefaultWebMvcTagsProvider.class)).extracting("ignoreTrailingSlash")
"ignoreTrailingSlash")).isEqualTo(true); .isEqualTo(true);
assertThat(context).hasSingleBean(FilterRegistrationBean.class); assertThat(context).hasSingleBean(FilterRegistrationBean.class);
assertThat(context.getBean(FilterRegistrationBean.class).getFilter()) assertThat(context.getBean(FilterRegistrationBean.class).getFilter())
.isInstanceOf(WebMvcMetricsFilter.class); .isInstanceOf(WebMvcMetricsFilter.class);
@ -97,8 +96,8 @@ class WebMvcMetricsAutoConfigurationTests {
this.contextRunner.withPropertyValues("management.metrics.web.server.request.ignore-trailing-slash=false") this.contextRunner.withPropertyValues("management.metrics.web.server.request.ignore-trailing-slash=false")
.run((context) -> { .run((context) -> {
assertThat(context).hasSingleBean(DefaultWebMvcTagsProvider.class); assertThat(context).hasSingleBean(DefaultWebMvcTagsProvider.class);
assertThat(ReflectionTestUtils.getField(context.getBean(DefaultWebMvcTagsProvider.class), assertThat(context.getBean(DefaultWebMvcTagsProvider.class)).extracting("ignoreTrailingSlash")
"ignoreTrailingSlash")).isEqualTo(false); .isEqualTo(false);
}); });
} }

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -29,7 +29,6 @@ import org.springframework.boot.test.context.runner.WebApplicationContextRunner;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.security.web.util.matcher.RequestMatcher; import org.springframework.security.web.util.matcher.RequestMatcher;
import org.springframework.test.util.ReflectionTestUtils;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
@ -64,7 +63,7 @@ class SecurityRequestMatchersManagementContextConfigurationTests {
this.contextRunner.withUserConfiguration(TestMvcConfiguration.class).run((context) -> { this.contextRunner.withUserConfiguration(TestMvcConfiguration.class).run((context) -> {
AntPathRequestMatcherProvider matcherProvider = context.getBean(AntPathRequestMatcherProvider.class); AntPathRequestMatcherProvider matcherProvider = context.getBean(AntPathRequestMatcherProvider.class);
RequestMatcher requestMatcher = matcherProvider.getRequestMatcher("/example"); 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 AntPathRequestMatcherProvider matcherProvider = context
.getBean(AntPathRequestMatcherProvider.class); .getBean(AntPathRequestMatcherProvider.class);
RequestMatcher requestMatcher = matcherProvider.getRequestMatcher("/example"); RequestMatcher requestMatcher = matcherProvider.getRequestMatcher("/example");
assertThat(ReflectionTestUtils.getField(requestMatcher, "pattern")).isEqualTo("/admin/example"); assertThat(requestMatcher).extracting("pattern").isEqualTo("/admin/example");
}); });
} }

@ -79,8 +79,7 @@ class CassandraDataAutoConfigurationTests {
void userTypeResolverShouldBeSet() { void userTypeResolverShouldBeSet() {
load(); load();
CassandraMappingContext mappingContext = this.context.getBean(CassandraMappingContext.class); CassandraMappingContext mappingContext = this.context.getBean(CassandraMappingContext.class);
assertThat(ReflectionTestUtils.getField(mappingContext, "userTypeResolver")) assertThat(mappingContext).extracting("userTypeResolver").isInstanceOf(SimpleUserTypeResolver.class);
.isInstanceOf(SimpleUserTypeResolver.class);
} }
@Test @Test

@ -75,8 +75,7 @@ class CassandraReactiveDataAutoConfigurationTests {
void userTypeResolverShouldBeSet() { void userTypeResolverShouldBeSet() {
load("spring.data.cassandra.keyspaceName:boot_test"); load("spring.data.cassandra.keyspaceName:boot_test");
CassandraMappingContext mappingContext = this.context.getBean(CassandraMappingContext.class); CassandraMappingContext mappingContext = this.context.getBean(CassandraMappingContext.class);
assertThat(ReflectionTestUtils.getField(mappingContext, "userTypeResolver")) assertThat(mappingContext).extracting("userTypeResolver").isInstanceOf(SimpleUserTypeResolver.class);
.isInstanceOf(SimpleUserTypeResolver.class);
} }
private void load(String... environment) { private void load(String... environment) {

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -389,7 +389,7 @@ class KafkaAutoConfigurationTests {
assertThat(containerProperties.getMonitorInterval()).isEqualTo(45); assertThat(containerProperties.getMonitorInterval()).isEqualTo(45);
assertThat(containerProperties.isLogContainerConfig()).isTrue(); assertThat(containerProperties.isLogContainerConfig()).isTrue();
assertThat(containerProperties.isMissingTopicsFatal()).isFalse(); assertThat(containerProperties.isMissingTopicsFatal()).isFalse();
assertThat(ReflectionTestUtils.getField(kafkaListenerContainerFactory, "concurrency")).isEqualTo(3); assertThat(kafkaListenerContainerFactory).extracting("concurrency").isEqualTo(3);
assertThat(kafkaListenerContainerFactory.isBatchListener()).isTrue(); assertThat(kafkaListenerContainerFactory.isBatchListener()).isTrue();
assertThat(context.getBeansOfType(KafkaJaasLoginModuleInitializer.class)).hasSize(1); assertThat(context.getBeansOfType(KafkaJaasLoginModuleInitializer.class)).hasSize(1);
KafkaJaasLoginModuleInitializer jaas = context.getBean(KafkaJaasLoginModuleInitializer.class); KafkaJaasLoginModuleInitializer jaas = context.getBean(KafkaJaasLoginModuleInitializer.class);

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -41,7 +41,6 @@ import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; 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.assertThat;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
@ -92,8 +91,7 @@ class TaskExecutionAutoConfigurationTests {
this.contextRunner.withUserConfiguration(TaskDecoratorConfig.class).run((context) -> { this.contextRunner.withUserConfiguration(TaskDecoratorConfig.class).run((context) -> {
assertThat(context).hasSingleBean(TaskExecutorBuilder.class); assertThat(context).hasSingleBean(TaskExecutorBuilder.class);
ThreadPoolTaskExecutor executor = context.getBean(TaskExecutorBuilder.class).build(); ThreadPoolTaskExecutor executor = context.getBean(TaskExecutorBuilder.class).build();
assertThat(ReflectionTestUtils.getField(executor, "taskDecorator")) assertThat(executor).extracting("taskDecorator").isSameAs(context.getBean(TaskDecorator.class));
.isSameAs(context.getBean(TaskDecorator.class));
}); });
} }

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -380,16 +380,15 @@ class WebMvcAutoConfigurationTests {
@Test @Test
void defaultAsyncRequestTimeout() { void defaultAsyncRequestTimeout() {
this.contextRunner.run((context) -> assertThat(ReflectionTestUtils this.contextRunner.run((context) -> assertThat(context.getBean(RequestMappingHandlerAdapter.class))
.getField(context.getBean(RequestMappingHandlerAdapter.class), "asyncRequestTimeout")).isNull()); .extracting("asyncRequestTimeout").isNull());
} }
@Test @Test
void customAsyncRequestTimeout() { void customAsyncRequestTimeout() {
this.contextRunner.withPropertyValues("spring.mvc.async.request-timeout:12345") this.contextRunner.withPropertyValues("spring.mvc.async.request-timeout:12345")
.run((context) -> assertThat(ReflectionTestUtils .run((context) -> assertThat(context.getBean(RequestMappingHandlerAdapter.class))
.getField(context.getBean(RequestMappingHandlerAdapter.class), "asyncRequestTimeout")) .extracting("asyncRequestTimeout").isEqualTo(12345L));
.isEqualTo(12345L));
} }
@Test @Test
@ -397,8 +396,8 @@ class WebMvcAutoConfigurationTests {
this.contextRunner.withConfiguration(AutoConfigurations.of(TaskExecutionAutoConfiguration.class)) this.contextRunner.withConfiguration(AutoConfigurations.of(TaskExecutionAutoConfiguration.class))
.run((context) -> { .run((context) -> {
assertThat(context).hasSingleBean(AsyncTaskExecutor.class); assertThat(context).hasSingleBean(AsyncTaskExecutor.class);
assertThat(ReflectionTestUtils.getField(context.getBean(RequestMappingHandlerAdapter.class), assertThat(context.getBean(RequestMappingHandlerAdapter.class)).extracting("taskExecutor")
"taskExecutor")).isSameAs(context.getBean("applicationTaskExecutor")); .isSameAs(context.getBean("applicationTaskExecutor"));
}); });
} }
@ -407,8 +406,8 @@ class WebMvcAutoConfigurationTests {
this.contextRunner.withUserConfiguration(CustomApplicationTaskExecutorConfig.class) this.contextRunner.withUserConfiguration(CustomApplicationTaskExecutorConfig.class)
.withConfiguration(AutoConfigurations.of(TaskExecutionAutoConfiguration.class)).run((context) -> { .withConfiguration(AutoConfigurations.of(TaskExecutionAutoConfiguration.class)).run((context) -> {
assertThat(context).doesNotHaveBean(AsyncTaskExecutor.class); assertThat(context).doesNotHaveBean(AsyncTaskExecutor.class);
assertThat(ReflectionTestUtils.getField(context.getBean(RequestMappingHandlerAdapter.class), assertThat(context.getBean(RequestMappingHandlerAdapter.class)).extracting("taskExecutor")
"taskExecutor")).isNotSameAs(context.getBean("applicationTaskExecutor")); .isNotSameAs(context.getBean("applicationTaskExecutor"));
}); });
} }
@ -416,9 +415,9 @@ class WebMvcAutoConfigurationTests {
void asyncTaskExecutorWithMvcConfigurerCanOverrideExecutor() { void asyncTaskExecutorWithMvcConfigurerCanOverrideExecutor() {
this.contextRunner.withUserConfiguration(CustomAsyncTaskExecutorConfigurer.class) this.contextRunner.withUserConfiguration(CustomAsyncTaskExecutorConfigurer.class)
.withConfiguration(AutoConfigurations.of(TaskExecutionAutoConfiguration.class)) .withConfiguration(AutoConfigurations.of(TaskExecutionAutoConfiguration.class))
.run((context) -> assertThat(ReflectionTestUtils .run((context) -> assertThat(context.getBean(RequestMappingHandlerAdapter.class))
.getField(context.getBean(RequestMappingHandlerAdapter.class), "taskExecutor")) .extracting("taskExecutor")
.isSameAs(context.getBean(CustomAsyncTaskExecutorConfigurer.class).taskExecutor)); .isSameAs(context.getBean(CustomAsyncTaskExecutorConfigurer.class).taskExecutor));
} }
@Test @Test
@ -426,8 +425,8 @@ class WebMvcAutoConfigurationTests {
this.contextRunner.withUserConfiguration(CustomAsyncTaskExecutorConfig.class) this.contextRunner.withUserConfiguration(CustomAsyncTaskExecutorConfig.class)
.withConfiguration(AutoConfigurations.of(TaskExecutionAutoConfiguration.class)).run((context) -> { .withConfiguration(AutoConfigurations.of(TaskExecutionAutoConfiguration.class)).run((context) -> {
assertThat(context).hasSingleBean(AsyncTaskExecutor.class); assertThat(context).hasSingleBean(AsyncTaskExecutor.class);
assertThat(ReflectionTestUtils.getField(context.getBean(RequestMappingHandlerAdapter.class), assertThat(context.getBean(RequestMappingHandlerAdapter.class)).extracting("taskExecutor")
"taskExecutor")).isNotSameAs(context.getBean("customTaskExecutor")); .isNotSameAs(context.getBean("customTaskExecutor"));
}); });
} }
@ -643,8 +642,7 @@ class WebMvcAutoConfigurationTests {
Validator validator = context.getBean(Validator.class); Validator validator = context.getBean(Validator.class);
assertThat(validator).isInstanceOf(ValidatorAdapter.class); assertThat(validator).isInstanceOf(ValidatorAdapter.class);
Validator target = ((ValidatorAdapter) validator).getTarget(); Validator target = ((ValidatorAdapter) validator).getTarget();
assertThat(ReflectionTestUtils.getField(target, "targetValidator")) assertThat(target).extracting("targetValidator").isSameAs(context.getBean("customJsr303Validator"));
.isSameAs(context.getBean("customJsr303Validator"));
}); });
} }

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -25,7 +25,6 @@ import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.test.context.runner.WebApplicationContextRunner; import org.springframework.boot.test.context.runner.WebApplicationContextRunner;
import org.springframework.boot.web.servlet.ServletRegistrationBean; import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.test.util.ReflectionTestUtils;
import org.springframework.ws.wsdl.wsdl11.SimpleWsdl11Definition; import org.springframework.ws.wsdl.wsdl11.SimpleWsdl11Definition;
import org.springframework.xml.xsd.SimpleXsdSchema; import org.springframework.xml.xsd.SimpleXsdSchema;
@ -72,7 +71,7 @@ class WebServicesAutoConfigurationTests {
void customLoadOnStartup() { void customLoadOnStartup() {
this.contextRunner.withPropertyValues("spring.webservices.servlet.load-on-startup=1").run((context) -> { this.contextRunner.withPropertyValues("spring.webservices.servlet.load-on-startup=1").run((context) -> {
ServletRegistrationBean<?> registrationBean = context.getBean(ServletRegistrationBean.class); ServletRegistrationBean<?> registrationBean = context.getBean(ServletRegistrationBean.class);
assertThat(ReflectionTestUtils.getField(registrationBean, "loadOnStartup")).isEqualTo(1); assertThat(registrationBean).extracting("loadOnStartup").isEqualTo(1);
}); });
} }

@ -104,7 +104,7 @@ public @interface DataJpaTest {
/** /**
* The {@link BootstrapMode} for the test repository support. Defaults to * The {@link BootstrapMode} for the test repository support. Defaults to
* {@link BootstrapMode#LAZY}. * {@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") @PropertyMapping("spring.data.jpa.repositories.bootstrap-mode")
BootstrapMode bootstrapMode() default BootstrapMode.LAZY; BootstrapMode bootstrapMode() default BootstrapMode.LAZY;

@ -28,7 +28,6 @@ import org.springframework.boot.autoconfigure.task.TaskExecutionAutoConfiguratio
import org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration; import org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.core.task.AsyncTaskExecutor; import org.springframework.core.task.AsyncTaskExecutor;
import org.springframework.test.util.ReflectionTestUtils;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter; import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
@ -75,8 +74,8 @@ class WebMvcTestAutoConfigurationIntegrationTests {
@Test @Test
void asyncTaskExecutorWithApplicationTaskExecutor() { void asyncTaskExecutorWithApplicationTaskExecutor() {
assertThat(this.applicationContext.getBeansOfType(AsyncTaskExecutor.class)).hasSize(1); assertThat(this.applicationContext.getBeansOfType(AsyncTaskExecutor.class)).hasSize(1);
assertThat(ReflectionTestUtils.getField(this.applicationContext.getBean(RequestMappingHandlerAdapter.class), assertThat(this.applicationContext.getBean(RequestMappingHandlerAdapter.class)).extracting("taskExecutor")
"taskExecutor")).isSameAs(this.applicationContext.getBean("applicationTaskExecutor")); .isSameAs(this.applicationContext.getBean("applicationTaskExecutor"));
} }
@Test @Test

@ -4,7 +4,7 @@
The plugin can create an https://github.com/opencontainers/image-spec[OCI image] using https://buildpacks.io/[Cloud Native Buildpacks]. 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. 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: 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"] [source,xml,indent=0,subs="verbatim,attributes"]

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -24,7 +24,6 @@ import org.junit.jupiter.api.Test;
import org.springframework.core.task.TaskDecorator; import org.springframework.core.task.TaskDecorator;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; 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.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
@ -76,7 +75,7 @@ class TaskExecutorBuilderTests {
void taskDecoratorShouldApply() { void taskDecoratorShouldApply() {
TaskDecorator taskDecorator = mock(TaskDecorator.class); TaskDecorator taskDecorator = mock(TaskDecorator.class);
ThreadPoolTaskExecutor executor = this.builder.taskDecorator(taskDecorator).build(); ThreadPoolTaskExecutor executor = this.builder.taskDecorator(taskDecorator).build();
assertThat(ReflectionTestUtils.getField(executor, "taskDecorator")).isSameAs(taskDecorator); assertThat(executor).extracting("taskDecorator").isSameAs(taskDecorator);
} }
@Test @Test

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -541,8 +541,7 @@ class RestTemplateBuilderTests {
void readTimeoutCanBeConfiguredOnOkHttp3RequestFactory() { void readTimeoutCanBeConfiguredOnOkHttp3RequestFactory() {
ClientHttpRequestFactory requestFactory = this.builder.requestFactory(OkHttp3ClientHttpRequestFactory.class) ClientHttpRequestFactory requestFactory = this.builder.requestFactory(OkHttp3ClientHttpRequestFactory.class)
.setReadTimeout(Duration.ofMillis(1234)).build().getRequestFactory(); .setReadTimeout(Duration.ofMillis(1234)).build().getRequestFactory();
assertThat(ReflectionTestUtils.getField(ReflectionTestUtils.getField(requestFactory, "client"), "readTimeout")) assertThat(requestFactory).extracting("client").extracting("readTimeout").isEqualTo(1234);
.isEqualTo(1234);
} }
@Test @Test

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -29,7 +29,6 @@ import org.springframework.mock.web.MockFilterConfig;
import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse; import org.springframework.mock.web.MockHttpServletResponse;
import org.springframework.mock.web.MockServletContext; import org.springframework.mock.web.MockServletContext;
import org.springframework.test.util.ReflectionTestUtils;
import org.springframework.web.context.support.GenericWebApplicationContext; import org.springframework.web.context.support.GenericWebApplicationContext;
import org.springframework.web.filter.DelegatingFilterProxy; import org.springframework.web.filter.DelegatingFilterProxy;
import org.springframework.web.filter.GenericFilterBean; import org.springframework.web.filter.GenericFilterBean;
@ -72,8 +71,8 @@ class DelegatingFilterProxyRegistrationBeanTests extends AbstractFilterRegistrat
DelegatingFilterProxyRegistrationBean registrationBean = createFilterRegistrationBean(); DelegatingFilterProxyRegistrationBean registrationBean = createFilterRegistrationBean();
Filter filter = registrationBean.getFilter(); Filter filter = registrationBean.getFilter();
assertThat(filter).isInstanceOf(DelegatingFilterProxy.class); assertThat(filter).isInstanceOf(DelegatingFilterProxy.class);
assertThat(ReflectionTestUtils.getField(filter, "webApplicationContext")).isEqualTo(this.applicationContext); assertThat(filter).extracting("webApplicationContext").isEqualTo(this.applicationContext);
assertThat(ReflectionTestUtils.getField(filter, "targetBeanName")).isEqualTo("mockFilter"); assertThat(filter).extracting("targetBeanName").isEqualTo("mockFilter");
} }
@Test @Test

Loading…
Cancel
Save