use of cn.taketoday.framework.test.context.ApplicationTest.WebEnvironment in project today-infrastructure by TAKETODAY.
the class ApplicationTestContextBootstrapper method processMergedContextConfiguration.
@Override
protected MergedContextConfiguration processMergedContextConfiguration(MergedContextConfiguration mergedConfig) {
Class<?>[] classes = getOrFindConfigurationClasses(mergedConfig);
List<String> propertySourceProperties = getAndProcessPropertySourceProperties(mergedConfig);
mergedConfig = createModifiedConfig(mergedConfig, classes, StringUtils.toStringArray(propertySourceProperties));
WebEnvironment webEnvironment = getWebEnvironment(mergedConfig.getTestClass());
if (webEnvironment != null && isWebEnvironmentSupported(mergedConfig)) {
ApplicationType webApplicationType = getApplicationType(mergedConfig);
if (webApplicationType == ApplicationType.SERVLET_WEB && (webEnvironment.isEmbedded() || webEnvironment == WebEnvironment.MOCK)) {
mergedConfig = new WebMergedContextConfiguration(mergedConfig, determineResourceBasePath(mergedConfig));
} else if (webApplicationType == ApplicationType.REACTIVE_WEB && (webEnvironment.isEmbedded() || webEnvironment == WebEnvironment.MOCK)) {
return new ReactiveWebMergedContextConfiguration(mergedConfig);
}
}
return mergedConfig;
}
use of cn.taketoday.framework.test.context.ApplicationTest.WebEnvironment in project today-infrastructure by TAKETODAY.
the class ApplicationTestContextBootstrapper method buildTestContext.
@Override
public TestContext buildTestContext() {
TestContext context = super.buildTestContext();
verifyConfiguration(context.getTestClass());
WebEnvironment webEnvironment = getWebEnvironment(context.getTestClass());
if (webEnvironment == WebEnvironment.MOCK && deduceWebApplicationType() == ApplicationType.SERVLET_WEB) {
context.setAttribute(ACTIVATE_SERVLET_LISTENER, true);
} else if (webEnvironment != null && webEnvironment.isEmbedded()) {
context.setAttribute(ACTIVATE_SERVLET_LISTENER, false);
}
return context;
}
use of cn.taketoday.framework.test.context.ApplicationTest.WebEnvironment in project today-framework by TAKETODAY.
the class ApplicationTestContextBootstrapper method buildTestContext.
@Override
public TestContext buildTestContext() {
TestContext context = super.buildTestContext();
verifyConfiguration(context.getTestClass());
WebEnvironment webEnvironment = getWebEnvironment(context.getTestClass());
if (webEnvironment == WebEnvironment.MOCK && deduceWebApplicationType() == ApplicationType.SERVLET_WEB) {
context.setAttribute(ACTIVATE_SERVLET_LISTENER, true);
} else if (webEnvironment != null && webEnvironment.isEmbedded()) {
context.setAttribute(ACTIVATE_SERVLET_LISTENER, false);
}
return context;
}
use of cn.taketoday.framework.test.context.ApplicationTest.WebEnvironment in project today-framework by TAKETODAY.
the class ApplicationTestContextBootstrapper method processMergedContextConfiguration.
@Override
protected MergedContextConfiguration processMergedContextConfiguration(MergedContextConfiguration mergedConfig) {
Class<?>[] classes = getOrFindConfigurationClasses(mergedConfig);
List<String> propertySourceProperties = getAndProcessPropertySourceProperties(mergedConfig);
mergedConfig = createModifiedConfig(mergedConfig, classes, StringUtils.toStringArray(propertySourceProperties));
WebEnvironment webEnvironment = getWebEnvironment(mergedConfig.getTestClass());
if (webEnvironment != null && isWebEnvironmentSupported(mergedConfig)) {
ApplicationType webApplicationType = getApplicationType(mergedConfig);
if (webApplicationType == ApplicationType.SERVLET_WEB && (webEnvironment.isEmbedded() || webEnvironment == WebEnvironment.MOCK)) {
mergedConfig = new WebMergedContextConfiguration(mergedConfig, determineResourceBasePath(mergedConfig));
} else if (webApplicationType == ApplicationType.REACTIVE_WEB && (webEnvironment.isEmbedded() || webEnvironment == WebEnvironment.MOCK)) {
return new ReactiveWebMergedContextConfiguration(mergedConfig);
}
}
return mergedConfig;
}
Aggregations