Use file based loader with MockServletContext

Update SpringApplicationContextLoader so that the MockServletContext
uses FileSystemResourceLoader. This allows `/src/main/webapp` folder
to be found.

See gh-2654
pull/2740/head
Phillip Webb 10 years ago
parent 219317e8c7
commit 35bfa16315

@ -39,6 +39,7 @@ import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.env.MapPropertySource;
import org.springframework.core.env.StandardEnvironment;
import org.springframework.core.io.FileSystemResourceLoader;
import org.springframework.mock.web.MockServletContext;
import org.springframework.test.context.ContextConfigurationAttributes;
import org.springframework.test.context.ContextLoader;
@ -261,7 +262,8 @@ public class SpringApplicationContextLoader extends AbstractContextLoader {
List<ApplicationContextInitializer<?>> initializers,
WebMergedContextConfiguration webConfiguration) {
MockServletContext servletContext = new MockServletContext(
webConfiguration.getResourceBasePath());
webConfiguration.getResourceBasePath(),
new FileSystemResourceLoader());
initializers.add(0, new ServletContextApplicationContextInitializer(
servletContext));
}

Loading…
Cancel
Save