public void testRemoveAccessControlEntryAndSetPolicy() throws NotExecutableException, RepositoryException {
checkCanModifyAc(path);
// add a new ACE that can be removed later on.
AccessControlList acl = getList(acMgr, path);
if (!acl.addAccessControlEntry(testPrincipal, privs)) {
throw new NotExecutableException();
} else {
acMgr.setPolicy(path, acl);
}
// try to re-access the modifiable ACL in order to remove the ACE
// added before.
acl = getList(acMgr, path);
AccessControlEntry ace = null;
AccessControlEntry[] aces = acl.getAccessControlEntries();
if (aces.length == 0) {
throw new NotExecutableException();
} else {
ace = aces[0];
acl.removeAccessControlEntry(ace);
}
// before setting the policy again -> no changes visible.
assertEquals("Removal of an ACE must only be visible upon 'setPolicy'", Arrays.asList(aces), Arrays.asList(getList(acMgr, path).getAccessControlEntries()));
// set policy again.
acMgr.setPolicy(path, acl);
assertEquals("After 'setPolicy' the ACE-removal must be visible to the editing session.", Arrays.asList(acl.getAccessControlEntries()), Arrays.asList(getList(acMgr, path).getAccessControlEntries()));
}