Code example for PropertyChangeSupport

Methods: addPropertyChangeListener, firePropertyChange, getPropertyChangeListeners, removePropertyChangeListener

0
     * Test the method removePropertyChangeListener(PropertyChangeListener, 
     * String) when a listener for all properties has been registered. 
     */ 
    public void testRemovePropertyChangeListener_PropertyChangeListener_String_AllRegistered() { 
        Object src = new Object();
        PropertyChangeSupport sup = new PropertyChangeSupport(src);
        Object newValue = new Object();
        Object oldValue = new Object();
 
        MockPropertyChangeListener l1 = new MockPropertyChangeListener(src,
                "myProp", oldValue, newValue);
 
        sup.addPropertyChangeListener(l1);
 
        sup.removePropertyChangeListener("myProp", l1);
        assertEquals(1, sup.getPropertyChangeListeners().length);
        assertEquals(0, sup.getPropertyChangeListeners("myProp").length);
        sup.firePropertyChange("myProp", oldValue, newValue);
        l1.assertCalled();
    } 
 
    /* 
     * Test the method removePropertyChangeListener(PropertyChangeListener,