Assert.assertNotNull(testManager);
SLAThresholdEventProducer service =
(SLAThresholdEventProducer)testManager.waitForService(SLAThresholdEventProducer.class);
EventDescriptor eDesc = SLAThresholdEvent.getEventDescriptor();
Assert.assertNotNull(service);
DynamicEventConsumer eventConsumer = null;
Throwable t = null;
try {
eventConsumer = new DynamicEventConsumer(eDesc,
testManager.getServiceDiscoveryManager().getDiscoveryManager());
} catch (Exception e) {
t = e;
e.printStackTrace();
}
Assert.assertNull(t);
Assert.assertNotNull(eventConsumer);
Listener listener = new Listener();
eventConsumer.register(listener);
int waitCount = 0;
while(!listener.upperBreachNotification() && waitCount<10) {
try {
service.increment();
Thread.sleep(500);
waitCount++;
} catch (Exception e) {
t = e;
e.printStackTrace();
}
}
Assert.assertNull(t);
Assert.assertTrue(listener.upperBreachNotification());
t = null;
waitCount = 0;
while(!listener.lowerBreachNotification() && waitCount<10) {
try {
service.decrement();
Thread.sleep(500);
waitCount++;
} catch (Exception e) {
t = e;
e.printStackTrace();
}
}
Assert.assertNull(t);
Assert.assertTrue(listener.lowerBreachNotification());
eventConsumer.terminate();
}