This commit is contained in:
Rossen Stoyanchev
2011-04-20 08:43:57 +00:00
parent 9c65973b33
commit 57d327d1ff
4 changed files with 33 additions and 9 deletions

View File

@@ -77,9 +77,13 @@ public class RequestKeyTests {
key1 = createKeyFromPatterns();
key2 = createKeyFromPatterns();
key3 = createKeyFromPatterns("/");
key3 = createKeyFromPatterns("");
assertEquals(key3.getPatterns(), key1.combine(key2, pathMatcher).getPatterns());
key1 = createKeyFromPatterns("/t1");
key2 = createKeyFromPatterns("");
key3 = createKeyFromPatterns("/t1");
assertEquals(key3.getPatterns(), key1.combine(key2, pathMatcher).getPatterns());
}
@Test

View File

@@ -60,12 +60,15 @@ public class RequestMappingHandlerMethodMappingTests {
private HandlerMethod barMethod;
private HandlerMethod emptyMethod;
@Before
public void setUp() throws Exception {
handler = new Handler();
fooMethod = new HandlerMethod(handler, "foo");
fooParamMethod = new HandlerMethod(handler, "fooParam");
barMethod = new HandlerMethod(handler, "bar");
emptyMethod = new HandlerMethod(handler, "empty");
StaticApplicationContext context = new StaticApplicationContext();
context.registerSingleton("handler", handler.getClass());
@@ -88,6 +91,17 @@ public class RequestMappingHandlerMethodMappingTests {
assertEquals(barMethod.getMethod(), hm.getMethod());
}
@Test
public void emptyPathMatch() throws Exception {
MockHttpServletRequest request = new MockHttpServletRequest("GET", "");
HandlerMethod hm = (HandlerMethod) mapping.getHandler(request).getHandler();
assertEquals(emptyMethod.getMethod(), hm.getMethod());
request = new MockHttpServletRequest("GET", "/");
hm = (HandlerMethod) mapping.getHandler(request).getHandler();
assertEquals(emptyMethod.getMethod(), hm.getMethod());
}
// TODO: SPR-8247
@Ignore
@Test
@@ -144,6 +158,7 @@ public class RequestMappingHandlerMethodMappingTests {
@SuppressWarnings("unused")
@Controller
@RequestMapping
private static class Handler {
@RequestMapping(value = "/foo", method = RequestMethod.GET)
@@ -157,6 +172,10 @@ public class RequestMappingHandlerMethodMappingTests {
@RequestMapping(value = "/ba*", method = { RequestMethod.GET, RequestMethod.HEAD })
public void bar() {
}
@RequestMapping(value = "")
public void empty() {
}
}
}