public void testRemoveListener() { Listen ln = new Listen(); t.addPropertyChangeListener(ln); t.removePropertyChangeListener(ln); listenerResult = false; t.setUserName("user id"); Assert.assertTrue( "listener should not have heard message after removeListner", !listenerResult); }
/** * Deactivates a LightControl by control type. This method tests the control type, and deactivates * the control mechanism, appropriate for the control type. */ public void deactivateLightControl() { // skip if Light Control is not active if (_active) { // deactivate according to control type switch (_controlType) { case Light.SENSOR_CONTROL: if (_sensorListener != null) { _namedControlSensor.getBean().removePropertyChangeListener(_sensorListener); _sensorListener = null; } break; case Light.FAST_CLOCK_CONTROL: if ((_clock != null) && (_timebaseListener != null)) { _clock.removeMinuteChangeListener(_timebaseListener); _timebaseListener = null; } break; case Light.TURNOUT_STATUS_CONTROL: if (_turnoutListener != null) { _controlTurnout.removePropertyChangeListener(_turnoutListener); _turnoutListener = null; } break; case Light.TIMED_ON_CONTROL: if (_timedSensorListener != null) { _namedTimedControlSensor.getBean().removePropertyChangeListener(_timedSensorListener); _timedSensorListener = null; } if (_lightOnTimerActive) { _timedControlTimer.stop(); _lightOnTimerActive = false; } if (_timedControlTimer != null) { if (_timedControlListener != null) { _timedControlTimer.removeActionListener(_timedControlListener); _timedControlListener = null; } _timedControlTimer = null; } break; case Light.TWO_SENSOR_CONTROL: if (_sensorListener != null) { _namedControlSensor.getBean().removePropertyChangeListener(_sensorListener); _sensorListener = null; } if (_sensor2Listener != null) { _namedControlSensor2.getBean().removePropertyChangeListener(_sensor2Listener); _sensor2Listener = null; } break; default: log.warn( "Unexpected control type when activating Light: " + _parentLight.getSystemName()); } _active = false; } }