use of org.springframework.messaging.MessageChannel in project camel by apache.
the class SpringIntegrationOneWayConsumerTest method testSendingOneWayMessage.
@Test
public void testSendingOneWayMessage() throws Exception {
MockEndpoint resultEndpoint = getMockEndpoint("mock:result");
resultEndpoint.expectedBodiesReceived(MESSAGE_BODY);
MessageChannel outputChannel = getMandatoryBean(MessageChannel.class, "outputChannel");
outputChannel.send(new GenericMessage<Object>(MESSAGE_BODY));
assertMockEndpointsSatisfied();
}
use of org.springframework.messaging.MessageChannel in project camel by apache.
the class SpringIntegrationTwoWayConsumerTest method testSendingTwoWayMessage.
@Test
public void testSendingTwoWayMessage() throws Exception {
final CountDownLatch latch = new CountDownLatch(1);
MessageChannel requestChannel = getMandatoryBean(MessageChannel.class, "requestChannel");
Map<String, Object> maps = new HashMap<String, Object>();
maps.put(MessageHeaders.REPLY_CHANNEL, "responseChannel");
Message<String> message = new GenericMessage<String>(MESSAGE_BODY, maps);
DirectChannel responseChannel = getMandatoryBean(DirectChannel.class, "responseChannel");
responseChannel.subscribe(new MessageHandler() {
public void handleMessage(Message<?> message) {
latch.countDown();
assertEquals("Get the wrong result", MESSAGE_BODY + " is processed", message.getPayload());
assertEquals("Done", message.getHeaders().get("Status"));
}
});
requestChannel.send(message);
assertTrue(latch.await(1, TimeUnit.SECONDS));
}
use of org.springframework.messaging.MessageChannel in project camel by apache.
the class CamelTargetAdapterTest method testSendingOneWayMessage.
@Test
public void testSendingOneWayMessage() throws Exception {
MockEndpoint resultEndpoint = getMockEndpoint("mock:result");
resultEndpoint.expectedBodiesReceived(MESSAGE_BODY);
MessageChannel outputChannel = getMandatoryBean(MessageChannel.class, "channelA");
outputChannel.send(new GenericMessage<Object>(MESSAGE_BODY));
assertMockEndpointsSatisfied();
}
use of org.springframework.messaging.MessageChannel in project camel by apache.
the class CamelTargetAdapterTest method testSendingTwoWayMessage.
@Test
public void testSendingTwoWayMessage() throws Exception {
final CountDownLatch latch = new CountDownLatch(1);
MessageChannel requestChannel = getMandatoryBean(MessageChannel.class, "channelB");
Message<?> message = new GenericMessage<Object>(MESSAGE_BODY);
//Need to subscribe the responseChannel first
DirectChannel responseChannel = getMandatoryBean(DirectChannel.class, "channelC");
responseChannel.subscribe(new MessageHandler() {
public void handleMessage(Message<?> message) {
latch.countDown();
assertEquals("Get the wrong result", MESSAGE_BODY + " is processed", message.getPayload());
}
});
requestChannel.send(message);
assertTrue(latch.await(1, TimeUnit.SECONDS));
}
use of org.springframework.messaging.MessageChannel in project camel by apache.
the class CamelTargetAdapterTest method testSendingTwoWayMessageWithMessageAddress.
@Test
public void testSendingTwoWayMessageWithMessageAddress() throws Exception {
final CountDownLatch latch = new CountDownLatch(1);
MessageChannel requestChannel = getMandatoryBean(MessageChannel.class, "channelD");
DirectChannel responseChannel = getMandatoryBean(DirectChannel.class, "channelC");
Map<String, Object> headers = new HashMap<String, Object>();
headers.put(MessageHeaders.REPLY_CHANNEL, responseChannel);
GenericMessage<String> message = new GenericMessage<String>(MESSAGE_BODY, headers);
responseChannel.subscribe(new MessageHandler() {
public void handleMessage(Message<?> message) {
latch.countDown();
assertEquals("Get the wrong result", MESSAGE_BODY + " is processed", message.getPayload());
}
});
requestChannel.send(message);
assertTrue(latch.await(1, TimeUnit.SECONDS));
}
Aggregations