@Test
public void testReorder() throws Exception {
Privilege[] read = privilegesFromNames(PrivilegeConstants.JCR_READ, PrivilegeConstants.JCR_READ_ACCESS_CONTROL);
Privilege[] write = privilegesFromNames(PrivilegeConstants.JCR_WRITE);
AbstractAccessControlList acl = createEmptyACL();
acl.addAccessControlEntry(testPrincipal, read);
acl.addEntry(testPrincipal, write, false);
acl.addAccessControlEntry(getTestPrincipal("p2"), write);
AccessControlEntry[] entries = acl.getAccessControlEntries();
assertEquals(3, entries.length);
AccessControlEntry first = entries[0];
AccessControlEntry second = entries[1];
AccessControlEntry third = entries[2];
// reorder 'second' to the first position
acl.orderBefore(second, first);
assertEquals(second, acl.getEntries().get(0));
assertEquals(first, acl.getEntries().get(1));
assertEquals(third, acl.getEntries().get(2));
// reorder 'third' before 'first'
acl.orderBefore(third, first);
assertEquals(second, acl.getEntries().get(0));
assertEquals(third, acl.getEntries().get(1));
assertEquals(first, acl.getEntries().get(2));
}