logger.log(Level.INFO, "Sent events {0}", generatedEvents);
expectedEventCount += NUM_EVENTS;
// Get events and verify
logger.log(Level.INFO, "Getting events.");
RemoteEventIterator rei = mr.getRemoteEvents();
ArrayList receivedEvents = new ArrayList();
RemoteEvent rei_event;
while ((rei_event = rei.next(MAX_WAIT)) != null) {
receivedEvents.add(rei_event);
}
logger.log(Level.INFO, "Received events {0}", receivedEvents);
logger.log(Level.INFO, "Verifying received events");
assertEvents(generatedEvents, receivedEvents);
if (receivedEvents.size() != expectedEventCount) {
throw new TestException("Received " + receivedEvents.size()
+ " events, but expected " + expectedEventCount);
}
// Set myGen events as unknown events
logger.log(Level.INFO, "Calling addUnknownEvents");
mr.addUnknownEvents(java.util.Arrays.asList(genEvents));
// Send some myGen events -- should be rejected
int exceptionCount = 0;
logger.log(Level.INFO, "Generating some unknown events");
for (i = 0; i < NUM_EVENTS; i++) {
try {
genEvents[i] = myGen.generateEvent(evtReg.getID(), 3);
} catch (UnknownEventException uue) {
exceptionCount++;
logger.log(Level.INFO, "Caught expected exception -- ignoring",
uue);
}
}
if (exceptionCount != NUM_EVENTS) {
throw new TestException("Unexpected number of exceptions "
+ exceptionCount);
}
//Verify that events weren't delivered
RemoteEvent re = null;
if ((re = rei.next(MAX_WAIT)) != null) {
throw new TestException("Unexpected event received " + re);
}
logger.log(Level.INFO, "Did not receive any unknown events");
// Generate some myGen2 events -- should be accepted
logger.log(Level.INFO, "Generating " + NUM_EVENTS + " events");
for (i = 0; i < NUM_EVENTS; i++) {
generatedEvents.add(myGen2.generateEvent(evtReg2.getID(), 3));
}
expectedEventCount += NUM_EVENTS;
logger.log(Level.INFO, "Sent events {0}", generatedEvents);
while ((rei_event = rei.next(MAX_WAIT)) != null) {
receivedEvents.add(rei_event);
}
logger.log(Level.INFO, "Received events {0}", receivedEvents);
logger.log(Level.INFO, "Verifying received events");
assertEvents(generatedEvents, receivedEvents);
if (receivedEvents.size() != expectedEventCount) {
throw new TestException("Received " + receivedEvents.size()
+ " events, but expected " + expectedEventCount);
}
//
// Kill event mailbox service
//
logger.log(Level.INFO, "Killing mailbox service");
shutdown(0);
// Send some myGen events -- should be rejected
exceptionCount = 0;
logger.log(Level.INFO, "Generating some more unknown events");
for (i = 0; i < NUM_EVENTS; i++) {
try {
genEvents[i] = myGen.generateEvent(evtReg.getID(), 3);
} catch (UnknownEventException uue) {
exceptionCount++;
logger.log(Level.INFO, "Caught expected exception -- ignoring",
uue);
}
}
if (exceptionCount != NUM_EVENTS) {
throw new TestException("Unexpected number of exceptions "
+ exceptionCount);
}
//Verify that events weren't delivered
re = null;
if ((re = rei.next(MAX_WAIT)) != null) {
throw new TestException("Unexpected event received " + re);
}
logger.log(Level.INFO, "Did not receive any unknown events");
// Get new iter -- should clear unknown event list
logger.log(Level.INFO, "Getting new remote event iterator.");
rei = mr.getRemoteEvents();
re = null;
if ((re = rei.next(MAX_WAIT)) != null) {
throw new TestException("Unexpected event received " + re);
}
logger.log(Level.INFO, "Did not receive any unknown events");
//
// Kill event mailbox service
//
logger.log(Level.INFO, "Killing mailbox service");
shutdown(0);
// Generate some myGen events -- should be accepted now
logger.log(Level.INFO, "Generating " + NUM_EVENTS + " events");
for (i = 0; i < NUM_EVENTS; i++) {
generatedEvents.add(myGen.generateEvent(evtReg.getID(), 3));
}
logger.log(Level.INFO, "Sent events {0}", generatedEvents);
expectedEventCount += NUM_EVENTS;
while ((rei_event = rei.next(MAX_WAIT)) != null) {
receivedEvents.add(rei_event);
}
logger.log(Level.INFO, "Received events {0}", receivedEvents);
logger.log(Level.INFO, "Verifying received events");