mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-04 03:13:49 +00:00
added test for delta clock at mark
This commit is contained in:
1 parent
05e1dcdcd4
commit
d870388e65
4 files changed
+22
-4
No files matched your search
+12
-1
@@ -10,6 +10,7 @@ import java.net.UnknownHostException;
|
||||
import java.text.ParseException;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
@@ -32,7 +33,7 @@ import com.sap.sailing.util.Util;
|
||||
import com.sap.sailing.util.Util.Pair;
|
||||
import com.sap.sailing.util.Util.Triple;
|
||||
|
||||
@Ignore("This test doesn't work as long as the server doesn't play an actual race")
|
||||
//@Ignore("This test doesn't work as long as the server doesn't play an actual race")
|
||||
public class SwissTimingSailMasterLiveTest implements SailMasterListener {
|
||||
private int rpdCounter;
|
||||
private SailMasterConnector connector;
|
||||
@@ -107,6 +108,16 @@ public class SwissTimingSailMasterLiveTest implements SailMasterListener {
|
||||
assertNotNull(currentBoatSpeed);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetDeltaClockAtMark() throws UnknownHostException, IOException, InterruptedException, NumberFormatException, ParseException {
|
||||
Iterable<Race> races = connector.getRaces();
|
||||
Race race = races.iterator().next();
|
||||
Map<Integer, Pair<TimePoint, String>> deltaClockAtMark = connector.getDeltaClockAtMark(race.getRaceID());
|
||||
for (int i=0; i<7; i++) {
|
||||
assertTrue(deltaClockAtMark.keySet().contains(i));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receivedRacePositionData(String raceID, RaceStatus status, TimePoint timePoint, TimePoint startTime,
|
||||
|
||||
+5
@@ -28,5 +28,10 @@ public class CompetitorImpl implements Competitor {
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name+"/"+boatID;
|
||||
}
|
||||
|
||||
}
|
||||
+4
-2
@@ -63,7 +63,7 @@ public class SailMasterConnectorImpl extends SailMasterTransceiver implements Sa
|
||||
private final String host;
|
||||
private final int port;
|
||||
private Socket socket;
|
||||
private static final DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss");
|
||||
private final DateFormat dateFormat;
|
||||
private final Set<SailMasterListener> listeners;
|
||||
private final Thread receiverThread;
|
||||
private boolean stopped;
|
||||
@@ -72,6 +72,7 @@ public class SailMasterConnectorImpl extends SailMasterTransceiver implements Sa
|
||||
|
||||
public SailMasterConnectorImpl(String host, int port) {
|
||||
super();
|
||||
dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss");
|
||||
this.host = host;
|
||||
this.port = port;
|
||||
this.listeners = new HashSet<SailMasterListener>();
|
||||
@@ -387,7 +388,8 @@ public class SailMasterConnectorImpl extends SailMasterTransceiver implements Sa
|
||||
for (int i=0; i<count; i++) {
|
||||
String[] markTimeDetail = sections[3+i].split(";");
|
||||
result.put(Integer.valueOf(markTimeDetail[0]), new Pair<TimePoint, String>(
|
||||
new MillisecondsTimePoint(dateFormat.parse(prefixTimeWithISOToday(markTimeDetail[1]))), markTimeDetail[2]));
|
||||
markTimeDetail.length <= 1 ? null : new MillisecondsTimePoint(dateFormat.parse(prefixTimeWithISOToday(markTimeDetail[1]))),
|
||||
markTimeDetail.length <= 2 ? null : markTimeDetail[2]));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ public class SailMasterTransceiver {
|
||||
* Sends the string message to the output stream <code>os</code>, using the cp1252 character set
|
||||
* for encoding and framing the message with the <code>STX</code> and <code>ETX</code> bytes.
|
||||
*/
|
||||
public void sendMessage(String message, OutputStream os) throws IOException {
|
||||
public synchronized void sendMessage(String message, OutputStream os) throws IOException {
|
||||
os.write(STX);
|
||||
os.write(message.getBytes(Charset.forName("cp1252")));
|
||||
os.write(ETX);
|
||||
|
||||
Reference in new issue
Block a user