mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-09-30 09:26:44 +00:00
distinguish a listening and a connecting StoreAndForward test
This commit is contained in:
+6
-1
@@ -213,7 +213,7 @@ public class StoreAndForward implements Runnable {
|
||||
} else {
|
||||
synchronized (this) {
|
||||
receivingFromSailMaster = true;
|
||||
logger.info("StoreAndForward issuing SailMaster connections to "+sailMasterHostname+":"+sailMasterPort);
|
||||
logger.info("StoreAndForward issuing SailMaster connection to "+sailMasterHostname+":"+sailMasterPort);
|
||||
notifyAll();
|
||||
}
|
||||
socket = new Socket(sailMasterHostname, sailMasterPort);
|
||||
@@ -279,6 +279,11 @@ public class StoreAndForward implements Runnable {
|
||||
} catch (Throwable e) {
|
||||
if (!stopped) {
|
||||
logger.throwing(StoreAndForward.class.getName(), "Error during forwarding message. Continuing...", e);
|
||||
try {
|
||||
Thread.sleep(1000l); // wait a little bit before trying to re-establish a connection
|
||||
} catch (InterruptedException e1) {
|
||||
logger.throwing(StoreAndForward.class.getName(), "Can't find any sleep...", e1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+9
-6
@@ -30,8 +30,8 @@ import com.sap.sailing.domain.swisstimingadapter.persistence.impl.CollectionName
|
||||
import com.sap.sailing.domain.swisstimingadapter.persistence.impl.FieldNames;
|
||||
import com.sap.sailing.mongodb.Activator;
|
||||
|
||||
public class StoreAndForwardTest {
|
||||
private static final Logger logger = Logger.getLogger(StoreAndForwardTest.class.getName());
|
||||
public class ListeningStoreAndForwardTest {
|
||||
private static final Logger logger = Logger.getLogger(ListeningStoreAndForwardTest.class.getName());
|
||||
|
||||
private static final int RECEIVE_PORT = 6543;
|
||||
private static final int CLIENT_PORT = 6544;
|
||||
@@ -47,8 +47,10 @@ public class StoreAndForwardTest {
|
||||
|
||||
@Before
|
||||
public void setUp() throws UnknownHostException, IOException, InterruptedException {
|
||||
logger.info("ListeningStoreAndForwardTest.setUp");
|
||||
db = Activator.getDefaultInstance().getDB();
|
||||
storeAndForward = new StoreAndForward(RECEIVE_PORT, CLIENT_PORT, SwissTimingFactory.INSTANCE, SwissTimingAdapterPersistence.INSTANCE);
|
||||
swissTimingAdapterPersistence = SwissTimingAdapterPersistence.INSTANCE;
|
||||
storeAndForward = new StoreAndForward(RECEIVE_PORT, CLIENT_PORT, SwissTimingFactory.INSTANCE, swissTimingAdapterPersistence);
|
||||
sendingSocket = new Socket("localhost", RECEIVE_PORT);
|
||||
sendingStream = sendingSocket.getOutputStream();
|
||||
swissTimingFactory = SwissTimingFactory.INSTANCE;
|
||||
@@ -59,18 +61,19 @@ public class StoreAndForwardTest {
|
||||
/* upsert */ true, /* multi */ false);
|
||||
DBCollection rawMessages = db.getCollection(CollectionNames.RAW_MESSAGES.name());
|
||||
rawMessages.drop();
|
||||
swissTimingAdapterPersistence = SwissTimingAdapterPersistence.INSTANCE;
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws InterruptedException, IOException {
|
||||
logger.entering(getClass().getName(), "tearDown");
|
||||
storeAndForward.stop();
|
||||
connector.stop();
|
||||
logger.exiting(getClass().getName(), "tearDown");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSimpleRACMessage() throws IOException, InterruptedException {
|
||||
logger.info("Starting ListeningStoreAndForwardTest.testSimpleRACMessage");
|
||||
final List<Race> racesReceived = new ArrayList<Race>();
|
||||
final boolean[] receivedSomething = new boolean[1];
|
||||
connector.addSailMasterListener(new SailMasterAdapter() {
|
||||
@@ -79,9 +82,9 @@ public class StoreAndForwardTest {
|
||||
for (Race race : races) {
|
||||
racesReceived.add(race);
|
||||
}
|
||||
synchronized (StoreAndForwardTest.this) {
|
||||
synchronized (ListeningStoreAndForwardTest.this) {
|
||||
receivedSomething[0] = true;
|
||||
StoreAndForwardTest.this.notifyAll();
|
||||
ListeningStoreAndForwardTest.this.notifyAll();
|
||||
}
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user