From 33c0da23411fb80bc8b6561ecd7cc1a69828315e Mon Sep 17 00:00:00 2001 From: Gary Russell Date: Wed, 23 May 2012 13:08:51 -0400 Subject: [PATCH] INT-2581 Fix Failing Test (Timing) When sending a message to the server, we checked that the user hook for the socket creation was called. However, it was possible (likely) that we tested the counter before the socket actually opened. --- .../integration/ip/tcp/connection/SocketSupportTests.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/SocketSupportTests.java b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/SocketSupportTests.java index 39340d91bc..13ab174eb4 100644 --- a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/SocketSupportTests.java +++ b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/SocketSupportTests.java @@ -144,9 +144,11 @@ public class SocketSupportTests { }); final AtomicInteger ppSocketCountServer = new AtomicInteger(); final AtomicInteger ppServerSocketCountServer = new AtomicInteger(); + final CountDownLatch latch = new CountDownLatch(1); TcpSocketSupport serverSocketSupport = new TcpSocketSupport() { public void postProcessSocket(Socket socket) { ppSocketCountServer.incrementAndGet(); + latch.countDown(); } public void postProcessServerSocket(ServerSocket serverSocket) { ppServerSocketCountServer.incrementAndGet(); @@ -156,6 +158,7 @@ public class SocketSupportTests { serverConnectionFactory.start(); waitListening(serverConnectionFactory); clientConnectionFactory.getConnection().send(new GenericMessage("Hello, world!")); + assertTrue(latch.await(10, TimeUnit.SECONDS)); assertEquals(0, ppServerSocketCountClient.get()); assertEquals(1, ppSocketCountClient.get());