diff --git a/jpos/src/test/java/org/jpos/space/TSpaceTestCase.java b/jpos/src/test/java/org/jpos/space/TSpaceTestCase.java index c51cda0e32..6b71681e77 100644 --- a/jpos/src/test/java/org/jpos/space/TSpaceTestCase.java +++ b/jpos/src/test/java/org/jpos/space/TSpaceTestCase.java @@ -79,7 +79,7 @@ public void testExpiration() { sp.out("testExpiration_Key", "ABC", 50); assertEquals("ABC", sp.rdp("testExpiration_Key")); try { - Thread.sleep(60); + Thread.sleep(75); // allow for low system timer accuracy } catch (InterruptedException e) { } assertNull(sp.rdp("testExpiration_Key"), "ABC"); @@ -136,7 +136,7 @@ public void testGC() throws Exception { sp.out("testGC_Key", "XYZ", 50); assertEquals("ABC", sp.rdp("testGC_Key")); try { - Thread.sleep(60); + Thread.sleep(75); // allow for low system timer accuracy } catch (InterruptedException e) { } assertEquals("testGC_Key", sp.getKeysAsString()); diff --git a/jpos/src/test/java/org/jpos/util/ThroughputControlTestCase.java b/jpos/src/test/java/org/jpos/util/ThroughputControlTestCase.java index 90972e12bf..bd432dd882 100644 --- a/jpos/src/test/java/org/jpos/util/ThroughputControlTestCase.java +++ b/jpos/src/test/java/org/jpos/util/ThroughputControlTestCase.java @@ -32,23 +32,24 @@ public void testSingleThread () throws Exception { ThroughputControl tc = new ThroughputControl (2, 1000); Instant start = Instant.now(); assertTrue (tc.control() == 0L, "Control should return 0L"); + // Allow for low system timer accuracy via a tolerance of 25 milliseconds either way: assertTrue ( - Duration.between(start, Instant.now()).toMillis() < 1000L, + Duration.between(start, Instant.now()).toMillis() < 1000L + 25L, "Elapsed time should be less than one second" ); tc.control(); assertTrue ( - Duration.between(start, Instant.now()).toMillis() < 1000L, + Duration.between(start, Instant.now()).toMillis() < 1000L + 25L, "Elapsed time should still be less than one second" ); tc.control(); assertTrue ( - Duration.between(start, Instant.now()).toMillis() > 1000L, + Duration.between(start, Instant.now()).toMillis() > 1000L - 25L, "Elapsed time should be greater than one second" ); tc.control(); assertTrue ( - Duration.between(start, Instant.now()).toMillis() < 2000L, + Duration.between(start, Instant.now()).toMillis() < 2000L - 25L, "second transaction should be less than two seconds" ); }