use of org.springframework.integration.channel.QueueChannel in project spring-integration by spring-projects.
the class FlowServiceTests method testGatewayExplicitReplyChannel.
@Test
public void testGatewayExplicitReplyChannel() {
QueueChannel replyChannel = new QueueChannel();
this.testGatewayInput.send(MessageBuilder.withPayload("foo").setReplyChannel(replyChannel).build());
Message<?> message = replyChannel.receive(10000);
assertNotNull(message);
assertEquals("FOO", message.getPayload());
}
use of org.springframework.integration.channel.QueueChannel in project spring-integration by spring-projects.
the class FilterAnnotationMethodResolutionTests method resolveAnnotatedMethod.
@Test
public void resolveAnnotatedMethod() throws Exception {
TestUtils.TestApplicationContext testApplicationContext = TestUtils.createTestApplicationContext();
testApplicationContext.refresh();
FilterFactoryBean factoryBean = new FilterFactoryBean();
factoryBean.setBeanFactory(testApplicationContext);
AnnotatedTestFilter filter = new AnnotatedTestFilter();
factoryBean.setTargetObject(filter);
MessageHandler handler = factoryBean.getObject();
QueueChannel replyChannel = new QueueChannel();
handler.handleMessage(MessageBuilder.withPayload("test").setReplyChannel(replyChannel).build());
Message<?> result = replyChannel.receive(0);
assertNotNull(result);
assertTrue(filter.invokedCorrectMethod);
assertFalse(filter.invokedIncorrectMethod);
testApplicationContext.close();
}
use of org.springframework.integration.channel.QueueChannel in project spring-integration by spring-projects.
the class MessageFilterTests method filterThrowsException.
@Test(expected = MessageRejectedException.class)
public void filterThrowsException() {
MessageFilter filter = new MessageFilter(message -> false);
filter.setThrowExceptionOnRejection(true);
QueueChannel output = new QueueChannel();
filter.setOutputChannel(output);
filter.handleMessage(new GenericMessage<String>("test"));
}
use of org.springframework.integration.channel.QueueChannel in project spring-integration by spring-projects.
the class MessageFilterTests method filterAcceptsWithChannels.
@Test
public void filterAcceptsWithChannels() {
DirectChannel inputChannel = new DirectChannel();
QueueChannel outputChannel = new QueueChannel();
MessageFilter filter = new MessageFilter(message -> true);
filter.setOutputChannel(outputChannel);
EventDrivenConsumer endpoint = new EventDrivenConsumer(inputChannel, filter);
endpoint.start();
Message<?> message = new GenericMessage<String>("test");
assertTrue(inputChannel.send(message));
Message<?> reply = outputChannel.receive(0);
assertNotNull(reply);
assertEquals(message.getPayload(), reply.getPayload());
}
use of org.springframework.integration.channel.QueueChannel in project spring-integration by spring-projects.
the class MessageFilterTests method filterAcceptsMessage.
@Test
public void filterAcceptsMessage() {
MessageFilter filter = new MessageFilter(message -> true);
Message<?> message = new GenericMessage<String>("test");
QueueChannel output = new QueueChannel();
filter.setOutputChannel(output);
filter.handleMessage(message);
Message<?> received = output.receive(0);
assertEquals(message.getPayload(), received.getPayload());
assertEquals(message.getHeaders().getId(), received.getHeaders().getId());
}
Aggregations