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