@Test
public void testSendingTwoWayMessage() throws Exception {
MessageChannel requestChannel = (MessageChannel) applicationContext.getBean("channelB");
Message message = new GenericMessage(MESSAGE_BODY);
//Need to subscribe the responseChannel first
DirectChannel responseChannel = (DirectChannel) applicationContext.getBean("channelC");
responseChannel.subscribe(new MessageHandler() {
public void handleMessage(Message<?> message) {
String result = (String) message.getPayload();
assertEquals("Get the wrong result", MESSAGE_BODY + " is processed", result);
}
});
requestChannel.send(message);
}