Skip to content

Commit

Permalink
JCR-2909: EntryCollectorTest failure on certain Java versions
Browse files Browse the repository at this point in the history
Use set instead of array equality for comparing sets of privileges

git-svn-id: https://svn.apache.org/repos/asf/jackrabbit/trunk@1077887 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
jukka committed Mar 4, 2011
1 parent 4981622 commit e4916db
Showing 1 changed file with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import java.security.Principal;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;

Expand Down Expand Up @@ -214,7 +215,7 @@ public void testCache() throws Exception {
}
}
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]);
Expand All @@ -236,6 +237,21 @@ public void testCache() throws Exception {
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);
Expand Down

0 comments on commit e4916db

Please sign in to comment.