public void testDeregisterOnOutOfScope() { Configuration conf = new Configuration(); ConfigurationManager cm = new ConfigurationManager();
spanReceiverHost = SpanReceiverHost.getInstance(getConfiguration()); this.configurationManager = new ConfigurationManager(); setupWindows(getConfiguration(), getConfigurationManager());
/** * Test if observers get notified by the <code>ConfigurationManager</code> * when the Configuration is reloaded. */ @Test public void testCheckIfObserversNotified() { Configuration conf = new Configuration(); ConfigurationManager cm = new ConfigurationManager(); DummyConfigurationObserver d1 = new DummyConfigurationObserver(cm); // Check if we get notified. cm.notifyAllObservers(conf); assertTrue(d1.wasNotifiedOnChange()); d1.resetNotifiedOnChange(); // Now check if we get notified on change with more than one observers. DummyConfigurationObserver d2 = new DummyConfigurationObserver(cm); cm.notifyAllObservers(conf); assertTrue(d1.wasNotifiedOnChange()); d1.resetNotifiedOnChange(); assertTrue(d2.wasNotifiedOnChange()); d2.resetNotifiedOnChange(); // Now try deregistering an observer and verify that it was not notified d2.deregister(); cm.notifyAllObservers(conf); assertTrue(d1.wasNotifiedOnChange()); d1.resetNotifiedOnChange(); assertFalse(d2.wasNotifiedOnChange()); }
public void testDeregisterOnOutOfScope() { Configuration conf = new Configuration(); ConfigurationManager cm = new ConfigurationManager();
clusterStatusTracker.start(); this.configurationManager = new ConfigurationManager();
/** * Test if observers get notified by the <code>ConfigurationManager</code> * when the Configuration is reloaded. */ @Test public void testCheckIfObserversNotified() { Configuration conf = new Configuration(); ConfigurationManager cm = new ConfigurationManager(); DummyConfigurationObserver d1 = new DummyConfigurationObserver(cm); // Check if we get notified. cm.notifyAllObservers(conf); assertTrue(d1.wasNotifiedOnChange()); d1.resetNotifiedOnChange(); // Now check if we get notified on change with more than one observers. DummyConfigurationObserver d2 = new DummyConfigurationObserver(cm); cm.notifyAllObservers(conf); assertTrue(d1.wasNotifiedOnChange()); d1.resetNotifiedOnChange(); assertTrue(d2.wasNotifiedOnChange()); d2.resetNotifiedOnChange(); // Now try deregistering an observer and verify that it was not notified d2.deregister(); cm.notifyAllObservers(conf); assertTrue(d1.wasNotifiedOnChange()); d1.resetNotifiedOnChange(); assertFalse(d2.wasNotifiedOnChange()); }