Skip to content

Commit

Permalink
test: Increase reliability of JSON Time service tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rhwood committed May 6, 2019
1 parent bd65dbb commit c597213
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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(() -> {
Expand All @@ -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);
Expand Down

0 comments on commit c597213

Please sign in to comment.