use of org.motechproject.event.domain.TrackingListener in project motech by motech.
the class ServerEventRelayBundleIT method shouldTriggerAllListenersIfOneListenerFailsWhenRelyingTopicEvent.
@Test
public void shouldTriggerAllListenersIfOneListenerFailsWhenRelyingTopicEvent() throws InterruptedException {
TrackingListener buggyListener = new BuggyListener(1);
TrackingListener firstGoodListener = new TrackingListener("first");
TrackingListener secondGoodListener = new TrackingListener("second");
eventListenerRegistry.registerListener(buggyListener, EXCEPTION_HANDLING_TEST);
eventListenerRegistry.registerListener(firstGoodListener, EXCEPTION_HANDLING_TEST);
eventListenerRegistry.registerListener(secondGoodListener, EXCEPTION_HANDLING_TEST);
MotechEvent testMessage = new MotechEvent(EXCEPTION_HANDLING_TEST);
eventRelay.broadcastEventMessage(testMessage);
while (buggyListener.getCount() < 2) {
Thread.sleep(1000);
}
Thread.sleep(2000);
assertEquals(firstGoodListener.getCount(), 1);
assertEquals(secondGoodListener.getCount(), 1);
}
use of org.motechproject.event.domain.TrackingListener in project motech by motech.
the class ServerEventRelayBundleIT method shouldNotTriggerAllListenersWhenOneListenerFails.
@Test
public void shouldNotTriggerAllListenersWhenOneListenerFails() throws InterruptedException {
TrackingListener buggyListener = new BuggyListener(1);
TrackingListener firstGoodListener = new TrackingListener("first");
TrackingListener secondGoodListener = new TrackingListener("second");
eventListenerRegistry.registerListener(buggyListener, EXCEPTION_HANDLING_TEST);
eventListenerRegistry.registerListener(firstGoodListener, EXCEPTION_HANDLING_TEST);
eventListenerRegistry.registerListener(secondGoodListener, EXCEPTION_HANDLING_TEST);
MotechEvent testMessage = new MotechEvent(EXCEPTION_HANDLING_TEST);
eventRelay.sendEventMessage(testMessage);
while (buggyListener.getCount() < 2) {
Thread.sleep(3000);
}
assertTrue(buggyListener.getCount() > 1);
Thread.sleep(2000);
assertEquals(1, firstGoodListener.getCount());
assertEquals(1, secondGoodListener.getCount());
}
Aggregations