use of org.motechproject.event.listener.EventListener in project motech by motech.
the class EventListenerRegistryTest method testRegisterForSameEventTwice.
@Test
public void testRegisterForSameEventTwice() {
List<String> et = new ArrayList<String>();
et.add("org.motechproject.server.someevent");
et.add("org.motechproject.server.someevent");
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.EventListener in project motech by motech.
the class EventListenerRegistryTest method testAddThenRemoveListener.
@Test
public void testAddThenRemoveListener() {
List<String> et = new ArrayList<String>();
et.add("org.motechproject.server.someevent");
EventListener sel = new SampleEventListener();
registry.registerListener(sel, et);
Set<EventListener> el = registry.getListeners("org.motechproject.server.someevent");
assertEquals(1, el.size());
registry.clearListenersForBean("TestEventListener");
el = registry.getListeners("org.motechproject.server.someevent");
assertEquals(0, el.size());
}
use of org.motechproject.event.listener.EventListener in project motech by motech.
the class EventListenerRegistryTest method testRegisterMultipleListener.
@Test
public void testRegisterMultipleListener() {
EventListener sel = new SampleEventListener();
EventListener sel2 = new FooEventListener();
registry.registerListener(sel, "org.motechproject.server.someevent");
registry.registerListener(sel2, "org.motechproject.server.someevent");
Set<EventListener> el = registry.getListeners("org.motechproject.server.someevent");
assertNotNull(el);
assertTrue(el.size() == 2);
assertTrue(el.contains(sel));
assertTrue(el.contains(sel2));
}
use of org.motechproject.event.listener.EventListener in project motech by motech.
the class EventListenerRegistryTest method testAddingWildCardListenerThenRemoving.
@Test
public void testAddingWildCardListenerThenRemoving() {
List<String> et = new ArrayList<String>();
et.add("org.motechproject.server.*");
EventListener sel = new SampleEventListener();
registry.registerListener(sel, et);
Set<EventListener> el = registry.getListeners("org.motechproject.server.someevent.test");
assertEquals(1, el.size());
registry.clearListenersForBean("TestEventListener");
el = registry.getListeners("org.motechproject.server.someevent");
assertEquals(0, el.size());
}
use of org.motechproject.event.listener.EventListener in project motech by motech.
the class EventListenerRegistryTest method testEmptyEventListRegistration.
@Test
public void testEmptyEventListRegistration() throws NoSuchFieldException {
List<String> subjects = new ArrayList<String>();
EventListener sel = new SampleEventListener();
EventListenerTree mockTree = mock(EventListenerTree.class);
PrivateAccessor.setField(registry, "listenerTree", mockTree);
registry.registerListener(sel, subjects);
verify(mockTree, times(0)).addListener(Matchers.<EventListener>anyObject(), anyString());
}
Aggregations