use of org.springframework.boot.web.reactive.context.GenericReactiveWebApplicationContext in project spring-boot by spring-projects.
the class SpringBootContextLoader method loadContext.
@Override
public ApplicationContext loadContext(MergedContextConfiguration config) throws Exception {
Class<?>[] configClasses = config.getClasses();
String[] configLocations = config.getLocations();
Assert.state(!ObjectUtils.isEmpty(configClasses) || !ObjectUtils.isEmpty(configLocations), () -> "No configuration classes or locations found in @SpringApplicationConfiguration. " + "For default configuration detection to work you need Spring 4.0.3 or better (found " + SpringVersion.getVersion() + ").");
SpringApplication application = getSpringApplication();
application.setMainApplicationClass(config.getTestClass());
application.addPrimarySources(Arrays.asList(configClasses));
application.getSources().addAll(Arrays.asList(configLocations));
List<ApplicationContextInitializer<?>> initializers = getInitializers(config, application);
if (config instanceof WebMergedContextConfiguration) {
application.setWebApplicationType(WebApplicationType.SERVLET);
if (!isEmbeddedWebEnvironment(config)) {
new WebConfigurer().configure(config, application, initializers);
}
} else if (config instanceof ReactiveWebMergedContextConfiguration) {
application.setWebApplicationType(WebApplicationType.REACTIVE);
if (!isEmbeddedWebEnvironment(config)) {
application.setApplicationContextFactory(ApplicationContextFactory.of(GenericReactiveWebApplicationContext::new));
}
} else {
application.setWebApplicationType(WebApplicationType.NONE);
}
application.setInitializers(initializers);
ConfigurableEnvironment environment = getEnvironment();
if (environment != null) {
prepareEnvironment(config, application, environment, false);
application.setEnvironment(environment);
} else {
application.addListeners(new PrepareEnvironmentListener(config));
}
String[] args = SpringBootTestArgs.get(config.getContextCustomizers());
return application.run(args);
}
use of org.springframework.boot.web.reactive.context.GenericReactiveWebApplicationContext in project spring-boot by spring-projects.
the class ConditionalOnNotWebApplicationTests method testNotWebApplicationWithReactiveContext.
@Test
public void testNotWebApplicationWithReactiveContext() {
GenericReactiveWebApplicationContext ctx = new GenericReactiveWebApplicationContext();
ctx.register(ReactiveApplicationConfig.class, NotWebApplicationConfiguration.class);
ctx.refresh();
this.context = ctx;
assertThat(this.context.getBeansOfType(String.class)).isEmpty();
}
use of org.springframework.boot.web.reactive.context.GenericReactiveWebApplicationContext in project spring-boot by spring-projects.
the class HttpHandlerAutoConfigurationTests method load.
private void load(Class<?> config, String... environment) {
this.context = new GenericReactiveWebApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context, environment);
if (this.context != null) {
this.context.register(config);
}
this.context.register(HttpHandlerAutoConfiguration.class);
this.context.refresh();
}
use of org.springframework.boot.web.reactive.context.GenericReactiveWebApplicationContext in project spring-boot by spring-projects.
the class WebFluxAnnotationAutoConfigurationTests method load.
private void load(Class<?> config, String... environment) {
this.context = new GenericReactiveWebApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context, environment);
if (config != null) {
this.context.register(config);
}
this.context.register(BaseConfiguration.class);
this.context.refresh();
}
Aggregations