Polishing

This commit is contained in:
Juergen Hoeller
2014-02-12 18:36:04 +01:00
parent 6f58491b9c
commit 0ec99fdef7
4 changed files with 26 additions and 30 deletions

View File

@@ -45,6 +45,7 @@ public class InvocableHandlerMethodTests {
private NativeWebRequest webRequest;
@Before
public void setUp() throws Exception {
Method method = Handler.class.getDeclaredMethod("handle", Integer.class, String.class);
@@ -52,6 +53,7 @@ public class InvocableHandlerMethodTests {
this.webRequest = new ServletWebRequest(new MockHttpServletRequest(), new MockHttpServletResponse());
}
@Test
public void resolveArg() throws Exception {
StubArgumentResolver intResolver = new StubArgumentResolver(Integer.class, 99);
@@ -63,11 +65,9 @@ public class InvocableHandlerMethodTests {
handlerMethod.setHandlerMethodArgumentResolvers(composite);
Object returnValue = handlerMethod.invokeForRequest(webRequest, null);
assertEquals(1, intResolver.getResolvedParameters().size());
assertEquals(1, stringResolver.getResolvedParameters().size());
assertEquals("99-value", returnValue);
assertEquals("intArg", intResolver.getResolvedParameters().get(0).getParameterName());
assertEquals("stringArg", stringResolver.getResolvedParameters().get(0).getParameterName());
}
@@ -83,7 +83,6 @@ public class InvocableHandlerMethodTests {
handlerMethod.setHandlerMethodArgumentResolvers(composite);
Object returnValue = handlerMethod.invokeForRequest(webRequest, null);
assertEquals(1, intResolver.getResolvedParameters().size());
assertEquals(1, stringResolver.getResolvedParameters().size());
assertEquals("null-null", returnValue);
@@ -119,7 +118,6 @@ public class InvocableHandlerMethodTests {
handlerMethod.setHandlerMethodArgumentResolvers(composite);
Object returnValue = handlerMethod.invokeForRequest(webRequest, null, 2, "value2");
assertEquals("2-value2", returnValue);
}
@@ -134,8 +132,7 @@ public class InvocableHandlerMethodTests {
fail("Expected exception");
}
catch (HttpMessageNotReadableException ex) {
// Expected..
// Allow HandlerMethodArgumentResolver exceptions to propagate..
// expected - allow HandlerMethodArgumentResolver exceptions to propagate
}
}
@@ -208,6 +205,7 @@ public class InvocableHandlerMethodTests {
fail("Expected exception");
}
@SuppressWarnings("unused")
private static class Handler {
@@ -216,6 +214,7 @@ public class InvocableHandlerMethodTests {
}
}
@SuppressWarnings("unused")
private static class ExceptionRaisingHandler {
@@ -228,9 +227,9 @@ public class InvocableHandlerMethodTests {
public void raiseException() throws Throwable {
throw t;
}
}
private static class ExceptionRaisingArgumentResolver implements HandlerMethodArgumentResolver {
@Override