This commit is contained in:
Rossen Stoyanchev
2018-11-01 14:20:43 -04:00
parent 47aec50917
commit 48654c6483
5 changed files with 132 additions and 142 deletions

View File

@@ -18,7 +18,6 @@ package org.springframework.messaging.handler.invocation;
import java.lang.reflect.Method;
import org.junit.Before;
import org.junit.Test;
import org.springframework.core.MethodParameter;
@@ -27,6 +26,7 @@ import org.springframework.util.ClassUtils;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;
import static org.mockito.Mockito.*;
/**
* Unit tests for {@link InvocableHandlerMethod}.
@@ -35,17 +35,11 @@ import static org.junit.Assert.*;
*/
public class InvocableHandlerMethodTests {
private Message<?> message;
private final Message<?> message = mock(Message.class);
private final HandlerMethodArgumentResolverComposite composite = new HandlerMethodArgumentResolverComposite();
@Before
public void setUp() {
this.message = null;
}
@Test
public void resolveArg() throws Exception {
this.composite.addResolver(new StubArgumentResolver(99));
@@ -61,7 +55,7 @@ public class InvocableHandlerMethodTests {
}
@Test
public void resolveNullArg() throws Exception {
public void resolveNoArgValue() throws Exception {
this.composite.addResolver(new StubArgumentResolver(Integer.class));
this.composite.addResolver(new StubArgumentResolver(String.class));
@@ -135,35 +129,33 @@ public class InvocableHandlerMethodTests {
@Test
public void invocationTargetException() throws Exception {
Throwable expected = new RuntimeException("error");
Throwable expected = null;
try {
expected = new RuntimeException("error");
getInvocable("handleWithException", Throwable.class).invoke(this.message, expected);
fail("Expected exception");
}
catch (RuntimeException actual) {
assertSame(expected, actual);
}
expected = new Error("error");
try {
expected = new Error("error");
getInvocable("handleWithException", Throwable.class).invoke(this.message, expected);
fail("Expected exception");
}
catch (Error actual) {
assertSame(expected, actual);
}
expected = new Exception("error");
try {
expected = new Exception("error");
getInvocable("handleWithException", Throwable.class).invoke(this.message, expected);
fail("Expected exception");
}
catch (Exception actual) {
assertSame(expected, actual);
}
expected = new Throwable("error");
try {
expected = new Throwable("error");
getInvocable("handleWithException", Throwable.class).invoke(this.message, expected);
fail("Expected exception");
}