8023639: Difference between LocalTime.now(Clock.systemDefaultZone()) and LocalTime.now() executed successively is more than 100 000 000 nanoseconds for slow machines
Summary: Test timed out on a slow machine; it is not a conformance test and should be in the test subtree
Reviewed-by: darcy, sherman
--- a/jdk/test/java/time/tck/java/time/TCKLocalTime.java Fri Sep 06 15:36:00 2013 -0700
+++ b/jdk/test/java/time/tck/java/time/TCKLocalTime.java Sat Sep 14 13:55:04 2013 -0400
@@ -283,17 +283,6 @@
}
//-----------------------------------------------------------------------
- // 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)
//-----------------------------------------------------------------------
@Test(expectedExceptions=NullPointerException.class)
--- a/jdk/test/java/time/test/java/time/TestLocalTime.java Fri Sep 06 15:36:00 2013 -0700
+++ b/jdk/test/java/time/test/java/time/TestLocalTime.java Sat Sep 14 13:55:04 2013 -0400
@@ -61,7 +61,9 @@
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 @@
}
}
+ //-----------------------------------------------------------------------
+ // 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
+ }
+
}