SPR-6876 - RequestMethod does not appear to factor into @RequestMapping uniqueness in some cases

This commit is contained in:
Arjen Poutsma
2010-03-02 09:52:43 +00:00
parent 20a8039642
commit 5675046cb7
2 changed files with 51 additions and 3 deletions

View File

@@ -321,6 +321,25 @@ public class UriTemplateServletAnnotationControllerTests {
assertEquals("M5", response.getContentAsString());
}
/*
* See SPR-6876
*/
@Test
public void variableNames() throws Exception {
initServlet(VariableNamesController.class);
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/test/foo");
MockHttpServletResponse response = new MockHttpServletResponse();
servlet.service(request, response);
assertEquals("foo-foo", response.getContentAsString());
request = new MockHttpServletRequest("DELETE", "/test/bar");
response = new MockHttpServletResponse();
servlet.service(request, response);
assertEquals("bar-bar", response.getContentAsString());
}
/*
* Controllers
@@ -555,5 +574,21 @@ public class UriTemplateServletAnnotationControllerTests {
}
}
@Controller
@RequestMapping("/test")
public static class VariableNamesController {
@RequestMapping(value = "/{foo}", method=RequestMethod.GET)
public void foo(@PathVariable String foo, Writer writer) throws IOException {
writer.write("foo-" + foo);
}
@RequestMapping(value = "/{bar}", method=RequestMethod.DELETE)
public void bar(@PathVariable String bar, Writer writer) throws IOException {
writer.write("bar-" + bar);
}
}
}