added test for header sub-elements with a method-invoking inbound-channel-adapter
This commit is contained in:
@@ -11,14 +11,22 @@
|
||||
<queue capacity="1"/>
|
||||
</channel>
|
||||
|
||||
<channel id="queueChannelForHeadersTest">
|
||||
<queue capacity="1"/>
|
||||
</channel>
|
||||
|
||||
<outbound-channel-adapter id="outboundWithImplicitChannel" ref="consumer"/>
|
||||
|
||||
<outbound-channel-adapter id="methodInvokingConsumer" ref="testBean" method="store"/>
|
||||
|
||||
<inbound-channel-adapter id="methodInvokingSource" ref="testBean" method="getMessage" channel="queueChannel" auto-startup="false">
|
||||
<poller max-messages-per-poll="1">
|
||||
<interval-trigger interval="10000"/>
|
||||
</poller>
|
||||
<poller max-messages-per-poll="1" fixed-delay="10000"/>
|
||||
</inbound-channel-adapter>
|
||||
|
||||
<inbound-channel-adapter id="methodInvokingSourceWithHeaders" ref="testBean" method="getMessage" channel="queueChannelForHeadersTest" auto-startup="false">
|
||||
<poller max-messages-per-poll="1" fixed-delay="10000"/>
|
||||
<header name="foo" value="ABC"/>
|
||||
<header name="bar" expression="new Integer(123)"/>
|
||||
</inbound-channel-adapter>
|
||||
|
||||
<beans:bean id="consumer" class="org.springframework.integration.config.TestConsumer"/>
|
||||
|
||||
@@ -78,6 +78,7 @@ public class ChannelAdapterParserTests {
|
||||
message = channel.receive(100);
|
||||
assertNull(message);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void methodInvokingSourceStoppedByApplicationContextInner() {
|
||||
String beanName = "methodInvokingSource";
|
||||
@@ -148,6 +149,25 @@ public class ChannelAdapterParserTests {
|
||||
((SourcePollingChannelAdapter) adapter).stop();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void methodInvokingSourceWithHeaders() {
|
||||
String beanName = "methodInvokingSourceWithHeaders";
|
||||
PollableChannel channel = (PollableChannel) this.applicationContext.getBean("queueChannelForHeadersTest");
|
||||
TestBean testBean = (TestBean) this.applicationContext.getBean("testBean");
|
||||
testBean.store("source test");
|
||||
Object adapter = this.applicationContext.getBean(beanName);
|
||||
assertNotNull(adapter);
|
||||
assertTrue(adapter instanceof SourcePollingChannelAdapter);
|
||||
((SourcePollingChannelAdapter) adapter).start();
|
||||
Message<?> message = channel.receive(100);
|
||||
((SourcePollingChannelAdapter) adapter).stop();
|
||||
assertNotNull(message);
|
||||
assertEquals("source test", testBean.getMessage());
|
||||
assertEquals("source test", message.getPayload());
|
||||
assertEquals("ABC", message.getHeaders().get("foo"));
|
||||
assertEquals(123, message.getHeaders().get("bar"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void methodInvokingSourceNotStarted() {
|
||||
String beanName = "methodInvokingSource";
|
||||
|
||||
Reference in New Issue
Block a user