in src/main/java/org/apache/sling/commons/testing/jcr/EventHelper.java [63:84]
public void waitForEvents(long timeoutMsec) throws RepositoryException {
final int targetEventCount = eventCount + 1;
if(waitNodeFolder.hasNode(WAIT_NODE_NODE)) {
waitNodeFolder.getNode(WAIT_NODE_NODE).remove();
} else {
waitNodeFolder.addNode(WAIT_NODE_NODE);
}
session.save();
final long end = System.currentTimeMillis() + timeoutMsec;
while(eventCount < targetEventCount && System.currentTimeMillis() < end) {
try {
Thread.sleep(100);
} catch(InterruptedException ignored) {
}
}
if(eventCount < targetEventCount) {
throw new IllegalStateException("Event counter did not reach " + targetEventCount + ", waited " + timeoutMsec + " msec");
}
}