Listeners { public void add(L listener) throws TooManyListenersException { try { accessSemaphore.acquire(); } catch(InterruptedException e) { } list.add(listener); accessSemaphore.release(); } Listeners(); void add(L listener); void remove(L listener); void clear(); boolean dispatch(Event event);  }
@Test public void testAdd() throws Exception { listeners.add(new TestListener()); listeners.dispatch(new TestEvent("test")); assertEquals("test", event.getName()); }