use of javax.jcr.observation.Event in project jackrabbit by apache.
the class GetIdentifierTest method testNodeMoved.
public void testNodeMoved() throws RepositoryException {
final Node n = testRootNode.addNode(nodeName1, testNodeType);
testRootNode.getSession().save();
Event[] events = getEvents(new Callable() {
public void call() throws RepositoryException {
superuser.getWorkspace().move(n.getPath(), testRoot + "/" + nodeName2);
}
}, Event.NODE_MOVED);
String path = testRootNode.getNode(nodeName2).getPath();
assertEquals(n.getIdentifier(), getEventByPath(events, path).getIdentifier());
}
use of javax.jcr.observation.Event in project jackrabbit by apache.
the class GetIdentifierTest method testPropertyChanged.
public void testPropertyChanged() throws RepositoryException {
Node n = testRootNode.addNode(nodeName1, testNodeType);
final Property prop = n.setProperty(propertyName1, "test");
testRootNode.getSession().save();
Event[] events = getEvents(new Callable() {
public void call() throws RepositoryException {
prop.setValue("modified");
testRootNode.getSession().save();
}
}, Event.PROPERTY_CHANGED);
assertEquals(n.getIdentifier(), getEventByPath(events, prop.getPath()).getIdentifier());
}
use of javax.jcr.observation.Event in project jackrabbit by apache.
the class GetInfoTest method testNodeRemoved.
public void testNodeRemoved() throws RepositoryException {
final Node n = testRootNode.addNode(nodeName1, testNodeType);
testRootNode.getSession().save();
Event[] events = getEvents(new Callable() {
public void call() throws RepositoryException {
n.remove();
testRootNode.getSession().save();
}
}, Event.NODE_REMOVED);
for (int i = 0; i < events.length; i++) {
Set<?> unexpectedKeys = getUnexpectedKeys(events[i].getInfo());
assertEquals("info map must be empty", 0, unexpectedKeys.size());
}
}
use of javax.jcr.observation.Event in project jackrabbit by apache.
the class GetInfoTest method testPropertyRemoved.
public void testPropertyRemoved() throws RepositoryException {
Node n = testRootNode.addNode(nodeName1, testNodeType);
final Property prop = n.setProperty(propertyName1, "test");
testRootNode.getSession().save();
Event[] events = getEvents(new Callable() {
public void call() throws RepositoryException {
Session s = prop.getSession();
prop.remove();
s.save();
}
}, Event.PROPERTY_REMOVED);
for (int i = 0; i < events.length; i++) {
Set<?> unexpectedKeys = getUnexpectedKeys(events[i].getInfo());
assertEquals("info map must be empty: " + unexpectedKeys, 0, unexpectedKeys.size());
}
}
use of javax.jcr.observation.Event in project jackrabbit by apache.
the class EventJournalTest method testPersist.
public void testPersist() throws RepositoryException, NotExecutableException {
Node n1 = testRootNode.addNode(nodeName1);
journal = getEventJournal(Event.PERSIST, testRoot, true, null, null);
skipToNow();
superuser.save();
boolean hasPersistEvents = journal.hasNext();
if (!hasPersistEvents) {
throw new NotExecutableException("repository does not appear to provide PERSIST events");
}
journal = getEventJournal(ALL_TYPES | Event.PERSIST, testRoot, true, null, null);
skipToNow();
// add another child node
Node n3 = testRootNode.addNode(nodeName2);
String target = n1.getPath();
n1.remove();
superuser.save();
// move it
superuser.getWorkspace().move(n3.getPath(), target);
// remove it again
n3 = superuser.getNode(target);
n3.remove();
superuser.save();
int persistCount = 0;
Event e = null;
while (journal.hasNext()) {
e = journal.nextEvent();
if (e.getType() == Event.PERSIST) {
persistCount += 1;
}
}
assertEquals(3, persistCount);
// last event should be persist
assertEquals(Event.PERSIST, e.getType());
}
Aggregations