|
|
@ -77,7 +77,7 @@ public class SpringApplicationContextLoader extends AbstractContextLoader {
|
|
|
|
List<ApplicationContextInitializer<?>> initializers = getInitializers(
|
|
|
|
List<ApplicationContextInitializer<?>> initializers = getInitializers(
|
|
|
|
mergedConfig, application);
|
|
|
|
mergedConfig, application);
|
|
|
|
if (mergedConfig instanceof WebMergedContextConfiguration) {
|
|
|
|
if (mergedConfig instanceof WebMergedContextConfiguration) {
|
|
|
|
new WebConfigurer().setup(mergedConfig, application, initializers);
|
|
|
|
new WebConfigurer().configure(mergedConfig, application, initializers);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
application.setWebEnvironment(false);
|
|
|
|
application.setWebEnvironment(false);
|
|
|
@ -168,20 +168,22 @@ public class SpringApplicationContextLoader extends AbstractContextLoader {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private static class WebConfigurer {
|
|
|
|
private static class WebConfigurer {
|
|
|
|
void setup(MergedContextConfiguration mergedConfig,
|
|
|
|
|
|
|
|
|
|
|
|
void configure(MergedContextConfiguration configuration,
|
|
|
|
SpringApplication application,
|
|
|
|
SpringApplication application,
|
|
|
|
List<ApplicationContextInitializer<?>> initializers) {
|
|
|
|
List<ApplicationContextInitializer<?>> initializers) {
|
|
|
|
WebMergedContextConfiguration webConfig = (WebMergedContextConfiguration) mergedConfig;
|
|
|
|
WebMergedContextConfiguration webConfiguration = (WebMergedContextConfiguration) configuration;
|
|
|
|
if (AnnotationUtils.findAnnotation(webConfig.getTestClass(),
|
|
|
|
if (AnnotationUtils.findAnnotation(webConfiguration.getTestClass(),
|
|
|
|
IntegrationTest.class) == null) {
|
|
|
|
IntegrationTest.class) == null) {
|
|
|
|
MockServletContext servletContext = new MockServletContext(
|
|
|
|
MockServletContext servletContext = new MockServletContext(
|
|
|
|
webConfig.getResourceBasePath());
|
|
|
|
webConfiguration.getResourceBasePath());
|
|
|
|
initializers.add(0, new ServletContextApplicationContextInitializer(
|
|
|
|
initializers.add(0, new ServletContextApplicationContextInitializer(
|
|
|
|
servletContext));
|
|
|
|
servletContext));
|
|
|
|
application
|
|
|
|
application
|
|
|
|
.setApplicationContextClass(GenericWebApplicationContext.class);
|
|
|
|
.setApplicationContextClass(GenericWebApplicationContext.class);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|