db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmars...@apache.org
Subject svn commit: r1524579 - /db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/TimeZoneTestSetup.java
Date Wed, 18 Sep 2013 21:26:26 GMT
Author: kmarsden
Date: Wed Sep 18 21:26:26 2013
New Revision: 1524579

URL: http://svn.apache.org/r1524579
Log:
DERBY-6349 DaylightSavingTest - java.security.AccessControlException


Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/TimeZoneTestSetup.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/TimeZoneTestSetup.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/TimeZoneTestSetup.java?rev=1524579&r1=1524578&r2=1524579&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/TimeZoneTestSetup.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/TimeZoneTestSetup.java
Wed Sep 18 21:26:26 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<Object>() {
+                    public Object run() throws SecurityException {
+                        TimeZone.setDefault(tz);
+                        return null;
+                    }});
+    }
 }



Mime
View raw message