Skip to content

Commit ef5c2af

Browse files
committed
Polish
1 parent dd0ce54 commit ef5c2af

File tree

22 files changed

+528
-349
lines changed

22 files changed

+528
-349
lines changed

spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/HealthIndicatorAutoConfigurationTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
import org.springframework.boot.context.properties.EnableConfigurationProperties;
5959
import org.springframework.boot.test.context.ContextConsumer;
6060
import org.springframework.boot.test.context.ContextLoader;
61-
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
61+
import org.springframework.boot.test.context.StandardContextLoader;
6262
import org.springframework.context.annotation.Bean;
6363
import org.springframework.context.annotation.Configuration;
6464
import org.springframework.data.cassandra.core.CassandraOperations;
@@ -80,8 +80,8 @@
8080
*/
8181
public class HealthIndicatorAutoConfigurationTests {
8282

83-
public final ContextLoader<AnnotationConfigApplicationContext> contextLoader = ContextLoader
84-
.standard().autoConfig(HealthIndicatorAutoConfiguration.class,
83+
public final StandardContextLoader contextLoader = ContextLoader.standard()
84+
.autoConfig(HealthIndicatorAutoConfiguration.class,
8585
ManagementServerProperties.class);
8686

8787
@Test
@@ -380,7 +380,7 @@ public void notNeo4jHealthIndicator() throws Exception {
380380
.load(hasSingleHealthIndicator(ApplicationHealthIndicator.class));
381381
}
382382

383-
private ContextConsumer<AnnotationConfigApplicationContext> hasSingleHealthIndicator(
383+
private ContextConsumer hasSingleHealthIndicator(
384384
Class<? extends HealthIndicator> type) {
385385
return context -> {
386386
Map<String, HealthIndicator> beans = context

spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/cache/CacheAutoConfigurationTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
import org.springframework.boot.autoconfigure.cache.support.MockCachingProvider;
5757
import org.springframework.boot.autoconfigure.hazelcast.HazelcastAutoConfiguration;
5858
import org.springframework.boot.test.context.ContextLoader;
59+
import org.springframework.boot.test.context.StandardContextLoader;
5960
import org.springframework.boot.testsupport.runner.classpath.ClassPathExclusions;
6061
import org.springframework.boot.testsupport.runner.classpath.ModifiedClassPathRunner;
6162
import org.springframework.cache.Cache;
@@ -73,7 +74,6 @@
7374
import org.springframework.cache.support.NoOpCacheManager;
7475
import org.springframework.cache.support.SimpleCacheManager;
7576
import org.springframework.context.ConfigurableApplicationContext;
76-
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
7777
import org.springframework.context.annotation.Bean;
7878
import org.springframework.context.annotation.Configuration;
7979
import org.springframework.context.annotation.Import;
@@ -101,8 +101,8 @@ public class CacheAutoConfigurationTests {
101101
@Rule
102102
public final ExpectedException thrown = ExpectedException.none();
103103

104-
private final ContextLoader<AnnotationConfigApplicationContext> contextLoader = ContextLoader
105-
.standard().autoConfig(CacheAutoConfiguration.class);
104+
private final StandardContextLoader contextLoader = ContextLoader.standard()
105+
.autoConfig(CacheAutoConfiguration.class);
106106

107107
@Test
108108
public void noEnableCaching() {

spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/hazelcast/HazelcastAutoConfigurationClientTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
import org.springframework.beans.factory.BeanCreationException;
3131
import org.springframework.boot.test.context.ContextLoader;
32-
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
32+
import org.springframework.boot.test.context.StandardContextLoader;
3333
import org.springframework.context.annotation.Bean;
3434
import org.springframework.context.annotation.Configuration;
3535

@@ -60,8 +60,8 @@ public static void close() {
6060
}
6161
}
6262

63-
private final ContextLoader<AnnotationConfigApplicationContext> contextLoader = ContextLoader
64-
.standard().autoConfig(HazelcastAutoConfiguration.class);
63+
private final StandardContextLoader contextLoader = ContextLoader.standard()
64+
.autoConfig(HazelcastAutoConfiguration.class);
6565

6666
@Test
6767
public void systemProperty() throws IOException {

spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/hazelcast/HazelcastAutoConfigurationServerTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@
2828

2929
import org.springframework.beans.factory.BeanCreationException;
3030
import org.springframework.boot.test.context.ContextLoader;
31+
import org.springframework.boot.test.context.StandardContextLoader;
3132
import org.springframework.boot.testsupport.runner.classpath.ClassPathExclusions;
3233
import org.springframework.boot.testsupport.runner.classpath.ModifiedClassPathRunner;
33-
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
3434
import org.springframework.context.annotation.Bean;
3535
import org.springframework.context.annotation.Configuration;
3636
import org.springframework.core.io.ClassPathResource;
@@ -46,8 +46,8 @@
4646
@ClassPathExclusions("hazelcast-client-*.jar")
4747
public class HazelcastAutoConfigurationServerTests {
4848

49-
private final ContextLoader<AnnotationConfigApplicationContext> contextLoader = ContextLoader
50-
.standard().autoConfig(HazelcastAutoConfiguration.class);
49+
private final StandardContextLoader contextLoader = ContextLoader.standard()
50+
.autoConfig(HazelcastAutoConfiguration.class);
5151

5252
@Test
5353
public void defaultConfigFile() throws IOException {

spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/hazelcast/HazelcastAutoConfigurationTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import org.junit.Test;
2323

2424
import org.springframework.boot.test.context.ContextLoader;
25-
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
25+
import org.springframework.boot.test.context.StandardContextLoader;
2626
import org.springframework.core.io.ClassPathResource;
2727

2828
import static org.assertj.core.api.Assertions.assertThat;
@@ -34,7 +34,7 @@
3434
*/
3535
public class HazelcastAutoConfigurationTests {
3636

37-
private final ContextLoader<AnnotationConfigApplicationContext> contextLoader = ContextLoader
37+
private final StandardContextLoader contextLoader = ContextLoader
3838
.standard().autoConfig(HazelcastAutoConfiguration.class);
3939

4040
@Test

spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfigurationTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
import org.springframework.boot.test.context.ContextConsumer;
4242
import org.springframework.boot.test.context.ContextLoader;
4343
import org.springframework.boot.test.context.HidePackagesClassLoader;
44-
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
44+
import org.springframework.boot.test.context.StandardContextLoader;
4545
import org.springframework.context.annotation.Bean;
4646
import org.springframework.context.annotation.Configuration;
4747
import org.springframework.jdbc.core.JdbcTemplate;
@@ -58,7 +58,7 @@
5858
*/
5959
public class DataSourceAutoConfigurationTests {
6060

61-
private final ContextLoader<AnnotationConfigApplicationContext> contextLoader = ContextLoader
61+
private final StandardContextLoader contextLoader = ContextLoader
6262
.standard().autoConfig(DataSourceAutoConfiguration.class)
6363
.env("spring.datasource.initialize=false",
6464
"spring.datasource.url:jdbc:hsqldb:mem:testdb-"
@@ -185,7 +185,7 @@ public void explicitTypeSupportedDataSource() {
185185
.load(testExplicitType());
186186
}
187187

188-
private ContextConsumer<AnnotationConfigApplicationContext> testExplicitType() {
188+
private ContextConsumer testExplicitType() {
189189
return context -> {
190190
assertThat(context.getBeansOfType(DataSource.class)).hasSize(1);
191191
DataSource bean = context.getBean(DataSource.class);

spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jms/JmsAutoConfigurationTests.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import org.springframework.beans.factory.config.BeanPostProcessor;
2929
import org.springframework.boot.autoconfigure.jms.activemq.ActiveMQAutoConfiguration;
3030
import org.springframework.boot.test.context.ContextLoader;
31-
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
31+
import org.springframework.boot.test.context.StandardContextLoader;
3232
import org.springframework.context.annotation.Bean;
3333
import org.springframework.context.annotation.Configuration;
3434
import org.springframework.context.annotation.Primary;
@@ -62,8 +62,7 @@ public class JmsAutoConfigurationTests {
6262

6363
private static final String ACTIVEMQ_NETWORK_URL = "tcp://localhost:61616";
6464

65-
private final ContextLoader<AnnotationConfigApplicationContext> contextLoader = ContextLoader
66-
.standard()
65+
private final StandardContextLoader contextLoader = ContextLoader.standard()
6766
.autoConfig(ActiveMQAutoConfiguration.class, JmsAutoConfiguration.class);
6867

6968
@Test

spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jms/activemq/ActiveMQAutoConfigurationTests.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
import org.springframework.boot.autoconfigure.jms.JmsAutoConfiguration;
2727
import org.springframework.boot.test.context.ContextLoader;
28-
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
28+
import org.springframework.boot.test.context.StandardContextLoader;
2929
import org.springframework.context.annotation.Bean;
3030
import org.springframework.context.annotation.Configuration;
3131

@@ -42,8 +42,7 @@
4242
*/
4343
public class ActiveMQAutoConfigurationTests {
4444

45-
private final ContextLoader<AnnotationConfigApplicationContext> contextLoader = ContextLoader
46-
.standard()
45+
private final StandardContextLoader contextLoader = ContextLoader.standard()
4746
.autoConfig(ActiveMQAutoConfiguration.class, JmsAutoConfiguration.class);
4847

4948
@Test

spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jms/artemis/ArtemisAutoConfigurationTests.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@
4343

4444
import org.springframework.boot.autoconfigure.jms.JmsAutoConfiguration;
4545
import org.springframework.boot.test.context.ContextLoader;
46+
import org.springframework.boot.test.context.StandardContextLoader;
4647
import org.springframework.context.ApplicationContext;
47-
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
4848
import org.springframework.context.annotation.Bean;
4949
import org.springframework.context.annotation.Configuration;
5050
import org.springframework.jms.core.JmsTemplate;
@@ -66,8 +66,7 @@ public class ArtemisAutoConfigurationTests {
6666
@Rule
6767
public final TemporaryFolder folder = new TemporaryFolder();
6868

69-
private final ContextLoader<AnnotationConfigApplicationContext> contextLoader = ContextLoader
70-
.standard()
69+
private final StandardContextLoader contextLoader = ContextLoader.standard()
7170
.autoConfig(ArtemisAutoConfiguration.class, JmsAutoConfiguration.class);
7271

7372
@Test

spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/HttpHandlerAutoConfigurationTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import org.junit.Test;
2020

2121
import org.springframework.boot.test.context.ContextLoader;
22-
import org.springframework.boot.web.reactive.context.GenericReactiveWebApplicationContext;
22+
import org.springframework.boot.test.context.ReactiveWebContextLoader;
2323
import org.springframework.context.annotation.Bean;
2424
import org.springframework.context.annotation.Configuration;
2525
import org.springframework.http.server.reactive.HttpHandler;
@@ -39,8 +39,8 @@
3939
*/
4040
public class HttpHandlerAutoConfigurationTests {
4141

42-
private final ContextLoader<GenericReactiveWebApplicationContext> contextLoader = ContextLoader
43-
.reactiveWeb().autoConfig(HttpHandlerAutoConfiguration.class);
42+
private final ReactiveWebContextLoader contextLoader = ContextLoader.reactiveWeb()
43+
.autoConfig(HttpHandlerAutoConfiguration.class);
4444

4545
@Test
4646
public void shouldNotProcessIfExistingHttpHandler() {

spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfigurationTests.java

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration.WebMvcAutoConfigurationAdapter;
3939
import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration.WelcomePageHandlerMapping;
4040
import org.springframework.boot.test.context.ContextLoader;
41+
import org.springframework.boot.test.context.ServletWebContextLoader;
4142
import org.springframework.boot.web.server.WebServerFactoryCustomizerBeanPostProcessor;
4243
import org.springframework.boot.web.servlet.filter.OrderedHttpPutFormContentFilter;
4344
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
@@ -61,7 +62,6 @@
6162
import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean;
6263
import org.springframework.web.accept.ContentNegotiationManager;
6364
import org.springframework.web.bind.support.ConfigurableWebBindingInitializer;
64-
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
6565
import org.springframework.web.filter.HttpPutFormContentFilter;
6666
import org.springframework.web.servlet.HandlerAdapter;
6767
import org.springframework.web.servlet.HandlerExceptionResolver;
@@ -114,8 +114,7 @@ public class WebMvcAutoConfigurationTests {
114114

115115
private static final MockServletWebServerFactory webServerFactory = new MockServletWebServerFactory();
116116

117-
private final ContextLoader<AnnotationConfigWebApplicationContext> contextLoader = ContextLoader
118-
.servletWeb()
117+
private final ServletWebContextLoader contextLoader = ContextLoader.servletWeb()
119118
.autoConfig(WebMvcAutoConfiguration.class,
120119
HttpMessageConvertersAutoConfiguration.class,
121120
PropertyPlaceholderAutoConfiguration.class)
@@ -236,7 +235,6 @@ public void resourceHandlerFixedStrategyEnabled() throws Exception {
236235
assertThat(resolver.getStrategyMap().get("/**/*.js"))
237236
.isInstanceOf(FixedVersionStrategy.class);
238237
});
239-
;
240238
}
241239

242240
@Test
@@ -575,7 +573,7 @@ public void customLogResolvedException() {
575573
public void welcomePageMappingProducesNotFoundResponseWhenThereIsNoWelcomePage() {
576574
this.contextLoader
577575
.env("spring.resources.static-locations:classpath:/no-welcome-page/");
578-
this.contextLoader.load(context -> {
576+
this.contextLoader.loadWeb(context -> {
579577
assertThat(context.getBeansOfType(WelcomePageHandlerMapping.class))
580578
.hasSize(1);
581579
MockMvcBuilders.webAppContextSetup(context).build()
@@ -600,7 +598,7 @@ public void welcomePageRootHandlerIsNotRegisteredWhenStaticPathPatternIsNotSlash
600598
public void welcomePageMappingHandlesRequestsThatAcceptTextHtml() {
601599
this.contextLoader
602600
.env("spring.resources.static-locations:classpath:/welcome-page/");
603-
this.contextLoader.load(context -> {
601+
this.contextLoader.loadWeb(context -> {
604602
assertThat(context.getBeansOfType(WelcomePageHandlerMapping.class))
605603
.hasSize(1);
606604
MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(context).build();
@@ -615,7 +613,7 @@ public void welcomePageMappingHandlesRequestsThatAcceptTextHtml() {
615613
public void welcomePageMappingDoesNotHandleRequestsThatDoNotAcceptTextHtml() {
616614
this.contextLoader
617615
.env("spring.resources.static-locations:classpath:/welcome-page/");
618-
this.contextLoader.load(context -> {
616+
this.contextLoader.loadWeb(context -> {
619617
assertThat(context.getBeansOfType(WelcomePageHandlerMapping.class))
620618
.hasSize(1);
621619
MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(context).build();
@@ -628,7 +626,7 @@ public void welcomePageMappingDoesNotHandleRequestsThatDoNotAcceptTextHtml() {
628626
public void welcomePageMappingHandlesRequestsWithNoAcceptHeader() {
629627
this.contextLoader
630628
.env("spring.resources.static-locations:classpath:/welcome-page/");
631-
this.contextLoader.load(context -> {
629+
this.contextLoader.loadWeb(context -> {
632630
assertThat(context.getBeansOfType(WelcomePageHandlerMapping.class))
633631
.hasSize(1);
634632
MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(context).build();
@@ -642,7 +640,7 @@ public void welcomePageMappingHandlesRequestsWithEmptyAcceptHeader()
642640
throws Exception {
643641
this.contextLoader
644642
.env("spring.resources.static-locations:classpath:/welcome-page/");
645-
this.contextLoader.load(context -> {
643+
this.contextLoader.loadWeb(context -> {
646644
assertThat(context.getBeansOfType(WelcomePageHandlerMapping.class))
647645
.hasSize(1);
648646
MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(context).build();
@@ -656,7 +654,7 @@ public void welcomePageMappingWorksWithNoTrailingSlashOnResourceLocation()
656654
throws Exception {
657655
this.contextLoader
658656
.env("spring.resources.static-locations:classpath:/welcome-page");
659-
this.contextLoader.load(context -> {
657+
this.contextLoader.loadWeb(context -> {
660658
assertThat(context.getBeansOfType(WelcomePageHandlerMapping.class))
661659
.hasSize(1);
662660
MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(context).build();

spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/webservices/WebServicesAutoConfigurationTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222

2323
import org.springframework.beans.factory.BeanCreationException;
2424
import org.springframework.boot.test.context.ContextLoader;
25+
import org.springframework.boot.test.context.ServletWebContextLoader;
2526
import org.springframework.boot.web.servlet.ServletRegistrationBean;
2627
import org.springframework.test.util.ReflectionTestUtils;
27-
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
2828

2929
import static org.assertj.core.api.Assertions.assertThat;
3030

@@ -37,8 +37,8 @@
3737
*/
3838
public class WebServicesAutoConfigurationTests {
3939

40-
private final ContextLoader<AnnotationConfigWebApplicationContext> contextLoader = ContextLoader
41-
.servletWeb().autoConfig(WebServicesAutoConfiguration.class);
40+
private final ServletWebContextLoader contextLoader = ContextLoader.servletWeb()
41+
.autoConfig(WebServicesAutoConfiguration.class);
4242

4343
@Rule
4444
public ExpectedException thrown = ExpectedException.none();

spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jdbc/TestDatabaseAutoConfigurationTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import org.junit.Test;
2222

2323
import org.springframework.boot.test.context.ContextLoader;
24-
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
24+
import org.springframework.boot.test.context.StandardContextLoader;
2525
import org.springframework.context.annotation.Bean;
2626
import org.springframework.context.annotation.Configuration;
2727
import org.springframework.jdbc.core.JdbcTemplate;
@@ -38,8 +38,8 @@
3838
*/
3939
public class TestDatabaseAutoConfigurationTests {
4040

41-
private final ContextLoader<AnnotationConfigApplicationContext> contextLoader = ContextLoader
42-
.standard().autoConfig(TestDatabaseAutoConfiguration.class);
41+
private final StandardContextLoader contextLoader = ContextLoader.standard()
42+
.autoConfig(TestDatabaseAutoConfiguration.class);
4343

4444
@Test
4545
public void replaceWithNoDataSourceAvailable() {

spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/orm/jpa/TestDatabaseAutoConfigurationNoEmbeddedTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
import org.springframework.beans.factory.BeanCreationException;
2525
import org.springframework.boot.test.autoconfigure.jdbc.TestDatabaseAutoConfiguration;
2626
import org.springframework.boot.test.context.ContextLoader;
27+
import org.springframework.boot.test.context.StandardContextLoader;
2728
import org.springframework.boot.testsupport.runner.classpath.ClassPathExclusions;
2829
import org.springframework.boot.testsupport.runner.classpath.ModifiedClassPathRunner;
29-
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
3030
import org.springframework.context.annotation.Bean;
3131
import org.springframework.context.annotation.Configuration;
3232

@@ -44,8 +44,8 @@
4444
@ClassPathExclusions({ "h2-*.jar", "hsqldb-*.jar", "derby-*.jar" })
4545
public class TestDatabaseAutoConfigurationNoEmbeddedTests {
4646

47-
private final ContextLoader<AnnotationConfigApplicationContext> contextLoader = ContextLoader
48-
.standard().config(ExistingDataSourceConfiguration.class)
47+
private final StandardContextLoader contextLoader = ContextLoader.standard()
48+
.config(ExistingDataSourceConfiguration.class)
4949
.autoConfig(TestDatabaseAutoConfiguration.class);
5050

5151
@Test

0 commit comments

Comments
 (0)