db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From myrn...@apache.org
Subject svn commit: r1541159 - /db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/i18n/LocalizedDisplayScriptTest.java
Date Tue, 12 Nov 2013 17:06:38 GMT
Author: myrnavl
Date: Tue Nov 12 17:06:38 2013
New Revision: 1541159

URL: http://svn.apache.org/r1541159
Log:
DERBY-6356; java.security.AccessControlException in i18n.LocalizedDisplayScriptTest
   adding a 'setDefault' method to the test to do the calls requiring user.timezone "write"
permission

Modified:
    db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/i18n/LocalizedDisplayScriptTest.java

Modified: db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/i18n/LocalizedDisplayScriptTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/i18n/LocalizedDisplayScriptTest.java?rev=1541159&r1=1541158&r2=1541159&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/i18n/LocalizedDisplayScriptTest.java
(original)
+++ db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/i18n/LocalizedDisplayScriptTest.java
Tue Nov 12 17:06:38 2013
@@ -20,6 +20,8 @@
 
 package org.apache.derbyTesting.functionTests.tests.i18n;
 
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 import java.util.Properties;
 import java.util.TimeZone;
 
@@ -123,13 +125,25 @@ public final class LocalizedDisplayScrip
         // the canon contains time columns, which would display localized -
         // and so cause errors. Thus, run this with timezone PST.
         defaultTimeZone = TimeZone.getDefault(); 
-        TimeZone.setDefault(TimeZone.getTimeZone("America/Los_Angeles")); 
+        setDefault(TimeZone.getTimeZone("America/Los_Angeles")); 
         LocalizedResource.resetLocalizedResourceCache();
     }
     
     public void tearDown() throws Exception {
-        TimeZone.setDefault(defaultTimeZone); 
+        setDefault(defaultTimeZone); 
         LocalizedResource.resetLocalizedResourceCache();
         super.tearDown();
     }    
+
+    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;
+                    }});
+    }
 }



Mime
View raw message