@Test
public void testEventListener() throws Exception {
List<VcCluster> clusters = VcInventory.getClusters();
VcCluster cluster; // Will pick the first cluster.
VcEventListener eventListener = VcContext.getEventListener();
receivedEventCount = 0;
/* GeneralUser is a "fake" event not triggered by any cms vc task. */
VcEventListener.installExtEventHandler(VcEventType.GeneralUser, this);
if (clusters != null && (cluster = clusters.get(0)) != null) {
int eventCount = 1; // Take it easy - can't delete individual events from VC.
AuAssert.check(eventListener != null);
for (int i = 0; i < eventCount; i++ ) {
System.out.println("Posting GeneralUserEvent to cluster: " + cluster.getName());
eventListener.postGeneralUserEvent(cluster, "FakeGeneralUserEvent", "" +
"CMS -> VC GeneralUserEvent", "Administrator");
}
System.out.println("Waiting for GeneralUserEvent");
while (getReceivedEventCount() < eventCount) {
Thread.sleep(100);
}
System.out.println("Event count: " + eventListener.getTotalEventCount());
VcEventListener.removeExtEventHandler(VcEventType.GeneralUser, this);
}
}