PluginableElementsContainer { public void removeElement(T element) { synchronized (elements) { elements.remove(element.getPluginableId()); } synchronized (listeners) { for (PluginableElementEventListener l : listeners) { l.elementRemoved(element); } } } PluginableElementsContainer();  PluginableElementsContainer(Collection<T> e); Collection<T> getElements(); T getElement(String pluginableId); boolean contains(T element); void addElement(T element); void addListener(PluginableElementEventListener<T> listener); void removeListener(PluginableElementEventListener<T> listener); void removeElement(T element); void changeElement(T element);  }
@Test public void testRemoveElement() { PluginableListener listener = new PluginableListener(); container.addListener(listener); PluginableClass p1 = new PluginableClass(); container.addElement(p1); AssertJUnit.assertTrue(listener.added); Collection<PluginableClass> elements = container.getElements(); AssertJUnit.assertEquals(1, elements.size()); container.removeElement(p1); AssertJUnit.assertTrue(listener.removed); elements = container.getElements(); AssertJUnit.assertEquals(0, elements.size()); }