@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
/ *
* Copyright 2002 - 2013 the original author or authors .
* Copyright 2002 - 2015 the original author or authors .
*
* Licensed under the Apache License , Version 2 . 0 ( the "License" ) ;
* you may not use this file except in compliance with the License .
@ -201,6 +201,23 @@ public class ExceptionHandlerExceptionResolverTests {
@@ -201,6 +201,23 @@ public class ExceptionHandlerExceptionResolverTests {
assertEquals ( "TestExceptionResolver: IllegalStateException" , this . response . getContentAsString ( ) ) ;
}
// SPR-12605
@Test
public void resolveExceptionWithHandlerMethodArg ( ) throws Exception {
AnnotationConfigApplicationContext cxt = new AnnotationConfigApplicationContext ( MyConfig . class ) ;
this . resolver . setApplicationContext ( cxt ) ;
this . resolver . afterPropertiesSet ( ) ;
ArrayIndexOutOfBoundsException ex = new ArrayIndexOutOfBoundsException ( ) ;
HandlerMethod handlerMethod = new HandlerMethod ( new ResponseBodyController ( ) , "handle" ) ;
ModelAndView mav = this . resolver . resolveException ( this . request , this . response , handlerMethod , ex ) ;
assertNotNull ( "Exception was not handled" , mav ) ;
assertTrue ( mav . isEmpty ( ) ) ;
assertEquals ( "HandlerMethod: handle" , this . response . getContentAsString ( ) ) ;
}
@Test
public void resolveExceptionControllerAdviceHandler ( ) throws Exception {
AnnotationConfigApplicationContext cxt = new AnnotationConfigApplicationContext ( MyControllerAdviceConfig . class ) ;
@ -289,6 +306,12 @@ public class ExceptionHandlerExceptionResolverTests {
@@ -289,6 +306,12 @@ public class ExceptionHandlerExceptionResolverTests {
public String handleException ( IllegalStateException ex ) {
return "TestExceptionResolver: " + ClassUtils . getShortName ( ex . getClass ( ) ) ;
}
@ExceptionHandler ( ArrayIndexOutOfBoundsException . class )
@ResponseBody
public String handleWithHandlerMethod ( HandlerMethod handlerMethod ) {
return "HandlerMethod: " + handlerMethod . getMethod ( ) . getName ( ) ;
}
}
@ControllerAdvice