8023639: Difference between LocalTime.now(Clock.systemDefaultZone()) and LocalTime.now() executed successively is more than 100 000 000 nanoseconds for slow machines

Test timed out on a slow machine; it is not a conformance test and should be in the test subtree

Reviewed-by: darcy, sherman
This commit is contained in:
Roger Riggs 2013-09-14 13:55:04 -04:00
parent 9bed48236a
commit e2940a0e25
2 changed files with 21 additions and 11 deletions

View File

@ -282,17 +282,6 @@ public class TCKLocalTime extends AbstractDateTimeTest {
check(LocalTime.MAX, 23, 59, 59, 999999999);
}
//-----------------------------------------------------------------------
// now()
//-----------------------------------------------------------------------
@Test
public void now() {
LocalTime expected = LocalTime.now(Clock.systemDefaultZone());
LocalTime test = LocalTime.now();
long diff = Math.abs(test.toNanoOfDay() - expected.toNanoOfDay());
assertTrue(diff < 100000000); // less than 0.1 secs
}
//-----------------------------------------------------------------------
// now(ZoneId)
//-----------------------------------------------------------------------

View File

@ -61,7 +61,9 @@ package test.java.time;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertSame;
import static org.testng.Assert.assertTrue;
import java.time.Clock;
import java.time.LocalTime;
import org.testng.annotations.Test;
@ -176,4 +178,23 @@ public class TestLocalTime extends AbstractTest {
}
}
//-----------------------------------------------------------------------
// now()
//-----------------------------------------------------------------------
@Test
public void now() {
// Warmup the TimeZone data so the following test does not include
// one-time initialization
LocalTime expected = LocalTime.now(Clock.systemDefaultZone());
expected = LocalTime.now(Clock.systemDefaultZone());
LocalTime test = LocalTime.now();
long diff = test.toNanoOfDay() - expected.toNanoOfDay();
if (diff < 0) {
// Adjust if for rollover around midnight
diff += 24 * 60 * 60 * 1_000_000_000L; // Nanos Per Day
}
assertTrue(diff < 500000000); // less than 0.5 secs
}
}