SPR-6502 - Broken @RequestMapping inheritance

This commit is contained in:
Arjen Poutsma
2009-12-07 16:44:51 +00:00
parent 09a55c8ede
commit 27e0642543
3 changed files with 67 additions and 6 deletions

View File

@@ -1257,6 +1257,28 @@ public class ServletAnnotationControllerTests {
assertEquals("create", response.getContentAsString());
}
@Test
public void requestMappingInterface() throws Exception {
initServlet(IMyControllerImpl.class);
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/handle");
MockHttpServletResponse response = new MockHttpServletResponse();
servlet.service(request, response);
assertEquals("handle", response.getContentAsString());
}
@Test
public void requestMappingBaseClass() throws Exception {
initServlet(MyAbstractControllerImpl.class);
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/handle");
MockHttpServletResponse response = new MockHttpServletResponse();
servlet.service(request, response);
assertEquals("handle", response.getContentAsString());
}
/*
* Controllers
*/
@@ -2140,5 +2162,34 @@ public class ServletAnnotationControllerTests {
}
public interface IMyController {
@RequestMapping("/handle")
void handle(Writer writer) throws IOException;
}
@Controller
public static class IMyControllerImpl implements IMyController {
public void handle(Writer writer) throws IOException {
writer.write("handle");
}
}
public static abstract class MyAbstractController {
@RequestMapping("/handle")
public abstract void handle(Writer writer) throws IOException;
}
@Controller
public static class MyAbstractControllerImpl extends MyAbstractController {
@Override
public void handle(Writer writer) throws IOException {
writer.write("handle");
}
}
}