|
58 | 58 | import org.springframework.boot.testsupport.rule.OutputCapture;
|
59 | 59 | import org.springframework.boot.web.embedded.netty.NettyReactiveWebServerFactory;
|
60 | 60 | import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
|
| 61 | +import org.springframework.boot.web.reactive.context.AnnotationConfigReactiveWebApplicationContext; |
61 | 62 | import org.springframework.boot.web.reactive.context.AnnotationConfigReactiveWebServerApplicationContext;
|
62 | 63 | import org.springframework.boot.web.reactive.context.ReactiveWebApplicationContext;
|
63 | 64 | import org.springframework.boot.web.reactive.context.StandardReactiveWebEnvironment;
|
|
96 | 97 | import org.springframework.util.StringUtils;
|
97 | 98 | import org.springframework.web.context.ConfigurableWebEnvironment;
|
98 | 99 | import org.springframework.web.context.WebApplicationContext;
|
| 100 | +import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; |
99 | 101 | import org.springframework.web.context.support.StandardServletEnvironment;
|
100 | 102 |
|
101 | 103 | import static org.assertj.core.api.Assertions.assertThat;
|
@@ -316,6 +318,32 @@ public void specificApplicationContextClass() {
|
316 | 318 | assertThat(this.context).isInstanceOf(StaticApplicationContext.class);
|
317 | 319 | }
|
318 | 320 |
|
| 321 | + @Test |
| 322 | + public void specificWebApplicationContextClassDetectWebApplicationType() { |
| 323 | + SpringApplication application = new SpringApplication(ExampleConfig.class); |
| 324 | + application |
| 325 | + .setApplicationContextClass(AnnotationConfigWebApplicationContext.class); |
| 326 | + assertThat(application.getWebApplicationType()) |
| 327 | + .isEqualTo(WebApplicationType.SERVLET); |
| 328 | + } |
| 329 | + |
| 330 | + @Test |
| 331 | + public void specificReactiveApplicationContextClassDetectReactiveApplicationType() { |
| 332 | + SpringApplication application = new SpringApplication(ExampleConfig.class); |
| 333 | + application.setApplicationContextClass( |
| 334 | + AnnotationConfigReactiveWebApplicationContext.class); |
| 335 | + assertThat(application.getWebApplicationType()) |
| 336 | + .isEqualTo(WebApplicationType.REACTIVE); |
| 337 | + } |
| 338 | + |
| 339 | + @Test |
| 340 | + public void nonWebNorReactiveApplicationContextClassDetectNoneApplicationType() { |
| 341 | + SpringApplication application = new SpringApplication(ExampleConfig.class); |
| 342 | + application.setApplicationContextClass(StaticApplicationContext.class); |
| 343 | + assertThat(application.getWebApplicationType()) |
| 344 | + .isEqualTo(WebApplicationType.NONE); |
| 345 | + } |
| 346 | + |
319 | 347 | @Test
|
320 | 348 | public void specificApplicationContextInitializer() {
|
321 | 349 | SpringApplication application = new SpringApplication(ExampleConfig.class);
|
|
0 commit comments