changeset 10673:c5a683ee794d

8058514: TEST_BUG: New tests introduced in 8058429 are TimeZone dependent Reviewed-by: lancea
author redestad
date Tue, 16 Sep 2014 00:26:58 +0200
parents 73ddc04724d9
children fe00873b4f8d
files test/java/sql/test/sql/TimestampTests.java
diffstat 1 files changed, 25 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/test/java/sql/test/sql/TimestampTests.java	Mon Sep 15 21:20:46 2014 +0200
+++ b/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
      */