use of org.motechproject.event.listener.SampleEventListener in project motech by motech.
the class EventListenerRegistryTest method testHasListener_YesWildcard.
@Test
public void testHasListener_YesWildcard() {
registry.registerListener(new SampleEventListener(), "org.motechproject.server.*");
assertTrue(registry.hasListener("org.motechproject.server.someevent"));
}
use of org.motechproject.event.listener.SampleEventListener in project motech by motech.
the class EventListenerRegistryTest method testHasListener_No.
@Test
public void testHasListener_No() {
registry.registerListener(new SampleEventListener(), "org.motechproject.server.someevent");
assertFalse(registry.hasListener("org.motechproject.client.otherevent"));
}
use of org.motechproject.event.listener.SampleEventListener in project motech by motech.
the class EventListenerRegistryTest method testRegisterForMultipleEvents.
@Test
public void testRegisterForMultipleEvents() {
List<String> et = new ArrayList<String>();
et.add("org.motechproject.server.someevent");
et.add("org.motechproject.server.someotherevent");
EventListener sel = new SampleEventListener();
registry.registerListener(sel, et);
Set<EventListener> el = registry.getListeners(et.get(0));
assertNotNull(el);
assertTrue(el.size() == 1);
assertTrue(el.contains(sel));
el = registry.getListeners(et.get(1));
assertNotNull(el);
assertTrue(el.size() == 1);
assertTrue(el.contains(sel));
}
use of org.motechproject.event.listener.SampleEventListener in project motech by motech.
the class EventListenerRegistryTest method testRemovingListenerPreservesOtherListeners.
@Test
public void testRemovingListenerPreservesOtherListeners() {
List<String> et = new ArrayList<String>();
et.add("org.motechproject.server.someevent");
EventListener sel = new SampleEventListener();
EventListener se2 = new OtherSampleEventListener();
registry.registerListener(sel, et);
registry.registerListener(se2, et);
Set<EventListener> el = registry.getListeners("org.motechproject.server.someevent");
assertEquals(2, el.size());
registry.clearListenersForBean("TestEventListener");
el = registry.getListeners("org.motechproject.server.someevent");
assertEquals(1, el.size());
registry.clearListenersForBean("TestEventListener2");
el = registry.getListeners("org.motechproject.server.someevent");
assertEquals(0, el.size());
}
Aggregations