use of org.springframework.messaging.PollableChannel in project spring-integration by spring-projects.
the class AggregatorParserTests method testSimpleJavaBeanAggregator.
@Test
public void testSimpleJavaBeanAggregator() {
List<Message<?>> outboundMessages = new ArrayList<Message<?>>();
MessageChannel input = (MessageChannel) context.getBean("aggregatorWithReferenceAndMethodInput");
outboundMessages.add(createMessage(1L, "id1", 3, 1, null));
outboundMessages.add(createMessage(2L, "id1", 3, 3, null));
outboundMessages.add(createMessage(3L, "id1", 3, 2, null));
outboundMessages.forEach(input::send);
PollableChannel outputChannel = (PollableChannel) context.getBean("outputChannel");
Message<?> response = outputChannel.receive(10);
Assert.assertEquals(6L, response.getPayload());
Object mbf = context.getBean(IntegrationUtils.INTEGRATION_MESSAGE_BUILDER_FACTORY_BEAN_NAME);
Object handler = context.getBean("aggregatorWithReferenceAndMethod.handler");
assertSame(mbf, TestUtils.getPropertyValue(handler, "outputProcessor.messageBuilderFactory"));
}
use of org.springframework.messaging.PollableChannel in project spring-integration by spring-projects.
the class ChannelParserTests method testChannelInteceptorInnerBean.
@Test
public void testChannelInteceptorInnerBean() {
ConfigurableApplicationContext context = new ClassPathXmlApplicationContext("channelInterceptorParserTests.xml", getClass());
PollableChannel channel = (PollableChannel) context.getBean("channelWithInterceptorInnerBean");
channel.send(new GenericMessage<String>("test"));
Message<?> transformed = channel.receive(1000);
assertEquals("TEST", transformed.getPayload());
context.close();
}
use of org.springframework.messaging.PollableChannel in project spring-integration by spring-projects.
the class ChannelParserTests method testPriorityChannelWithIntegerDatatypeEnforced.
@Test
public void testPriorityChannelWithIntegerDatatypeEnforced() {
PollableChannel channel = this.context.getBean("integerOnlyPriorityChannel", PollableChannel.class);
channel.send(new GenericMessage<>(3));
channel.send(new GenericMessage<>(2));
channel.send(new GenericMessage<>(1));
assertEquals(1, channel.receive(0).getPayload());
assertEquals(2, channel.receive(0).getPayload());
assertEquals(3, channel.receive(0).getPayload());
boolean threwException = false;
try {
channel.send(new GenericMessage<>("wrong type"));
} catch (MessageDeliveryException e) {
assertEquals("wrong type", e.getFailedMessage().getPayload());
threwException = true;
}
assertTrue(threwException);
}
use of org.springframework.messaging.PollableChannel in project spring-integration by spring-projects.
the class ChannelParserTests method testPriorityChannelWithDefaultComparator.
@Test
public void testPriorityChannelWithDefaultComparator() {
PollableChannel channel = this.context.getBean("priorityChannelWithDefaultComparator", PollableChannel.class);
Message<String> lowPriorityMessage = MessageBuilder.withPayload("low").setPriority(-14).build();
Message<String> midPriorityMessage = MessageBuilder.withPayload("mid").setPriority(0).build();
Message<String> highPriorityMessage = MessageBuilder.withPayload("high").setPriority(99).build();
channel.send(lowPriorityMessage);
channel.send(highPriorityMessage);
channel.send(midPriorityMessage);
Message<?> reply1 = channel.receive(0);
Message<?> reply2 = channel.receive(0);
Message<?> reply3 = channel.receive(0);
assertEquals("high", reply1.getPayload());
assertEquals("mid", reply2.getPayload());
assertEquals("low", reply3.getPayload());
}
use of org.springframework.messaging.PollableChannel in project spring-integration by spring-projects.
the class ChannelAdapterParserTests method methodInvokingSourceNotStarted.
@Test
public void methodInvokingSourceNotStarted() {
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);
Message<?> message = channel.receive(100);
assertNull(message);
}
Aggregations