INT-2742 Fix TCP Test Case Race Condition

Test data was sent before the error-channel was added to
the inbound adapter; the expected error could occur before
the error-channel was in place and the test failed
because the expected error message was absent.

Move the error-channel setup to before the test
data is sent.
This commit is contained in:
Gary Russell
2012-09-07 17:01:22 -04:00
committed by Oleg Zhurakousky
parent 03e60171ec
commit e77811c59f

View File

@@ -594,11 +594,11 @@ public class TcpReceivingChannelAdapterTests {
adapter.setOutputChannel(channel);
ServiceActivatingHandler handler = new ServiceActivatingHandler(new FailingService());
channel.subscribe(handler);
QueueChannel errorChannel = new QueueChannel();
adapter.setErrorChannel(errorChannel);
Socket socket = SocketFactory.getDefault().createSocket("localhost", port);
socket.getOutputStream().write("Test1\r\n".getBytes());
socket.getOutputStream().write("Test2\r\n".getBytes());
QueueChannel errorChannel = new QueueChannel();
adapter.setErrorChannel(errorChannel);
Message<?> message = errorChannel.receive(10000);
assertNotNull(message);
assertEquals("Failed", ((Exception) message.getPayload()).getCause().getMessage());