// withdraw the READ privilege
Privilege[] dnPrivs = privilegesFromName(Privilege.JCR_READ);
withdrawPrivileges(path, dnPrivs, getRestrictions(superuser, path));
// testUser registers a eventlistener for 'path
ObservationManager obsMgr = testSession.getWorkspace().getObservationManager();
EventResult listener = new EventResult(((JUnitTest) this).log);
try {
obsMgr.addEventListener(listener, Event.NODE_REMOVED, path, true, new String[0], new String[0], true);
// superuser removes the node with childNPath in order to provoke
// events being generated
superuser.getItem(childNPath).remove();
superuser.save();
obsMgr.removeEventListener(listener);
// since the testUser does not have read-permission on the removed
// node, no corresponding event must be generated.
Event[] evts = listener.getEvents(DEFAULT_WAIT_TIMEOUT);
for (int i = 0; i < evts.length; i++) {
if (evts[i].getType() == Event.NODE_REMOVED &&
evts[i].getPath().equals(childNPath)) {
fail("TestUser does not have READ permission below " + path + " -> events below must not show up.");
}
}
} finally {
obsMgr.removeEventListener(listener);
}
}