use of org.springframework.integration.channel.QueueChannel in project spring-integration by spring-projects.
the class ServiceActivatorDefaultFrameworkMethodTests method testReplyingMessageHandlerWithOtherMethod.
@Test
public void testReplyingMessageHandlerWithOtherMethod() {
QueueChannel replyChannel = new QueueChannel();
Message<?> message = MessageBuilder.withPayload("test").setReplyChannel(replyChannel).build();
this.replyingHandlerWithOtherMethodTestInputChannel.send(message);
Message<?> reply = replyChannel.receive(0);
assertEquals("bar", reply.getPayload());
assertEquals("replyingHandlerWithOtherMethodTestInputChannel,replyingHandlerWithOtherMethodTestService", reply.getHeaders().get("history").toString());
}
use of org.springframework.integration.channel.QueueChannel in project spring-integration by spring-projects.
the class ServiceActivatorDefaultFrameworkMethodTests method testAsyncError.
@Test
public void testAsyncError() {
QueueChannel errorChannel = new QueueChannel();
Message<?> message = MessageBuilder.withPayload("test").setErrorChannel(errorChannel).build();
this.asyncIn.send(message);
this.asyncService.future.setException(new RuntimeException("intended"));
Message<?> error = errorChannel.receive(0);
assertNotNull(error);
assertThat(error, instanceOf(ErrorMessage.class));
assertThat(error.getPayload(), instanceOf(MessagingException.class));
assertThat(((MessagingException) error.getPayload()).getCause(), instanceOf(RuntimeException.class));
assertThat(((MessagingException) error.getPayload()).getCause().getMessage(), equalTo("intended"));
assertEquals("test", ((MessagingException) error.getPayload()).getFailedMessage().getPayload());
}
use of org.springframework.integration.channel.QueueChannel in project spring-integration by spring-projects.
the class ServiceActivatorDefaultFrameworkMethodTests method testMessageProcessor.
@Test
public void testMessageProcessor() {
Object processor = TestUtils.getPropertyValue(processorTestService, "handler.processor");
assertSame(testMessageProcessor, processor);
QueueChannel replyChannel = new QueueChannel();
Message<?> message = MessageBuilder.withPayload("bar").setReplyChannel(replyChannel).setHeader("foo", "foo").build();
this.processorTestInputChannel.send(message);
Message<?> reply = replyChannel.receive(0);
assertEquals("foo:bar", reply.getPayload());
assertThat(reply, not(hasHeaderKey("foo")));
}
use of org.springframework.integration.channel.QueueChannel in project spring-integration by spring-projects.
the class ServiceActivatorDefaultFrameworkMethodTests method testMessageHandler.
@Test
public void testMessageHandler() {
QueueChannel replyChannel = new QueueChannel();
Message<?> message = MessageBuilder.withPayload("test").setReplyChannel(replyChannel).build();
this.handlerTestInputChannel.send(message);
}
use of org.springframework.integration.channel.QueueChannel in project spring-integration by spring-projects.
the class ServiceActivatorDefaultFrameworkMethodTests method testReplyingMessageHandler.
@Test
public void testReplyingMessageHandler() {
QueueChannel replyChannel = new QueueChannel();
Message<?> message = MessageBuilder.withPayload("test").setReplyChannel(replyChannel).build();
this.replyingHandlerTestInputChannel.send(message);
Message<?> reply = replyChannel.receive(0);
assertEquals("TEST", reply.getPayload());
assertEquals("replyingHandlerTestInputChannel,replyingHandlerTestService", reply.getHeaders().get("history").toString());
StackTraceElement[] st = (StackTraceElement[]) reply.getHeaders().get("callStack");
assertTrue(StackTraceUtils.isFrameContainingXBeforeFrameContainingY("AbstractSubscribableChannel", "MethodInvokerHelper", // close to the metal
st));
}
Aggregations