Code example for PropertyChangeSupport

Methods: hasListeners

0
    /* 
     * Test the method hasListeners(String) with a null parameter. 
     */ 
    public void testHasListener_Null() { 
        Object src = new Object();
        PropertyChangeSupport sup = new PropertyChangeSupport(src);
        PropertyChangeListener l1 = new MockPropertyChangeListener();
 
        assertFalse(sup.hasListeners(null));
 
        sup.addPropertyChangeListener("myProP", l1);
        sup.hasListeners(null);
    } 
 
    public void testFireIndexedPropertyChange() { 
        final Object src = new Object();
        PropertyChangeSupport pcs = new PropertyChangeSupport(src);
        pcs.addPropertyChangeListener(new PropertyChangeListener() {
            public void propertyChange(PropertyChangeEvent evt) {
                assertEquals(src, evt.getSource());
                assertEquals(0, ((IndexedPropertyChangeEvent)evt).getIndex());