Skip to content

Commit 35bfa16

Browse files
committed
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
1 parent 219317e commit 35bfa16

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

spring-boot/src/main/java/org/springframework/boot/test/SpringApplicationContextLoader.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import org.springframework.core.env.ConfigurableEnvironment;
4040
import org.springframework.core.env.MapPropertySource;
4141
import org.springframework.core.env.StandardEnvironment;
42+
import org.springframework.core.io.FileSystemResourceLoader;
4243
import org.springframework.mock.web.MockServletContext;
4344
import org.springframework.test.context.ContextConfigurationAttributes;
4445
import org.springframework.test.context.ContextLoader;
@@ -261,7 +262,8 @@ private void addMockServletContext(
261262
List<ApplicationContextInitializer<?>> initializers,
262263
WebMergedContextConfiguration webConfiguration) {
263264
MockServletContext servletContext = new MockServletContext(
264-
webConfiguration.getResourceBasePath());
265+
webConfiguration.getResourceBasePath(),
266+
new FileSystemResourceLoader());
265267
initializers.add(0, new ServletContextApplicationContextInitializer(
266268
servletContext));
267269
}

0 commit comments

Comments
 (0)