@Test public void defaultErrorViewDifferentHandlerClass() { exceptionResolver.setDefaultErrorView("default-view"); exceptionResolver.setMappedHandlerClasses(new Class[] {String.class}); ModelAndView mav = exceptionResolver.resolveException(request, response, handler2, genericException); assertNull(mav); }
@Test public void simpleExceptionMappingWithHandlerClassSpecifiedButWrongHandler() { Properties props = new Properties(); props.setProperty("Exception", "error"); exceptionResolver.setMappedHandlerClasses(new Class[] {String.class}); exceptionResolver.setExceptionMappings(props); ModelAndView mav = exceptionResolver.resolveException(request, response, handler2, genericException); assertNull(mav); }
@Test public void exactExceptionMappingWithHandlerInterfaceSpecified() { Properties props = new Properties(); props.setProperty("java.lang.Exception", "error"); exceptionResolver.setMappedHandlerClasses(new Class[] {Comparable.class}); exceptionResolver.setExceptionMappings(props); ModelAndView mav = exceptionResolver.resolveException(request, response, handler1, genericException); assertEquals("error", mav.getViewName()); }