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);
if (re != null) {
logger.log(Level.INFO, "Got RemoteEvent", re);
} else {
throw new TestException(
"Successfully iterated through an expired iter ref");
}
} catch (NoSuchObjectException nsoe) {
logger.log(Level.INFO, "Caught NoSuchObjectException - expected");
done = true;
} catch (RemoteException rex) {
// log and retry
logger.log(Level.INFO, "Caught RemoteException", rex);
if (exceptionCount++ >= 10) {
throw new TestException(
"Too many remote exceptions received");
}
}
}
logger.log(Level.INFO, "Calling close() on expired reg iterator");
rei.close();
try {
logger.log(Level.INFO, "Calling close() again on expired reg iterator");
rei.close();
throw new TestException("Successfully called a close twice");
} catch (InvalidIteratorException iie) {
logger.log(Level.INFO, "Caught InvalidIteratorException - expected");
}