From caf493c65f782f92dc89f1465de92420dfc355e9 Mon Sep 17 00:00:00 2001 From: Axel Uhl Date: Mon, 14 Jan 2013 16:23:05 +0100 Subject: [PATCH] in the replication tests, wait for the servlet emulation to have started listening on the server socket before continuing --- .../test/AbstractServerReplicationTest.java | 14 ++++- ...Server (Proxy, Remote Debug SAP VM).launch | 59 ++++++++++--------- 2 files changed, 42 insertions(+), 31 deletions(-) diff --git a/java/com.sap.sailing.server.replication.test/src/com/sap/sailing/server/replication/test/AbstractServerReplicationTest.java b/java/com.sap.sailing.server.replication.test/src/com/sap/sailing/server/replication/test/AbstractServerReplicationTest.java index 396a777496a..0992edfbcf8 100755 --- a/java/com.sap.sailing.server.replication.test/src/com/sap/sailing/server/replication/test/AbstractServerReplicationTest.java +++ b/java/com.sap.sailing.server.replication.test/src/com/sap/sailing/server/replication/test/AbstractServerReplicationTest.java @@ -68,7 +68,7 @@ public abstract class AbstractServerReplicationTest { * service will be created as replica */ protected Pair basicSetUp( - boolean dropDB, RacingEventServiceImpl master, RacingEventServiceImpl replica) throws IOException { + boolean dropDB, RacingEventServiceImpl master, RacingEventServiceImpl replica) throws IOException, InterruptedException { final String exchangeName = "test-sapsailinganalytics-exchange"; final MongoDBService mongoDBService = MongoDBService.INSTANCE; if (dropDB) { @@ -124,12 +124,17 @@ public abstract class AbstractServerReplicationTest { this.masterDescriptor = masterDescriptor; } - private void startInitialLoadTransmissionServlet() { + private void startInitialLoadTransmissionServlet() throws InterruptedException { + final boolean[] listening = new boolean[] { false }; new Thread("Replication initial load test server") { public void run() { ServerSocket ss; try { ss = new ServerSocket(SERVLET_PORT); + synchronized (listening) { + listening[0] = true; + listening.notifyAll(); + } boolean stop = false; while (!stop) { Socket s = ss.accept(); @@ -157,6 +162,11 @@ public abstract class AbstractServerReplicationTest { } } }.start(); + synchronized (listening) { + while (!listening[0]) { + listening.wait(); + } + } } /** diff --git a/java/com.sap.sailing.server/SailingServer (Proxy, Remote Debug SAP VM).launch b/java/com.sap.sailing.server/SailingServer (Proxy, Remote Debug SAP VM).launch index 55f4c74c350..5a6a3d8935b 100755 --- a/java/com.sap.sailing.server/SailingServer (Proxy, Remote Debug SAP VM).launch +++ b/java/com.sap.sailing.server/SailingServer (Proxy, Remote Debug SAP VM).launch @@ -1,29 +1,30 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +