EventListenerTree { public void removeAllListeners(String beanName) { for (Iterator<EventListenerTree> listenerIterator = children.iterator(); listenerIterator.hasNext();) { EventListenerTree child = listenerIterator.next(); if (child.removeListeners(beanName) && child.removeEmptyChildWithWildcardListeners()) { listenerIterator.remove(); } } } EventListenerTree();  EventListenerTree(String pathElement, EventListenerTree parent); String getPathElement(); String getSubject(); void addListener(EventListener listener, String subject); Set<EventListener> getListeners(String subject); boolean hasListener(String subject); int getListenerCount(String subject); void removeAllListeners(String beanName);  }
@Test public void testRemoveAllListeners() { tree.addListener(new FooEventListener(), SUBJECT_1); tree.addListener(new FooEventListener(), SUBJECT_2); assertEquals(1, tree.getListenerCount(SUBJECT_1)); assertEquals(1, tree.getListenerCount(SUBJECT_2)); tree.removeAllListeners("FooEventListener"); assertEquals(0, tree.getListenerCount(SUBJECT_1)); assertEquals(0, tree.getListenerCount(SUBJECT_2)); }