AbstractThreadedObservablePlugin extends AbstractObservablePlugin { @Override public final void removeObserver(final ObservablePlugin.PluginObserver observer) { super.removeObserver(observer); if (countObservers() == 0) { if (logger.isDebugEnabled()) { logger.debug("Stop the plugin monitoring."); } if (thread != null) { thread.end(); } } } protected  AbstractThreadedObservablePlugin(String name); @Override final void addObserver(final ObservablePlugin.PluginObserver observer); @Override final void removeObserver(final ObservablePlugin.PluginObserver observer); @Override final void clearObservers();  }
@Test public void removeObserver() throws Throwable { MockAbstractThreadedPlugin plugin = new MockAbstractThreadedPlugin("addObserverTest"); ObservablePlugin.PluginObserver obs = getOneObserver(); plugin.addObserver(obs); plugin.removeObserver(obs); Assert.assertEquals(0, plugin.countObservers()); Assert.assertFalse(plugin.isMonitoring()); plugin.finalize(); }