From e77811c59f98a284911dde54fb03586ec4d8621f Mon Sep 17 00:00:00 2001 From: Gary Russell Date: Fri, 7 Sep 2012 17:01:22 -0400 Subject: [PATCH] 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. --- .../integration/ip/tcp/TcpReceivingChannelAdapterTests.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/TcpReceivingChannelAdapterTests.java b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/TcpReceivingChannelAdapterTests.java index d96144f6a3..578cdd72e2 100644 --- a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/TcpReceivingChannelAdapterTests.java +++ b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/TcpReceivingChannelAdapterTests.java @@ -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());