events[i] = myGen.generateEvent(evtReg.getID(), 3);
}
myRelCount += NUM_EVENTS;
RemoteEvent[] bogus = {
new RemoteEvent(myGen, 9999, 9999, null),
new RemoteEvent(myGen2, 1234, 1, null),
};
// Enable the first of our listener objects
assertCount(myRel, 0);
logger.log(Level.INFO, "Enabling delivery to our REL" + myRel);
mr.enableDelivery(myRel);
// Wait for events to arrive and verify
logger.log(Level.INFO, "Wating for event delivery");
waitForEvents(myRel, myRelCount, MAX_WAIT);
logger.log(Level.INFO, "Verifying event delivery");
assertCount(myRel, myRelCount);
assertEvents(myRel, events);
if (myRel.verifyEvents(bogus)) {
throw new TestException("Successfully verified bogus events");
}
// Re-submit listener again
logger.log(Level.INFO, "Re-enabling delivery to our REL");
mr.enableDelivery(myRel);
logger.log(Level.INFO, "Verifying event delivery");
assertCount(myRel, myRelCount);
// Generate some more events
for (i = 0; i < NUM_EVENTS; i++) {
events[i] = myGen.generateEvent(evtReg.getID(), 3);
}
myRelCount += NUM_EVENTS;
waitForEvents(myRel, myRelCount, MAX_WAIT);
logger.log(Level.INFO, "Verifying event delivery");
assertCount(myRel, myRelCount);
assertEvents(myRel, events);
// enable second listener object
logger.log(Level.INFO, "Enabling delivery to our REL2" + myRel2);
mr.enableDelivery(myRel2);
assertCount(myRel2, myRelCount2);
// Generate some more events
for (i = 0; i < NUM_EVENTS; i++) {
events[i] = myGen.generateEvent(evtReg.getID(), 3);
}
myRelCount2 += NUM_EVENTS;
// Wait for events to arrive and verify
logger.log(Level.INFO, "Wating for event delivery");
waitForEvents(myRel2, myRelCount2, MAX_WAIT);
logger.log(Level.INFO, "Verifying event delivery");
assertCount(myRel2, myRelCount2);
assertEvents(myRel2, events);
// Generate some more events from second generator
for (i = 0; i < NUM_EVENTS; i++) {
events[i] = myGen2.generateEvent(evtReg2.getID(), 3);
}
myRelCount2 += NUM_EVENTS;
// Wait for events to arrive and verify
logger.log(Level.INFO, "Wating for event delivery");
waitForEvents(myRel2, myRelCount2, MAX_WAIT);
logger.log(Level.INFO, "Verifying event delivery");
assertCount(myRel2, myRelCount2);
assertEvents(myRel2, events);
// disable delivery
mr.disableDelivery();
assertCount(myRel, myRelCount);
assertCount(myRel2, myRelCount2);
logger.log(Level.INFO, "Disabled delivery");
// Generate some more events from each generator
logger.log(Level.INFO, "Generating more events");
for (i = 0; i < NUM_EVENTS; i++) {
events[i] = myGen.generateEvent(evtReg.getID(), 3);
}
RemoteEvent[] events2 = new RemoteEvent[NUM_EVENTS];
for (i = 0; i < NUM_EVENTS; i++) {
events2[i] = myGen2.generateEvent(evtReg2.getID(), 3);
}
logger.log(Level.INFO, "Verifying that event counts haven't changed");
assertCount(myRel, myRelCount);
assertCount(myRel2, myRelCount2);
logger.log(Level.INFO, "enabling delivery to REL");
mr.enableDelivery(myRel);
myRelCount += NUM_EVENTS*2;
// Wait for events to arrive and verify
logger.log(Level.INFO, "Wating for event delivery");
waitForEvents(myRel, myRelCount, MAX_WAIT);
logger.log(Level.INFO, "Verifying event delivery");
assertCount(myRel, myRelCount);
assertEvents(myRel, events);
assertEvents(myRel, events2);
// Submit the null listener
logger.log(Level.INFO, "Calling enableDelivery(null)");
mr.enableDelivery(null);
logger.log(Level.INFO, "Asserting that event counts haven't changed");
assertCount(myRel, myRelCount);
assertCount(myRel2, myRelCount2);
// Generate another event
logger.log(Level.INFO, "Generating another event");
RemoteEvent evt = myGen.generateEvent(evtReg.getID(), 3);
logger.log(Level.INFO, "Asserting that event counts haven't changed");
assertCount(myRel, myRelCount);
assertCount(myRel2, myRelCount2);
logger.log(Level.INFO, "Enabling REL2");
myRelCount2 += 1;
mr.enableDelivery(myRel2);
logger.log(Level.INFO, "Wating for event delivery");
waitForEvents(myRel2, myRelCount2, MAX_WAIT);
logger.log(Level.INFO, "Asserting event counts ");
assertCount(myRel2, myRelCount2);
assertEvent(myRel2, evt);
assertCount(myRel, myRelCount);
logger.log(Level.INFO, "Disabling delivery");
mr.disableDelivery();
logger.log(Level.INFO, "Asserting event counts ");
assertCount(myRel, myRelCount);
assertCount(myRel2, myRelCount2);
// Generate another event
logger.log(Level.INFO, "Generating another event");
evt = myGen.generateEvent(evtReg.getID(), 3);
logger.log(Level.INFO, "Disabling delivery again");
mr.disableDelivery();
logger.log(Level.INFO, "Asserting event counts ");
assertCount(myRel, myRelCount);
assertCount(myRel2, myRelCount2);
// Generate another event
logger.log(Level.INFO, "Generating another event");
RemoteEvent evt2 = myGen2.generateEvent(evtReg2.getID(), 3);
assertCount(myRel, myRelCount);
assertCount(myRel2, myRelCount2);
logger.log(Level.INFO, "Enabling REL2 ");
mr.enableDelivery(myRel2);