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
This commit is contained in:
@@ -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));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user