use of org.apache.jackrabbit.test.api.observation.EventResult in project jackrabbit by apache.
the class MixinTest method testDerivedMixin.
/**
* Checks if an event listener registered for a mixin type T also gets
* notifications for an event on a node with a mixin type which is derived
* from T.
*/
public void testDerivedMixin() throws RepositoryException {
Node node1 = testRootNode.addNode(nodeName1, testNodeType);
node1.addMixin(mixVersionable);
testRootNode.save();
EventResult propertyAddedListener = new EventResult(log);
// mix:versionable is derived from mix:referenceable
addEventListener(propertyAddedListener, new String[] { mixReferenceable }, Event.PROPERTY_ADDED);
try {
node1.setProperty(propertyName1, "test");
testRootNode.save();
Event[] added = propertyAddedListener.getEvents(DEFAULT_WAIT_TIMEOUT);
checkPropertyAdded(added, new String[] { nodeName1 + "/" + propertyName1 });
} finally {
removeEventListener(propertyAddedListener);
}
}
use of org.apache.jackrabbit.test.api.observation.EventResult in project jackrabbit by apache.
the class MixinTest method testMultipleMixinOnNode.
/**
* Tests event filtering on nodes with multiple mixins applied.
*/
public void testMultipleMixinOnNode() throws RepositoryException {
Node node1 = testRootNode.addNode(nodeName1, testNodeType);
node1.addMixin(mixReferenceable);
node1.addMixin(mixLockable);
Node node2 = testRootNode.addNode(nodeName2, testNodeType);
Node node3 = testRootNode.addNode(nodeName3, testNodeType);
node3.addMixin(mixLockable);
node3.addMixin(mixReferenceable);
testRootNode.save();
EventResult propertyAddedListener = new EventResult(log);
addEventListener(propertyAddedListener, new String[] { mixReferenceable }, Event.PROPERTY_ADDED);
try {
node1.setProperty(propertyName1, "test");
node2.setProperty(propertyName1, "test");
node3.setProperty(propertyName1, "test");
testRootNode.save();
Event[] added = propertyAddedListener.getEvents(DEFAULT_WAIT_TIMEOUT);
checkPropertyAdded(added, new String[] { nodeName1 + "/" + propertyName1, nodeName3 + "/" + propertyName1 });
} finally {
removeEventListener(propertyAddedListener);
}
}
use of org.apache.jackrabbit.test.api.observation.EventResult in project jackrabbit by apache.
the class ShareableNodesTest method testRemoveShare.
public void testRemoveShare() throws RepositoryException {
Node n1 = testRootNode.addNode(nodeName1);
Node n2 = testRootNode.addNode(nodeName2);
Node s = n1.addNode(nodeName3);
s.addMixin(mixShareable);
testRootNode.save();
Workspace wsp = superuser.getWorkspace();
wsp.clone(wsp.getName(), s.getPath(), n2.getPath() + "/" + s.getName(), false);
EventResult result = new EventResult(log);
addEventListener(result);
removeFromSharedSet(n2.getNode(nodeName3));
testRootNode.save();
checkNodeRemoved(result.getEvents(DEFAULT_WAIT_TIMEOUT), new String[] { nodeName2 + "/" + nodeName3 }, new String[0]);
}
use of org.apache.jackrabbit.test.api.observation.EventResult in project jackrabbit by apache.
the class ShareableNodesTest method testAddShare.
public void testAddShare() throws RepositoryException {
Node n1 = testRootNode.addNode(nodeName1);
Node n2 = testRootNode.addNode(nodeName2);
Node s = n1.addNode(nodeName3);
s.addMixin(mixShareable);
testRootNode.save();
EventResult result = new EventResult(log);
addEventListener(result);
Workspace wsp = superuser.getWorkspace();
wsp.clone(wsp.getName(), s.getPath(), n2.getPath() + "/" + s.getName(), false);
checkNodeAdded(result.getEvents(DEFAULT_WAIT_TIMEOUT), new String[] { nodeName2 + "/" + nodeName3 }, new String[0]);
}
use of org.apache.jackrabbit.test.api.observation.EventResult in project jackrabbit by apache.
the class JackrabbitNodeTest method testRenameEventHandling.
public void testRenameEventHandling() throws RepositoryException {
Session s = getHelper().getSuperuserSession();
ObservationManager mgr = s.getWorkspace().getObservationManager();
EventResult result = new EventResult(log);
try {
mgr.addEventListener(result, Event.PERSIST | Event.NODE_ADDED | Event.NODE_MOVED | Event.NODE_REMOVED, testRootNode.getPath(), true, null, null, false);
NodeIterator it = testRootNode.getNodes();
Node n = it.nextNode();
String name = n.getName();
JackrabbitNode node = (JackrabbitNode) n;
node.rename(name.toUpperCase());
superuser.save();
boolean foundMove = false;
for (Event event : result.getEvents(5000)) {
if (Event.NODE_MOVED == event.getType()) {
foundMove = true;
break;
}
}
if (!foundMove) {
fail("Expected NODE_MOVED event upon renaming a node.");
}
} finally {
mgr.removeEventListener(result);
s.logout();
}
}
Aggregations