You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by km...@apache.org on 2013/11/11 20:17:46 UTC

svn commit: r1540812 - in /db/derby/code/branches/10.8: ./ java/testing/org/apache/derbyTesting/junit/TimeZoneTestSetup.java

Author: kmarsden
Date: Mon Nov 11 19:17:46 2013
New Revision: 1540812

URL: http://svn.apache.org/r1540812
Log:
DERBY-6349 DaylightSavingTest - java.security.AccessControlException
merge revision  1525671 from 10.10 branch

Modified:
    db/derby/code/branches/10.8/   (props changed)
    db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/junit/TimeZoneTestSetup.java

Propchange: db/derby/code/branches/10.8/
------------------------------------------------------------------------------
  Merged /db/derby/code/trunk:r1518766,1524579
  Merged /db/derby/code/branches/10.10:r1525671

Modified: db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/junit/TimeZoneTestSetup.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/junit/TimeZoneTestSetup.java?rev=1540812&r1=1540811&r2=1540812&view=diff
==============================================================================
--- db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/junit/TimeZoneTestSetup.java (original)
+++ db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/junit/TimeZoneTestSetup.java Mon Nov 11 19:17:46 2013
@@ -19,6 +19,8 @@
 
 package org.apache.derbyTesting.junit;
 
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 import java.util.TimeZone;
 import junit.framework.Test;
 
@@ -56,15 +58,27 @@ public class TimeZoneTestSetup extends B
      */
     protected void setUp() {
         savedDefault = TimeZone.getDefault();
-        TimeZone.setDefault(requestedDefault);
+        setDefault(requestedDefault);
     }
 
     /**
      * Reset the timezone.
      */
     protected void tearDown() {
-        TimeZone.setDefault(savedDefault);
+        setDefault(savedDefault);
         savedDefault = null;
         requestedDefault = null;
     }
+    
+    private void setDefault(final TimeZone tz) throws SecurityException{
+        if (tz== null) {
+            throw new IllegalArgumentException("tz cannot be <null>");
+        }
+        AccessController.doPrivileged(
+                new PrivilegedAction() {
+                    public Object run() throws SecurityException {
+                        TimeZone.setDefault(tz);
+                        return null;
+                    }});
+    }
 }