addLease(er.getLease(), false);
logger.log(Level.INFO, "Generating some events");
for (i = 0; i < NUM_EVENTS; i++) {
addLease(space.write(new Name("Duh"), null, DURATION), false);
}
//Note: JavaSpaces is allowed to compact event notifications.
// That is, if more than one event is scheduled to be delivered
// for the same notification target, then the one with the latest
// sequence number can be sent (alone). Therefore, for
// NUM_EVENTS > 1, you'll need to add some sort of delay factor
// in order to prevent multiple notifications from beng queue'd
// up together on the space side of the house.
logger.log(Level.INFO, "Checking event count befor enabling");
int eventCount = 0;
assertCount(listener, eventCount);
logger.log(Level.INFO, "Enabling delivery");
mr.enableDelivery(listener);
eventCount += NUM_EVENTS;
logger.log(Level.INFO, "Waiting for event delivery");
waitForEvents(listener, eventCount, MAX_WAIT);
logger.log(Level.INFO, "Verifying event delivery");
assertCount(listener, eventCount);
logger.log(Level.INFO, "Generating some more events");
for (i = 0; i < NUM_EVENTS; i++) {
addLease(space.write(new Name("Yah"), null, DURATION), false);
}
eventCount += NUM_EVENTS;
logger.log(Level.INFO, "Waiting for event delivery");
waitForEvents(listener, eventCount, MAX_WAIT);
logger.log(Level.INFO, "Verifying event delivery");
assertCount(listener, eventCount);
shutdown(0); // Mailbox is at index 0;
logger.log(Level.INFO, "Generating some more events");
for (i = 0; i < NUM_EVENTS; i++) {
addLease(space.write(new Name("Yah"), null, DURATION), false);
}
eventCount += NUM_EVENTS;
logger.log(Level.INFO, "Waiting for event delivery");
waitForEvents(listener, eventCount, MAX_WAIT);