Merge pull request #33 from olegz/INT-2011
fixed MessagingMethodInvokerHelper.HandlerMethod.dummyMessages to be of type Collection<Message<?>> instead of List<Message<?>>
This commit is contained in:
@@ -419,7 +419,7 @@ public class MessagingMethodInvokerHelper<T> extends AbstractExpressionEvaluator
|
||||
private static final TypeDescriptor messageArrayTypeDescriptor = TypeDescriptor.valueOf(Message[].class);
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private static final List<Message<?>> dummyMessages = Collections.emptyList();
|
||||
private static final Collection<Message<?>> dummyMessages = Collections.emptyList();
|
||||
|
||||
|
||||
private final Method method;
|
||||
|
||||
@@ -53,6 +53,7 @@ import org.springframework.integration.test.util.TestUtils;
|
||||
* @author Marius Bogoevici
|
||||
* @author Mark Fisher
|
||||
* @author Iwein Fuld
|
||||
* @author Oleg Zhurakousky
|
||||
*/
|
||||
public class AggregatorParserTests {
|
||||
|
||||
@@ -184,6 +185,31 @@ public class AggregatorParserTests {
|
||||
Assert.assertNotNull(reply);
|
||||
assertEquals(11l, reply.getPayload());
|
||||
}
|
||||
|
||||
@Test // see INT-2011
|
||||
public void testAggregatorWithPojoReleaseStrategyAsCollection() {
|
||||
MessageChannel input = (MessageChannel) context.getBean("aggregatorWithPojoReleaseStrategyInputAsCollection");
|
||||
EventDrivenConsumer endpoint = (EventDrivenConsumer) context.getBean("aggregatorWithPojoReleaseStrategyAsCollection");
|
||||
ReleaseStrategy releaseStrategy = (ReleaseStrategy) new DirectFieldAccessor(new DirectFieldAccessor(endpoint)
|
||||
.getPropertyValue("handler")).getPropertyValue("releaseStrategy");
|
||||
Assert.assertTrue(releaseStrategy instanceof MethodInvokingReleaseStrategy);
|
||||
DirectFieldAccessor releaseStrategyAccessor = new DirectFieldAccessor(new DirectFieldAccessor(new DirectFieldAccessor(releaseStrategy)
|
||||
.getPropertyValue("adapter")).getPropertyValue("delegate"));
|
||||
Map<?, ?> map = (Map<?, ?>) releaseStrategyAccessor.getPropertyValue("handlerMethods");
|
||||
assertEquals("The release strategy is not injected with the appropriate method", 1, map.size());
|
||||
assertTrue("Handler methods do not contain correct method: " + map, map.toString()
|
||||
.contains("checkCompleteness"));
|
||||
input.send(createMessage(1l, "correllationId", 4, 0, null));
|
||||
input.send(createMessage(2l, "correllationId", 4, 1, null));
|
||||
input.send(createMessage(3l, "correllationId", 4, 2, null));
|
||||
PollableChannel outputChannel = (PollableChannel) context.getBean("outputChannel");
|
||||
Message<?> reply = outputChannel.receive(0);
|
||||
Assert.assertNull(reply);
|
||||
input.send(createMessage(5l, "correllationId", 4, 3, null));
|
||||
reply = outputChannel.receive(0);
|
||||
Assert.assertNotNull(reply);
|
||||
assertEquals(11l, reply.getPayload());
|
||||
}
|
||||
|
||||
@Test(expected = BeanCreationException.class)
|
||||
public void testAggregatorWithInvalidReleaseStrategyMethod() {
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package org.springframework.integration.config;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public class MaxValueReleaseStrategy {
|
||||
@@ -26,7 +27,15 @@ public class MaxValueReleaseStrategy {
|
||||
this.maxValue = maxValue;
|
||||
}
|
||||
|
||||
public boolean checkCompleteness(List<Long> numbers) {
|
||||
public boolean checkCompletenessAsList(List<Long> numbers) {
|
||||
int sum = 0;
|
||||
for (long number: numbers) {
|
||||
sum += number;
|
||||
}
|
||||
return sum >= maxValue;
|
||||
}
|
||||
|
||||
public boolean checkCompletenessAsCollection(Collection<Long> numbers) {
|
||||
int sum = 0;
|
||||
for (long number: numbers) {
|
||||
sum += number;
|
||||
|
||||
@@ -52,7 +52,16 @@
|
||||
ref="adderBean"
|
||||
method="add"
|
||||
release-strategy="pojoReleaseStrategy"
|
||||
release-strategy-method="checkCompleteness"/>
|
||||
release-strategy-method="checkCompletenessAsList"/>
|
||||
|
||||
<channel id="aggregatorWithPojoReleaseStrategyInputAsCollection"/>
|
||||
<aggregator id="aggregatorWithPojoReleaseStrategyAsCollection"
|
||||
input-channel="aggregatorWithPojoReleaseStrategyInputAsCollection"
|
||||
output-channel="outputChannel"
|
||||
ref="adderBean"
|
||||
method="add"
|
||||
release-strategy="pojoReleaseStrategy"
|
||||
release-strategy-method="checkCompletenessAsCollection"/>
|
||||
|
||||
<beans:bean id="aggregatorBean"
|
||||
class="org.springframework.integration.config.TestAggregatorBean" />
|
||||
|
||||
Reference in New Issue
Block a user