8058514: TEST_BUG: New tests introduced in 8058429 are TimeZone dependent
authorredestad
Tue, 16 Sep 2014 00:26:58 +0200
changeset 26622 e7763eeb5e4d
parent 26621 91ab384d2f49
child 26623 11289cf5c8fc
8058514: TEST_BUG: New tests introduced in 8058429 are TimeZone dependent Reviewed-by: lancea
jdk/test/java/sql/test/sql/TimestampTests.java
--- a/jdk/test/java/sql/test/sql/TimestampTests.java	Mon Sep 15 21:20:46 2014 +0200
+++ b/jdk/test/java/sql/test/sql/TimestampTests.java	Tue Sep 16 00:26:58 2014 +0200
@@ -29,13 +29,38 @@
 import java.time.LocalDateTime;
 import java.time.ZoneId;
 import java.util.Calendar;
+import java.util.TimeZone;
 import static org.testng.Assert.*;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
 import org.testng.annotations.DataProvider;
 import org.testng.annotations.Test;
 import util.BaseTest;
 
 public class TimestampTests extends BaseTest {
 
+    private static TimeZone defaultTimeZone = null;
+
+    /*
+     * Need to set and use a custom TimeZone which does not
+     * observe daylight savings time for this test.
+     */
+    @BeforeClass
+    public static void setUpClass() throws Exception {
+        defaultTimeZone = TimeZone.getDefault();
+        TimeZone tzone = TimeZone.getTimeZone("GMT+01");
+        assertFalse(tzone.observesDaylightTime());
+        TimeZone.setDefault(tzone);
+    }
+
+    /*
+     * Conservatively reset the default time zone after test.
+     */
+    @AfterClass
+    public static void tearDownClass() throws Exception {
+        TimeZone.setDefault(defaultTimeZone);
+    }
+
     /*
      * Validate an IllegalArgumentException is thrown for an invalid Timestamp
      */