for (i = 0; i < NUM_EVENTS; i++) {
events[i] = myGen.generateEvent(evtReg.getID(), 3);
}
RemoteEvent[] bogus = {
new RemoteEvent(myGen, 9999, 9999, null),
new RemoteEvent(myGen, 5678, 1234, null),
};
logger.log(Level.INFO, "Wating for event delivery");
eventCount = NUM_EVENTS;
getCollectedRemoteEvents(tpl, mr, eventCount, MAX_WAIT);
logger.log(Level.INFO, "Verifying event delivery count of " + eventCount);
assertCount(tpl, eventCount);
logger.log(Level.INFO, "Verifying events ");
assertEvents(tpl, events);
if(tpl.verifyEvents(bogus)) {
throw new TestException("Successfully verified bogus events");
}
// Get iterator handle before cancelling associated reg
RemoteEventIterator rei = mr.getRemoteEvents();
logger.log(Level.INFO, "Cancelling registration lease");
mrl.cancel();
logger.log(Level.INFO, "Generating " + NUM_EVENTS + " more events");
try {
for (i = 0; i < NUM_EVENTS; i++) {
events[i] = myGen.generateEvent(evtReg.getID(), 3);
}
} catch (ServerException se) {
if (se.detail != null &&
se.detail instanceof NoSuchObjectException) {
// can safely ignore this since we expect
// that the registration has expired.
logger.log(Level.INFO, "Caught NoSuchObjectException - expected");
} else { throw se; }
}
// Would like to assert that the event count hasn't changed, but
// invoking getRemoteEvents should fail with NSOE, as above.
try {
logger.log(Level.INFO, "Re-cancelling registration lease");
mrl.cancel();
throw new TestException("Successfully cancelled a cancelled registration");
} catch (UnknownLeaseException ule) {
logger.log(Level.INFO, "Caught UnknownLeaseException - expected");
}
try {
logger.log(Level.INFO, "Calling getRemoteEvents on expired reg");
mr.getRemoteEvents();
throw new TestException("Successfully called a cancelled registration");
} catch (NoSuchObjectException nsoe) {
logger.log(Level.INFO, "Caught NoSuchObjectException - expected");
}
try {
logger.log(Level.INFO, "Calling addUnknownEvents on expired reg");
mr.addUnknownEvents(new java.util.ArrayList());
throw new TestException("Successfully called a cancelled registration");
} catch (NoSuchObjectException nsoe) {
logger.log(Level.INFO, "Caught NoSuchObjectException - expected");
}
logger.log(Level.INFO, "Calling next() on expired reg iterator");
RemoteEvent re;
boolean done = false;
int exceptionCount = 0;
while (!done) {
try {
re = rei.next(MAX_WAIT);