INT-1038, INT-1047 Changed IntegrationNamespaceUtils.parseInnerHandlerDefinition to register and return BeanComponentDefinition, Fixed MethodInvokingOutboundChannelAdapter, added test to ChannelAdapterParserTest
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans:beans xmlns="http://www.springframework.org/schema/integration"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:beans="http://www.springframework.org/schema/beans"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/integration
|
||||
http://www.springframework.org/schema/integration/spring-integration.xsd">
|
||||
|
||||
<channel id="queueChannel">
|
||||
<queue capacity="1"/>
|
||||
</channel>
|
||||
|
||||
<inbound-channel-adapter id="methodInvokingSource" method="getMessage" channel="queueChannel" auto-startup="false">
|
||||
<poller max-messages-per-poll="1">
|
||||
<interval-trigger interval="10000"/>
|
||||
</poller>
|
||||
<beans:bean class="org.springframework.integration.config.ChannelAdapterParserTests$SampleBean"/>
|
||||
</inbound-channel-adapter>
|
||||
|
||||
</beans:beans>
|
||||
@@ -39,16 +39,20 @@ import org.springframework.integration.message.StringMessage;
|
||||
|
||||
/**
|
||||
* @author Mark Fisher
|
||||
* @author Oleg Zhurakousky
|
||||
*/
|
||||
public class ChannelAdapterParserTests {
|
||||
|
||||
private AbstractApplicationContext applicationContext;
|
||||
private AbstractApplicationContext applicationContextInner;
|
||||
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
this.applicationContext = new ClassPathXmlApplicationContext(
|
||||
"ChannelAdapterParserTests-context.xml", this.getClass());
|
||||
this.applicationContextInner = new ClassPathXmlApplicationContext(
|
||||
"ChannelAdapterParserTests-inner-context.xml", this.getClass());
|
||||
}
|
||||
|
||||
@After
|
||||
@@ -74,6 +78,23 @@ public class ChannelAdapterParserTests {
|
||||
message = channel.receive(100);
|
||||
assertNull(message);
|
||||
}
|
||||
@Test
|
||||
public void methodInvokingSourceStoppedByApplicationContextInner() {
|
||||
String beanName = "methodInvokingSource";
|
||||
PollableChannel channel = (PollableChannel) this.applicationContextInner.getBean("queueChannel");
|
||||
// TestBean testBean = (TestBean) this.applicationContextInner.getBean("testBean");
|
||||
// testBean.store("source test");
|
||||
Object adapter = this.applicationContextInner.getBean(beanName);
|
||||
assertNotNull(adapter);
|
||||
assertTrue(adapter instanceof SourcePollingChannelAdapter);
|
||||
this.applicationContextInner.start();
|
||||
Message<?> message = channel.receive(1000);
|
||||
assertNotNull(message);
|
||||
//assertEquals("source test", testBean.getMessage());
|
||||
this.applicationContextInner.stop();
|
||||
message = channel.receive(100);
|
||||
assertNull(message);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void targetOnly() {
|
||||
@@ -180,4 +201,11 @@ public class ChannelAdapterParserTests {
|
||||
channelResolver.resolveChannelName("methodInvokingSource");
|
||||
}
|
||||
|
||||
public static class SampleBean{
|
||||
private String message = "hello";
|
||||
|
||||
String getMessage() {
|
||||
return message;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user