|
|
|
@ -1,5 +1,5 @@ |
|
|
|
/* |
|
|
|
/* |
|
|
|
* Copyright 2002-2014 the original author or authors. |
|
|
|
* Copyright 2002-2016 the original author or authors. |
|
|
|
* |
|
|
|
* |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
@ -29,6 +29,7 @@ import org.springframework.web.bind.support.WebDataBinderFactory; |
|
|
|
import org.springframework.web.context.request.NativeWebRequest; |
|
|
|
import org.springframework.web.context.request.NativeWebRequest; |
|
|
|
import org.springframework.web.context.request.ServletWebRequest; |
|
|
|
import org.springframework.web.context.request.ServletWebRequest; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import static org.hamcrest.Matchers.containsString; |
|
|
|
import static org.junit.Assert.*; |
|
|
|
import static org.junit.Assert.*; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
@ -195,6 +196,28 @@ public class InvocableHandlerMethodTests { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// SPR-13917
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
|
|
|
public void invocationErrorMessage() throws Exception { |
|
|
|
|
|
|
|
HandlerMethodArgumentResolverComposite composite = new HandlerMethodArgumentResolverComposite(); |
|
|
|
|
|
|
|
composite.addResolver(new StubArgumentResolver(double.class, null)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Method method = Handler.class.getDeclaredMethod("handle", double.class); |
|
|
|
|
|
|
|
Object handler = new Handler(); |
|
|
|
|
|
|
|
InvocableHandlerMethod hm = new InvocableHandlerMethod(handler, method); |
|
|
|
|
|
|
|
hm.setHandlerMethodArgumentResolvers(composite); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
hm.invokeForRequest(this.webRequest, new ModelAndViewContainer()); |
|
|
|
|
|
|
|
fail(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
catch (IllegalStateException ex) { |
|
|
|
|
|
|
|
assertThat(ex.getMessage(), containsString("Illegal argument")); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void invokeExceptionRaisingHandler(Throwable expected) throws Exception { |
|
|
|
private void invokeExceptionRaisingHandler(Throwable expected) throws Exception { |
|
|
|
Method method = ExceptionRaisingHandler.class.getDeclaredMethod("raiseException"); |
|
|
|
Method method = ExceptionRaisingHandler.class.getDeclaredMethod("raiseException"); |
|
|
|
Object handler = new ExceptionRaisingHandler(expected); |
|
|
|
Object handler = new ExceptionRaisingHandler(expected); |
|
|
|
@ -209,6 +232,9 @@ public class InvocableHandlerMethodTests { |
|
|
|
public String handle(Integer intArg, String stringArg) { |
|
|
|
public String handle(Integer intArg, String stringArg) { |
|
|
|
return intArg + "-" + stringArg; |
|
|
|
return intArg + "-" + stringArg; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void handle(double amount) { |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|