This commit is contained in:
Mark Fisher
2010-03-12 03:16:25 +00:00
parent f2c25c5721
commit 0018abe608
3 changed files with 51 additions and 2 deletions

View File

@@ -66,6 +66,21 @@
</chain>
</chain>
<chain input-channel="payloadTypeRouterInput">
<payload-type-router>
<mapping type="java.lang.String" channel="strings"/>
<mapping type="java.lang.Integer" channel="numbers"/>
</payload-type-router>
</chain>
<channel id="strings">
<queue/>
</channel>
<channel id="numbers">
<queue/>
</channel>
<beans:bean id="aggregatorBean"
class="org.springframework.integration.config.ChainParserTests$StubAggregator" />

View File

@@ -69,6 +69,18 @@ public class ChainParserTests {
@Qualifier("replyOutput")
private PollableChannel replyOutput;
@Autowired
@Qualifier("payloadTypeRouterInput")
private MessageChannel payloadTypeRouterInput;
@Autowired
@Qualifier("strings")
private PollableChannel strings;
@Autowired
@Qualifier("numbers")
private PollableChannel numbers;
@Autowired
@Qualifier("beanInput")
private MessageChannel beanInput;
@@ -145,7 +157,21 @@ public class ChainParserTests {
assertNotNull(reply);
assertEquals("foo", reply.getPayload());
}
@Test
public void chainWithPayloadTypeRouter() throws Exception {
Message<?> message1 = MessageBuilder.withPayload("test").build();
Message<?> message2 = MessageBuilder.withPayload(123).build();
this.payloadTypeRouterInput.send(message1);
this.payloadTypeRouterInput.send(message2);
Message<?> reply1 = this.strings.receive(0);
Message<?> reply2 = this.numbers.receive(0);
assertNotNull(reply1);
assertNotNull(reply2);
assertEquals("test", reply1.getPayload());
assertEquals(123, reply2.getPayload());
}
public static class StubHandler extends AbstractReplyProducingMessageHandler {
@Override