@Override
public void onEvent(EventIterator events) {
try {
while (events.hasNext()) {
Event event = events.nextEvent();
if (event.getType() == Event.NODE_ADDED) {
numAdded++;
if (!observingSession.nodeExists(event.getPath())) {
error = "node missing: " + event.getPath();
}
}
if (event.getType() == Event.NODE_REMOVED) {
numRemoved++;
if (observingSession.nodeExists(event.getPath())) {
error = "node not missing: " + event.getPath();
}
}
if (event.getType() == Event.PROPERTY_ADDED) {
Node node = observingSession.getNode(Text.getRelativeParent(event.getPath(), 1));
PropertyIterator iter = node.getProperties();
boolean ok = false;
while (iter.hasNext()) {
Property p = iter.nextProperty();
if (p.getPath().equals(event.getPath())) {
ok = true;
}
}
if (!ok) {
error = "property missing: " + event.getPath();
}
String name = Text.getName(event.getPath());
if ("test100".equals(name)) {
test100Exists = true;
} else {
numPropsAdded++;
if (!observingSession.propertyExists(event.getPath())) {
error = "property missing: " + event.getPath();
}
}
}
if (event.getType() == Event.PROPERTY_REMOVED) {
String name = Text.getName(event.getPath());
if ("test100".equals(name)) {
test100Exists = false;
} else {
numPropsRemoved++;
if (observingSession.propertyExists(event.getPath())) {
error = "property not missing: " + event.getPath();
}
}
}
if (event.getType() == Event.PROPERTY_CHANGED) {
String name = Text.getName(event.getPath());
if ("test100".equals(name)) {
} else {
numPropsModified++;
long v = observingSession.getProperty(event.getPath()).getLong();
if (v != Long.valueOf(Text.getName(name).substring(4))) {
error = "property has wrong content: " + event.getPath();
}
}
}
}
} catch (Exception e) {