SPR-6093 - MVC Annotation Inheritance

This commit is contained in:
Arjen Poutsma
2009-09-25 08:45:58 +00:00
parent d8245c800b
commit 04fa5d4b99
3 changed files with 57 additions and 40 deletions

View File

@@ -64,7 +64,17 @@ public class AnnotationMethodHandlerExceptionResolverTests {
assertEquals("Invalid view name returned", "BindException", mav.getViewName());
assertEquals("Invalid status code returned", 406, response.getStatus());
}
@Test
public void inherited() {
IOException ex = new IOException();
InheritedController controller = new InheritedController();
ModelAndView mav = exceptionResolver.resolveException(request, response, controller, ex);
assertNotNull("No ModelAndView returned", mav);
assertEquals("Invalid view name returned", "GenericError", mav.getViewName());
assertEquals("Invalid status code returned", 500, response.getStatus());
}
@Test(expected = IllegalStateException.class)
public void ambiguous() {
IllegalArgumentException ex = new IllegalArgumentException();
@@ -86,6 +96,7 @@ public class AnnotationMethodHandlerExceptionResolverTests {
private static class SimpleController {
@ExceptionHandler(IOException.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public String handleIOException(IOException ex, HttpServletRequest request) {
return ClassUtils.getShortName(ex.getClass());
}
@@ -103,6 +114,15 @@ public class AnnotationMethodHandlerExceptionResolverTests {
}
@Controller
private static class InheritedController extends SimpleController
{
@Override
public String handleIOException(IOException ex, HttpServletRequest request) {
return "GenericError";
}
}
@Controller
private static class AmbiguousController {