From 2ce03bc07b59984db172845eaaaa46a6ef589ca4 Mon Sep 17 00:00:00 2001 From: Mark Fisher Date: Fri, 28 Dec 2007 19:18:47 +0000 Subject: [PATCH] Added more tests for invalid methods. --- .../adapter/MethodInvokingSourceTests.java | 37 +++++++++++++++---- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/spring-integration-core/src/test/java/org/springframework/integration/adapter/MethodInvokingSourceTests.java b/spring-integration-core/src/test/java/org/springframework/integration/adapter/MethodInvokingSourceTests.java index c4f1c54306..9b8f97d4a1 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/adapter/MethodInvokingSourceTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/adapter/MethodInvokingSourceTests.java @@ -31,28 +31,51 @@ import org.springframework.integration.MessageDeliveryException; public class MethodInvokingSourceTests { @Test - public void testSingleObjectResult() { + public void testValidMethod() { MethodInvokingSource source = new MethodInvokingSource(); source.setObject(new TestBean()); - source.setMethod("foo"); + source.setMethod("validMethod"); Collection result = source.poll(5); assertNotNull(result); - assertEquals("bar", result.iterator().next()); + assertEquals("valid", result.iterator().next()); } @Test(expected=MessageDeliveryException.class) - public void testInvalidMethod() { + public void testNoMatchingMethodName() { MethodInvokingSource source = new MethodInvokingSource(); source.setObject(new TestBean()); - source.setMethod("boo"); + source.setMethod("noMatchingMethod"); + source.poll(5); + } + + @Test(expected=MessageDeliveryException.class) + public void testInvalidMethodWithArg() { + MethodInvokingSource source = new MethodInvokingSource(); + source.setObject(new TestBean()); + source.setMethod("invalidMethodWithArg"); + source.poll(5); + } + + @Test(expected=MessageDeliveryException.class) + public void testInvalidMethodWithNoReturnValue() { + MethodInvokingSource source = new MethodInvokingSource(); + source.setObject(new TestBean()); + source.setMethod("invalidMethodWithNoReturnValue"); source.poll(5); } private static class TestBean { - public String foo() { - return "bar"; + public String validMethod() { + return "valid"; + } + + public String invalidMethodWithArg(String arg) { + return "invalid"; + } + + public void invalidMethodWithNoReturnValue() { } }