From 767513de4e2c11c676c4edb217fe1e4b680fd1c5 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Mon, 11 Apr 2011 17:17:51 +0000 Subject: [PATCH] Add UriTemplateServletHandlerMethodTests --- .../web/servlet/mvc/method/annotation/RequestKey.java | 5 ++++- .../servlet/mvc/method/annotation/RequestKeyTests.java | 1 - .../mvc/method/annotation/ServletHandlerMethodTests.java | 8 ++++---- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestKey.java b/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestKey.java index 50348e785a..e4918d748d 100644 --- a/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestKey.java +++ b/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestKey.java @@ -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 +"/"; diff --git a/org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestKeyTests.java b/org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestKeyTests.java index d66c7f695c..946ba9f7c2 100644 --- a/org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestKeyTests.java +++ b/org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestKeyTests.java @@ -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 diff --git a/org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletHandlerMethodTests.java b/org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletHandlerMethodTests.java index 7b66144094..05df5acf92 100644 --- a/org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletHandlerMethodTests.java +++ b/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; 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