use of org.apache.jackrabbit.test.api.observation.EventResult in project jackrabbit by apache.
the class VersionEventsTest method testXACheckin.
/**
* Test if checkin of a node in an XA transaction creates two add node
* events: one for the version and one for the frozen node.
*/
public void testXACheckin() throws Exception {
// create versionable node
Node n1 = testRootNode.addNode(nodeName1);
n1.addMixin(mixVersionable);
testRootNode.save();
EventResult listener = new EventResult(log);
addEventListener(listener, Event.NODE_ADDED);
// use a transaction
UserTransaction utx = new UserTransactionImpl(superuser);
// start transaction
utx.begin();
Version v = n1.checkin();
// commit transaction
utx.commit();
removeEventListener(listener);
Event[] events = listener.getEvents(1000);
Set paths = new HashSet();
for (int i = 0; i < events.length; i++) {
paths.add(events[i].getPath());
}
assertTrue("missing 'node added' event: " + v.getPath(), paths.contains(v.getPath()));
String frozenPath = v.getPath() + "/" + jcrFrozenNode;
assertTrue("missing 'node added' event: " + frozenPath, paths.contains(frozenPath));
}
use of org.apache.jackrabbit.test.api.observation.EventResult in project jackrabbit by apache.
the class JackrabbitObservationManagerTest method testDisjunctPaths.
public void testDisjunctPaths() throws ExecutionException, InterruptedException, RepositoryException {
JackrabbitObservationManager oManager = (JackrabbitObservationManager) obsMgr;
EventResult listener = new EventResult(log);
JackrabbitEventFilter filter = new JackrabbitEventFilter().setAdditionalPaths('/' + testPath + "/a", '/' + testPath + "/x").setEventTypes(NODE_ADDED);
oManager.addEventListener(listener, filter);
try {
Node b = testRootNode.addNode("a").addNode("b");
b.addNode("c");
Node y = testRootNode.addNode("x").addNode("y");
y.addNode("z");
testRootNode.getSession().save();
Event[] added = listener.getEvents(DEFAULT_WAIT_TIMEOUT);
checkNodeAdded(added, new String[] { "a/b", "x/y" }, null);
} finally {
oManager.removeEventListener(listener);
}
}
use of org.apache.jackrabbit.test.api.observation.EventResult in project jackrabbit by apache.
the class MixinTest method testSingleMixin.
/**
* Tests event filtering with a single mixin type name.
*/
public void testSingleMixin() throws RepositoryException {
testRootNode.addNode(nodeName1, testNodeType).addMixin(mixReferenceable);
testRootNode.addNode(nodeName2, testNodeType);
testRootNode.addNode(nodeName3, testNodeType).addMixin(mixReferenceable);
testRootNode.save();
EventResult propertyAddedListener = new EventResult(log);
addEventListener(propertyAddedListener, new String[] { mixReferenceable }, Event.PROPERTY_ADDED);
try {
testRootNode.getNode(nodeName1).setProperty(propertyName1, "test");
testRootNode.getNode(nodeName2).setProperty(propertyName1, "test");
testRootNode.getNode(nodeName3).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 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);
}
}
Aggregations