Skip to content
Permalink
Browse files

test: Increase reliability of JSON Time service tests

  • Loading branch information...
rhwood committed May 6, 2019
1 parent bd65dbb commit c59721350de47a87abe87fe46d7b3eacb2eede4a
Showing with 3 additions and 4 deletions.
  1. +3 −4 java/test/jmri/server/json/time/JsonTimeSocketServiceTest.java
@@ -70,9 +70,8 @@ public void testOnMessage() throws IOException, JmriException, JsonException {
Assert.assertNotNull("Message is not null", message);
Assert.assertEquals("Rate is fast", rate, message.path(JSON.DATA).path(JSON.RATE).asDouble(), 0.0);
Assert.assertEquals("Timebase is on", JSON.ON, message.path(JSON.DATA).path(JSON.STATE).asInt());
// next line verifies time at start of fast clock has not changed -- is this needed?
Assert.assertEquals("Time is current", formatter.format(current),
message.path(JSON.DATA).path(JSON.TIME).asText());
// a timing issue can cause the message turning the fast clock on to
// not get the time at start of running, so don't test that
Assert.assertEquals("Service and listener are listening to changes", 2, manager.getPropertyChangeListeners().length);
Date waitFor = current;
JUnitUtil.waitFor(() -> {
@@ -85,7 +84,7 @@ public void testOnMessage() throws IOException, JmriException, JsonException {
Assert.assertEquals("Timebase is on", JSON.ON, message.path(JSON.DATA).path(JSON.STATE).asInt());
data.put(JSON.STATE, JSON.OFF); // stop the fast clock
service.onMessage(JSON.TIME, data, JSON.POST, Locale.ENGLISH, 42);
current = manager.getTime();
current = manager.getTime();
message = connection.getMessage();
Assert.assertNotNull("Message is not null", message);
Assert.assertEquals("Rate is fast", rate, message.path(JSON.DATA).path(JSON.RATE).asDouble(), 0.0);

0 comments on commit c597213

Please sign in to comment.
You can’t perform that action at this time.