--- a/jdk/test/java/time/test/java/time/TestClock_System.java Tue Feb 24 10:52:02 2015 -0800
+++ b/jdk/test/java/time/test/java/time/TestClock_System.java Tue Feb 24 21:51:45 2015 +0100
@@ -66,8 +66,10 @@
import java.time.Clock;
import java.time.Instant;
import java.time.ZoneId;
+import java.time.ZoneOffset;
import org.testng.annotations.Test;
+import org.testng.annotations.DataProvider;
/**
* Test system clock.
@@ -76,6 +78,7 @@
public class TestClock_System {
private static final ZoneId PARIS = ZoneId.of("Europe/Paris");
+ private static final Clock systemUTC = Clock.systemUTC();
public void test_withZone_same() {
Clock test = Clock.system(PARIS);
@@ -90,6 +93,32 @@
}
//-----------------------------------------------------------------------
+ @DataProvider(name="sampleSystemUTC")
+ Object[][] provider_sampleSystemUTC() {
+ return new Object[][] {
+ {"Clock.systemUTC()#1", Clock.systemUTC()},
+ {"Clock.systemUTC()#2", Clock.systemUTC()},
+ {"Clock.system(ZoneOffset.UTC)#1", Clock.system(ZoneOffset.UTC)},
+ {"Clock.system(ZoneOffset.UTC)#2", Clock.system(ZoneOffset.UTC)}
+ };
+ }
+
+ // Test for 8073394
+ @Test(dataProvider="sampleSystemUTC")
+ public void test_systemUTC(String s, Clock clock) {
+ if (clock != systemUTC) {
+ throw new RuntimeException("Unexpected clock instance for " + s + ": "
+ + "\n\texpected: " + toString(systemUTC)
+ + "\n\tactual: " + toString(clock));
+ }
+ }
+
+ private static String toString(Clock c) {
+ return c == null ? null :
+ c + " " + c.getClass().getName() + "@" + System.identityHashCode(c);
+ }
+
+ //-----------------------------------------------------------------------
private static String formatTime(String prefix, Instant time) {
return prefix + ": " + time + " - seconds: "