use of org.springframework.messaging.PollableChannel in project spring-integration by spring-projects.
the class HeaderEnricherTests method errorChannel.
@Test
public void errorChannel() {
PollableChannel errorChannel = context.getBean("testErrorChannel", PollableChannel.class);
MessageChannel inputChannel = context.getBean("errorChannelInput", MessageChannel.class);
inputChannel.send(new GenericMessage<String>("test"));
Message<?> errorMessage = errorChannel.receive(1000);
assertNotNull(errorMessage);
Object errorPayload = errorMessage.getPayload();
assertEquals(MessageTransformationException.class, errorPayload.getClass());
Message<?> failedMessage = ((MessageTransformationException) errorPayload).getFailedMessage();
assertEquals("test", failedMessage.getPayload());
assertEquals(errorChannel, failedMessage.getHeaders().getErrorChannel());
}
use of org.springframework.messaging.PollableChannel in project spring-integration by spring-projects.
the class MessagingAnnotationPostProcessorTests method serviceActivatorInApplicationContext.
@Test
public void serviceActivatorInApplicationContext() throws Exception {
AbstractApplicationContext context = new ClassPathXmlApplicationContext("serviceActivatorAnnotationPostProcessorTests.xml", this.getClass());
MessageChannel inputChannel = (MessageChannel) context.getBean("inputChannel");
PollableChannel outputChannel = (PollableChannel) context.getBean("outputChannel");
inputChannel.send(new GenericMessage<String>("world"));
Message<?> reply = outputChannel.receive(0);
assertEquals("hello world", reply.getPayload());
context.close();
}
use of org.springframework.messaging.PollableChannel in project spring-integration by spring-projects.
the class InnerDefinitionHandlerAwareEndpointParserTests method testAggregatorDefinitionSuccess.
private void testAggregatorDefinitionSuccess(String configProperty) {
ApplicationContext ac = this.bootStrap(configProperty);
MessageChannel inChannel = (MessageChannel) ac.getBean("inChannel");
for (int i = 0; i < 5; i++) {
Map<String, Object> headers = stubHeaders(i, 5, 1);
Message<Integer> message = MessageBuilder.withPayload(i).copyHeaders(headers).build();
inChannel.send(message);
}
PollableChannel output = (PollableChannel) ac.getBean("outChannel");
Message<?> receivedMessage = output.receive(10000);
assertNotNull(receivedMessage);
assertEquals(0 + 1 + 2 + 3 + 4, receivedMessage.getPayload());
}
use of org.springframework.messaging.PollableChannel in project spring-integration by spring-projects.
the class InnerDefinitionHandlerAwareEndpointParserTests method testSplitterDefinitionSuccess.
private void testSplitterDefinitionSuccess(String configProperty) {
ApplicationContext ac = this.bootStrap(configProperty);
EventDrivenConsumer splitter = (EventDrivenConsumer) ac.getBean("testSplitter");
Assert.assertNotNull(splitter);
MessageBuilder<String[]> inChannelMessageBuilder = MessageBuilder.withPayload(new String[] { "One", "Two" });
Message<String[]> inMessage = inChannelMessageBuilder.build();
MessageChannel inChannel = (MessageChannel) ac.getBean("inChannel");
inChannel.send(inMessage);
PollableChannel outChannel = (PollableChannel) ac.getBean("outChannel");
Assert.assertTrue(outChannel.receive().getPayload() instanceof String);
outChannel = (PollableChannel) ac.getBean("outChannel");
Assert.assertTrue(outChannel.receive().getPayload() instanceof String);
}
use of org.springframework.messaging.PollableChannel in project spring-integration by spring-projects.
the class InnerDefinitionHandlerAwareEndpointParserTests method testRouterDefinitionSuccess.
private void testRouterDefinitionSuccess(String configProperty) {
ApplicationContext ac = this.bootStrap(configProperty);
EventDrivenConsumer splitter = (EventDrivenConsumer) ac.getBean("testRouter");
Assert.assertNotNull(splitter);
MessageBuilder<String> inChannelMessageBuilder = MessageBuilder.withPayload("1");
Message<String> inMessage = inChannelMessageBuilder.build();
DirectChannel inChannel = (DirectChannel) ac.getBean("inChannel");
inChannel.send(inMessage);
PollableChannel channel1 = (PollableChannel) ac.getBean("channel1");
Assert.assertTrue(channel1.receive().getPayload().equals("1"));
inChannelMessageBuilder = MessageBuilder.withPayload("2");
inMessage = inChannelMessageBuilder.build();
inChannel.send(inMessage);
PollableChannel channel2 = (PollableChannel) ac.getBean("channel2");
Assert.assertTrue(channel2.receive().getPayload().equals("2"));
}
Aggregations