jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1077887 - /jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/acl/EntryCollectorTest.java
Date Fri, 04 Mar 2011 11:34:10 GMT
Author: jukka
Date: Fri Mar  4 11:34:09 2011
New Revision: 1077887

URL: http://svn.apache.org/viewvc?rev=1077887&view=rev
Log:
JCR-2909: EntryCollectorTest failure on certain Java versions

Use set instead of array equality for comparing sets of privileges

Modified:
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/acl/EntryCollectorTest.java

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/acl/EntryCollectorTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/acl/EntryCollectorTest.java?rev=1077887&r1=1077886&r2=1077887&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/acl/EntryCollectorTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/acl/EntryCollectorTest.java
Fri Mar  4 11:34:09 2011
@@ -40,6 +40,7 @@ import javax.jcr.security.Privilege;
 import java.security.Principal;
 import java.util.Arrays;
 import java.util.Collections;
+import java.util.HashSet;
 import java.util.Set;
 import java.util.UUID;
 
@@ -214,7 +215,7 @@ public class EntryCollectorTest extends 
             }
         }
         Privilege[] privs = privilegesFromNames(new String[] {Privilege.JCR_ADD_CHILD_NODES,
Privilege.JCR_REMOVE_CHILD_NODES});
-        assertTrue(Arrays.equals(privs, acl.getAccessControlEntries()[0].getPrivileges()));
+        assertEquals(privs, acl.getAccessControlEntries()[0].getPrivileges());
 
         // --- test4: remove policy at childNPath ------------------------------
         acMgr.removePolicy(childNPath, acMgr.getPolicies(childNPath)[0]);
@@ -236,6 +237,21 @@ public class EntryCollectorTest extends 
         verifyACEs(plcs, path, 2);
     }
 
+    /**
+     * Asserts that the given privilege sets are equal, regardless of ordering.
+     */
+    private void assertEquals(Privilege[] expected, Privilege[] actual) {
+        assertEquals(getPrivilegeNames(expected), getPrivilegeNames(actual));
+    }
+
+    private Set<String> getPrivilegeNames(Privilege[] privileges) {
+        Set<String> names = new HashSet<String>();
+        for (Privilege privilege : privileges) {
+            names.add(privilege.getName());
+        }
+        return names;
+    }
+
     public void testEntriesAreCached() throws Exception {
         modifyPrivileges(path, testGroup.getPrincipal(), privilegesFromName(Privilege.JCR_READ),
true);
         AccessControlPolicy[] plcs = acMgr.getEffectivePolicies(path);



Mime
View raw message