MessageMappingMethodInvoker now uses Assert instead of throwing ConfigurationException if the method does not accept any arguments.

This commit is contained in:
Mark Fisher
2008-09-24 23:37:21 +00:00
parent b0fc5da6a2
commit 2feb20e022
2 changed files with 2 additions and 4 deletions

View File

@@ -104,9 +104,7 @@ public class MessageMappingMethodInvoker implements MethodInvoker, InitializingB
}
if (this.method != null) {
Class<?>[] parameterTypes = this.method.getParameterTypes();
if (parameterTypes.length == 0) {
throw new ConfigurationException("method must accept at least one parameter");
}
Assert.isTrue(parameterTypes.length > 0, "method must accept at least one parameter");
if (parameterTypes.length == 1 && Message.class.isAssignableFrom(parameterTypes[0])) {
this.methodExpectsMessage = true;
}

View File

@@ -44,7 +44,7 @@ public class MethodInvokingConsumerTests {
consumer.onMessage(new GenericMessage<String>("test"));
}
@Test(expected = ConfigurationException.class)
@Test(expected = IllegalArgumentException.class)
public void testInvalidMethodWithNoArgs() {
MethodInvokingConsumer consumer = new MethodInvokingConsumer(new TestSink(), "invalidMethodWithNoArgs");
consumer.afterPropertiesSet();