Using 'spring-integration-core-1.0.xsd' in 'testAnnotatedAggregator.xml' and added tests for wrong parameter counts in AggregatorAdapterTests.
This commit is contained in:
@@ -5,22 +5,23 @@
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
|
||||
http://www.springframework.org/schema/integration
|
||||
http://www.springframework.org/schema/integration/spring-integration-1.0.xsd
|
||||
http://www.springframework.org/schema/integration/spring-integration-core-1.0.xsd
|
||||
http://www.springframework.org/schema/context
|
||||
http://www.springframework.org/schema/context/spring-context-2.5.xsd">
|
||||
|
||||
<message-bus />
|
||||
<annotation-driven />
|
||||
|
||||
<message-bus/>
|
||||
|
||||
<annotation-driven/>
|
||||
|
||||
<channel id="inputChannel"/>
|
||||
|
||||
<channel id="replyChannel"/>
|
||||
|
||||
<channel id="discardChannel"/>
|
||||
|
||||
<context:component-scan base-package="org.springframework.integration.config" use-default-filters="false">
|
||||
<context:include-filter type="regex"
|
||||
expression="org\.springframework\.integration\.config\.TestAnnotatedEndpointWithDefaultAggregator" />
|
||||
<context:include-filter type="regex"
|
||||
expression="org\.springframework\.integration\.config\.TestAnnotatedEndpointWithCustomizedAggregator" />
|
||||
expression="org\.springframework\.integration\.config\.TestAnnotatedEndpoint.*"/>
|
||||
</context:component-scan>
|
||||
|
||||
|
||||
<channel id="inputChannel" />
|
||||
<channel id="replyChannel" />
|
||||
<channel id="discardChannel" />
|
||||
|
||||
</beans:beans>
|
||||
</beans:beans>
|
||||
|
||||
@@ -17,24 +17,24 @@
|
||||
package org.springframework.integration.router;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.integration.MessagingConfigurationException;
|
||||
|
||||
import org.springframework.integration.message.GenericMessage;
|
||||
import org.springframework.integration.message.Message;
|
||||
|
||||
/**
|
||||
* @author Marius Bogoevici
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
public class AggregatorAdapterTests {
|
||||
|
||||
private SimpleAggregator simpleAggregator;
|
||||
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
simpleAggregator = new SimpleAggregator();
|
||||
@@ -87,9 +87,43 @@ public class AggregatorAdapterTests {
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
public void testAdapterWithWrongMethodName() {
|
||||
Aggregator aggregator = new AggregatorAdapter(simpleAggregator, "methodThatDoesNotExist");
|
||||
new AggregatorAdapter(simpleAggregator, "methodThatDoesNotExist");
|
||||
}
|
||||
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
public void testInvalidParameterTypeUsingMethodName() {
|
||||
new AggregatorAdapter(simpleAggregator, "invalidParameterType");
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
public void testTooManyParametersUsingMethodName() {
|
||||
new AggregatorAdapter(simpleAggregator, "tooManyParameters");
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
public void testNotEnoughParametersUsingMethodName() {
|
||||
new AggregatorAdapter(simpleAggregator, "notEnoughParameters");
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
public void testInvalidParameterTypeUsingMethodObject() throws SecurityException, NoSuchMethodException {
|
||||
new AggregatorAdapter(simpleAggregator, simpleAggregator.getClass().getMethod(
|
||||
"invalidParameterType", String.class));
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
public void testTooManyParametersUsingMethodObject() throws SecurityException, NoSuchMethodException {
|
||||
new AggregatorAdapter(simpleAggregator, simpleAggregator.getClass().getMethod(
|
||||
"tooManyParameters", Collection.class, Collection.class));
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
public void testNotEnoughParametersUsingMethodObject() throws SecurityException, NoSuchMethodException {
|
||||
new AggregatorAdapter(simpleAggregator, simpleAggregator.getClass().getMethod(
|
||||
"notEnoughParameters", null));
|
||||
}
|
||||
|
||||
|
||||
private static Collection<Message<?>> createCollectionOfMessages() {
|
||||
Collection<Message<?>> messages = new ArrayList<Message<?>>();
|
||||
messages.add(new GenericMessage<String>("123"));
|
||||
@@ -98,17 +132,22 @@ public class AggregatorAdapterTests {
|
||||
return messages;
|
||||
}
|
||||
|
||||
|
||||
private class SimpleAggregator {
|
||||
|
||||
private volatile boolean aggregationPerformed;
|
||||
|
||||
|
||||
public SimpleAggregator() {
|
||||
aggregationPerformed = false;
|
||||
this.aggregationPerformed = false;
|
||||
}
|
||||
|
||||
public boolean isAggregationPerformed() {
|
||||
return this.aggregationPerformed;
|
||||
}
|
||||
|
||||
public Message<?> doAggregationOnCollectionOfMessages(Collection<Message> messages) {
|
||||
aggregationPerformed = true;
|
||||
this.aggregationPerformed = true;
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
for (Message<?> message : messages) {
|
||||
buffer.append(message.getPayload());
|
||||
@@ -117,16 +156,16 @@ public class AggregatorAdapterTests {
|
||||
}
|
||||
|
||||
public Message<?> doAggregationOnCollectionOfMessagesParametrizedWithWildcard(Collection<Message<?>> messages) {
|
||||
aggregationPerformed = true;
|
||||
this.aggregationPerformed = true;
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
for (Message<?> message : messages) {
|
||||
buffer.append(message.getPayload());
|
||||
}
|
||||
return new GenericMessage<String>(buffer.toString());
|
||||
}
|
||||
|
||||
|
||||
public Message<?> doAggregationOnCollectionOfMessagesParametrizedWithString(Collection<Message<String>> messages) {
|
||||
aggregationPerformed = true;
|
||||
this.aggregationPerformed = true;
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
for (Message<String> message : messages) {
|
||||
buffer.append(message.getPayload());
|
||||
@@ -135,7 +174,7 @@ public class AggregatorAdapterTests {
|
||||
}
|
||||
|
||||
public Message<?> doAggregationOnCollectionOfStrings(Collection<String> messages) {
|
||||
aggregationPerformed = true;
|
||||
this.aggregationPerformed = true;
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
for (String payload : messages) {
|
||||
buffer.append(payload);
|
||||
@@ -144,7 +183,7 @@ public class AggregatorAdapterTests {
|
||||
}
|
||||
|
||||
public Long doAggregationOnCollectionOfStringsReturningLong(Collection<String> messages) {
|
||||
aggregationPerformed = true;
|
||||
this.aggregationPerformed = true;
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
for (String payload : messages) {
|
||||
buffer.append(payload);
|
||||
@@ -152,10 +191,17 @@ public class AggregatorAdapterTests {
|
||||
return Long.parseLong(buffer.toString());
|
||||
}
|
||||
|
||||
public boolean isAggregationPerformed() {
|
||||
return aggregationPerformed;
|
||||
public Message<?> invalidParameterType(String invalid) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Message<?> tooManyParameters(Collection<?> c1, Collection<?> c2) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Message<?> notEnoughParameters() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user