diff --git a/spring-test/src/main/java/org/springframework/test/web/servlet/setup/MockMvcFilterDecorator.java b/spring-test/src/main/java/org/springframework/test/web/servlet/setup/MockMvcFilterDecorator.java index b7120a24d3..baf990ea6e 100644 --- a/spring-test/src/main/java/org/springframework/test/web/servlet/setup/MockMvcFilterDecorator.java +++ b/spring-test/src/main/java/org/springframework/test/web/servlet/setup/MockMvcFilterDecorator.java @@ -47,9 +47,11 @@ import org.springframework.web.util.UrlPathHelper; */ final class MockMvcFilterDecorator implements Filter { - private static final String EXTENSION_MAPPING_PATTERN = "*."; + private static final String ALL_MAPPING_PATTERN = "*"; - private static final String PATH_MAPPING_PATTERN = "/*"; + private static final String EXTENSION_MAPPING_PATTERN = ALL_MAPPING_PATTERN + "."; + + private static final String PATH_MAPPING_PATTERN = "/" + ALL_MAPPING_PATTERN; private final Filter delegate; @@ -103,7 +105,7 @@ final class MockMvcFilterDecorator implements Filter { if (urlPattern.startsWith(EXTENSION_MAPPING_PATTERN)) { this.endsWithMatches.add(urlPattern.substring(1)); } - else if (urlPattern.equals(PATH_MAPPING_PATTERN)) { + else if (urlPattern.equals(PATH_MAPPING_PATTERN) || urlPattern.equals(ALL_MAPPING_PATTERN)) { this.startsWithMatches.add(""); } else if (urlPattern.endsWith(PATH_MAPPING_PATTERN)) { diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/setup/MockMvcFilterDecoratorTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/setup/MockMvcFilterDecoratorTests.java index eb9cea257e..af93e0d738 100644 --- a/spring-test/src/test/java/org/springframework/test/web/servlet/setup/MockMvcFilterDecoratorTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/servlet/setup/MockMvcFilterDecoratorTests.java @@ -95,7 +95,7 @@ public class MockMvcFilterDecoratorTests { @Test public void matchPathMappingAll() throws Exception { - assertFilterInvoked("/test", "/*"); + assertFilterInvoked("/test", "*"); } @Test