Browse Source

Add UriTemplateServletHandlerMethodTests

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4213 50f2f4bb-b051-0410-bef5-90022cba6387
pull/1/merge
Rossen Stoyanchev 15 years ago
parent
commit
8246d7023d
  1. 5
      org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestKey.java
  2. 1
      org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestKeyTests.java
  3. 8
      org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletHandlerMethodTests.java

5
org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestKey.java

@ -259,13 +259,16 @@ public final class RequestKey { @@ -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 +"/";

1
org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestKeyTests.java

@ -163,7 +163,6 @@ public class RequestKeyTests { @@ -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

8
org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletHandlerMethodTests.java

@ -138,10 +138,10 @@ import org.springframework.web.util.NestedServletException; @@ -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

Loading…
Cancel
Save