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.
This commit is contained in:
Gary Russell
2012-05-23 13:08:51 -04:00
parent 73164ff82a
commit 33c0da2341

View File

@@ -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<String>("Hello, world!"));
assertTrue(latch.await(10, TimeUnit.SECONDS));
assertEquals(0, ppServerSocketCountClient.get());
assertEquals(1, ppSocketCountClient.get());