use of org.springframework.messaging.PollableChannel in project spring-integration by spring-projects.
the class ChannelAdapterParserTests method methodInvokingSourceStopped.
@Test
public void methodInvokingSourceStopped() {
String beanName = "methodInvokingSource";
PollableChannel channel = (PollableChannel) this.applicationContext.getBean("queueChannel");
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(10000);
assertNotNull(message);
assertEquals("source test", testBean.getMessage());
((SourcePollingChannelAdapter) adapter).stop();
message = channel.receive(100);
assertNull(message);
}
use of org.springframework.messaging.PollableChannel in project spring-integration by spring-projects.
the class ChannelAdapterParserTests method testMessageSourceUniqueIds.
@Test
public void testMessageSourceUniqueIds() {
PollableChannel channel1 = this.applicationContext.getBean("channelAdapter1Channel", PollableChannel.class);
PollableChannel channel2 = this.applicationContext.getBean("channelAdapter2Channel", PollableChannel.class);
for (int i = 0; i < 10; i++) {
Message<?> message = channel1.receive(5000);
assertNotNull(message);
assertEquals(i + 1, message.getPayload());
message = channel2.receive(5000);
assertNotNull(message);
assertEquals(i + 1, message.getPayload());
}
}
use of org.springframework.messaging.PollableChannel in project spring-integration by spring-projects.
the class ChannelAdapterParserTests method methodInvokingSourceStoppedByApplicationContextInner.
@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(10000);
assertNotNull(message);
// assertEquals("source test", testBean.getMessage());
this.applicationContextInner.stop();
message = channel.receive(100);
assertNull(message);
}
use of org.springframework.messaging.PollableChannel in project spring-integration by spring-projects.
the class ChannelAdapterParserTests method methodInvokingSourceStartedByApplicationContext.
@Test
public void methodInvokingSourceStartedByApplicationContext() {
String beanName = "methodInvokingSource";
PollableChannel channel = (PollableChannel) this.applicationContext.getBean("queueChannel");
TestBean testBean = (TestBean) this.applicationContext.getBean("testBean");
testBean.store("source test");
Object adapter = this.applicationContext.getBean(beanName);
assertNotNull(adapter);
assertTrue(adapter instanceof SourcePollingChannelAdapter);
this.applicationContext.start();
Message<?> message = channel.receive(1000);
assertNotNull(message);
assertEquals("source test", testBean.getMessage());
this.applicationContext.stop();
}
use of org.springframework.messaging.PollableChannel in project spring-integration by spring-projects.
the class SplitterParserTests method splitterAdapterWithRefOnly.
@Test
public void splitterAdapterWithRefOnly() {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("splitterParserTests.xml", this.getClass());
context.start();
MessageChannel input = (MessageChannel) context.getBean("splitterAdapterWithRefOnlyInput");
PollableChannel output = (PollableChannel) context.getBean("output");
input.send(new GenericMessage<String>("this.is.a.test"));
Message<?> result1 = output.receive(1000);
assertEquals("this", result1.getPayload());
Message<?> result2 = output.receive(1000);
assertEquals("is", result2.getPayload());
Message<?> result3 = output.receive(1000);
assertEquals("a", result3.getPayload());
Message<?> result4 = output.receive(1000);
assertEquals("test", result4.getPayload());
assertNull(output.receive(0));
context.close();
}
Aggregations