Add UriTemplateServletHandlerMethodTests

This commit is contained in:
Rossen Stoyanchev
2011-04-11 17:17:51 +00:00
parent 23e37b6842
commit 767513de4e
3 changed files with 8 additions and 6 deletions

View File

@@ -259,13 +259,16 @@ public final class RequestKey {
}
private String getMatchingPattern(String pattern, String lookupPath, PathMatcher pathMatcher) {
if (pattern.equals(lookupPath) || pathMatcher.match(pattern, lookupPath)) {
if (pattern.equals(lookupPath)) {
return pattern;
}
boolean hasSuffix = pattern.indexOf('.') != -1;
if (!hasSuffix && pathMatcher.match(pattern + ".*", lookupPath)) {
return pattern + ".*";
}
if (pathMatcher.match(pattern, lookupPath)) {
return pattern;
}
boolean endsWithSlash = pattern.endsWith("/");
if (!endsWithSlash && pathMatcher.match(pattern + "/", lookupPath)) {
return pattern +"/";

View File

@@ -163,7 +163,6 @@ public class RequestKeyTests {
expected = new RequestKey(asList("/foo", "/foo*", "/**"), null);
assertEquals("Matched patterns are sorted with best match at the top", expected, match);
}
@Test

View File

@@ -138,10 +138,10 @@ import org.springframework.web.util.NestedServletException;
import static org.junit.Assert.*;
/**
* The origin of this test fixture is {@link ServletHandlerMethodTests}. The tests were adapted to run against
* the HandlerMethod infrastructure rather than against the DefaultAnnotationHandlerMapping, the
* AnnotationMethodHandlerAdapter, and the AnnotationMethodHandlerExceptionResolver.
* Tests that are not supported with HandlerMethod processing have been deleted and are listed at the bottom.
* The origin of this test fixture is {@link ServletHandlerMethodTests} with tests in this class adapted to run
* against the HandlerMethod infrastructure rather than against the DefaultAnnotationHandlerMapping, the
* AnnotationMethodHandlerAdapter, and the AnnotationMethodHandlerExceptionResolver. Tests that are not
* supported are listed at the bottom.
*
* @author Rossen Stoyanchev
* @since 3.1