harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From var...@apache.org
Subject svn commit: r487048 - in /harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang: MutableSecurityManager.java SecurityManagerTest.java
Date Thu, 14 Dec 2006 07:16:34 GMT
Author: varlax
Date: Wed Dec 13 23:16:33 2006
New Revision: 487048

URL: http://svn.apache.org/viewvc?view=rev&rev=487048
Log:
Fixed SecurityManagerTest to pass on DRLVM.

Modified:
    harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/MutableSecurityManager.java
    harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/SecurityManagerTest.java

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/MutableSecurityManager.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/MutableSecurityManager.java?view=diff&rev=487048&r1=487047&r2=487048
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/MutableSecurityManager.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/MutableSecurityManager.java
Wed Dec 13 23:16:33 2006
@@ -56,13 +56,15 @@
     }
 
     @Override
-    public void checkPermission(Permission permission) {
-        if (enabled.implies(permission)) {
-            return;
-        }
-        
+    public void checkPermission(Permission permission) 
+    {
+        // denied should take precedence over allowed
         if (denied != null && denied.implies(permission)){
             throw new SecurityException("Denied " + permission);
+        }
+
+        if (enabled.implies(permission)) {
+            return;
         }
         
         super.checkPermission(permission);

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/SecurityManagerTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/SecurityManagerTest.java?view=diff&rev=487048&r1=487047&r2=487048
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/SecurityManagerTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/SecurityManagerTest.java
Wed Dec 13 23:16:33 2006
@@ -18,6 +18,8 @@
 
 import java.io.File;
 import java.security.Security;
+import java.security.SecurityPermission;
+import java.security.AllPermission;
 import tests.support.Support_Exec;
 
 import junit.framework.TestCase;
@@ -119,15 +121,12 @@
      */
     public void test_checkMemberAccessLjava_lang_ClassI() {
         MutableSecurityManager sm = new MutableSecurityManager();
-        sm.addPermission(MutableSecurityManager.SET_SECURITY_MANAGER);
+        // enable all but access check
+        sm.addPermission(new AllPermission());
         sm.denyPermission(new RuntimePermission("accessDeclaredMembers"));
         System.setSecurityManager(sm);
         try {
-            try {
-                getClass().getDeclaredFields();
-            } catch (SecurityException e) {
-                fail("This should not throw a security exception");
-            }
+            getClass().getDeclaredFields();
 
             try {
                 Object.class.getDeclaredFields();
@@ -167,18 +166,12 @@
     private static class checkPermissionLjava_security_PermissionTesting {
         public static void main(String[] args) {
             MutableSecurityManager sm = new MutableSecurityManager();
-            sm.addPermission(MutableSecurityManager.SET_SECURITY_MANAGER);
             System.setSecurityManager(sm);
             try {
-                try {
-                    System.getSecurityManager().checkPermission(
-                            new RuntimePermission("createClassLoader"));
-                    fail("This should throw a SecurityException");
-                } catch (SecurityException e) {
-                }
-            } finally {
-                System.setSecurityManager(null);
-            }
+                System.getSecurityManager().checkPermission(
+                    new RuntimePermission("createClassLoader"));
+                fail("This should throw a SecurityException");
+            } catch (SecurityException ok) {}
         }
     }
 



Mime
View raw message