harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smish...@apache.org
Subject svn commit: r496921 - /harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/PolicyTest.java
Date Wed, 17 Jan 2007 03:20:33 GMT
Author: smishura
Date: Tue Jan 16 19:20:32 2007
New Revision: 496921

URL: http://svn.apache.org/viewvc?view=rev&rev=496921
Log:
Add test for reseting policy to default

Modified:
    harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/PolicyTest.java

Modified: harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/PolicyTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/PolicyTest.java?view=diff&rev=496921&r1=496920&r2=496921
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/PolicyTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/PolicyTest.java
Tue Jan 16 19:20:32 2007
@@ -26,6 +26,7 @@
 import java.security.PermissionCollection;
 import java.security.Policy;
 import java.security.ProtectionDomain;
+import java.security.Security;
 import java.security.SecurityPermission;
 import java.util.Collection;
 import java.util.Enumeration;
@@ -78,9 +79,6 @@
     public void test_getPolicy() {
         SecurityManager old = System.getSecurityManager();
         Policy oldPolicy = Policy.getPolicy();
-
-        assertNotNull("Got a null system security policy", oldPolicy);
-
         try {
             Policy.setPolicy(new TestProvider());
             SecurityChecker checker = new SecurityChecker(
@@ -157,5 +155,30 @@
 
         assertTrue(c.contains(sp));
         //no check for static permissions
+    }
+    
+    /**
+     * @tests java.security.Policy#getPolicy()
+     * @tests java.security.Policy#setPolicy()
+     */
+    public void testResetingPolicyToDefault() {
+
+        Policy oldPolicy = Policy.getPolicy();
+        assertNotNull("Got a null system security policy", oldPolicy);
+
+        try {
+
+            Policy.setPolicy(null); // passing null resets policy
+            Policy newPolicy = Policy.getPolicy();
+
+            assertNotNull(newPolicy);
+            assertNotSame(oldPolicy, newPolicy);
+
+            assertEquals("Policy class name", Security
+                    .getProperty("policy.provider"), newPolicy.getClass()
+                    .getName());
+        } finally {
+            Policy.setPolicy(oldPolicy);
+        }
     }
 }



Mime
View raw message