use of cn.taketoday.framework.web.reactive.context.GenericReactiveWebApplicationContext in project today-framework by TAKETODAY.
the class ApplicationContextLoader method loadContext.
@Override
public ApplicationContext loadContext(MergedContextConfiguration config) throws Exception {
Class<?>[] configClasses = config.getClasses();
String[] configLocations = config.getLocations();
Assert.state(ObjectUtils.isNotEmpty(configClasses) || ObjectUtils.isNotEmpty(configLocations), () -> "No configuration classes or locations found in @SpringApplicationConfiguration. " + "For default configuration detection to work you need Spring 4.0.3 or better (found " + cn.taketoday.lang.Version.get() + ").");
Application 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.setApplicationType(ApplicationType.SERVLET_WEB);
if (!isEmbeddedWebEnvironment(config)) {
new WebConfigurer().configure(config, application, initializers);
}
} else if (config instanceof ReactiveWebMergedContextConfiguration) {
application.setApplicationType(ApplicationType.REACTIVE_WEB);
if (!isEmbeddedWebEnvironment(config)) {
application.setApplicationContextFactory(ApplicationContextFactory.from(GenericReactiveWebApplicationContext::new));
}
} else {
application.setApplicationType(ApplicationType.NONE_WEB);
}
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 = ApplicationTestArgs.get(config.getContextCustomizers());
return application.run(args);
}
use of cn.taketoday.framework.web.reactive.context.GenericReactiveWebApplicationContext in project today-infrastructure by TAKETODAY.
the class ApplicationContextLoader method loadContext.
@Override
public ApplicationContext loadContext(MergedContextConfiguration config) throws Exception {
Class<?>[] configClasses = config.getClasses();
String[] configLocations = config.getLocations();
Assert.state(ObjectUtils.isNotEmpty(configClasses) || ObjectUtils.isNotEmpty(configLocations), () -> "No configuration classes or locations found in @SpringApplicationConfiguration. " + "For default configuration detection to work you need Spring 4.0.3 or better (found " + cn.taketoday.lang.Version.get() + ").");
Application 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.setApplicationType(ApplicationType.SERVLET_WEB);
if (!isEmbeddedWebEnvironment(config)) {
new WebConfigurer().configure(config, application, initializers);
}
} else if (config instanceof ReactiveWebMergedContextConfiguration) {
application.setApplicationType(ApplicationType.REACTIVE_WEB);
if (!isEmbeddedWebEnvironment(config)) {
application.setApplicationContextFactory(ApplicationContextFactory.from(GenericReactiveWebApplicationContext::new));
}
} else {
application.setApplicationType(ApplicationType.NONE_WEB);
}
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 = ApplicationTestArgs.get(config.getContextCustomizers());
return application.run(args);
}
Aggregations