support.firePropertyChange("property name", "old value",
"new value");
}
public void testAddPropertyChangeListener() {
BeanContextChildSupport support = new MockBeanContextChildSupport();
MockPropertyChangeListener l1 = new MockPropertyChangeListener();
MockPropertyChangeListener l2 = new MockPropertyChangeListener();
String propName = "property name";
Object oldValue = new Integer(1);
Object newValue = new Integer(5);
l1.clearLastEvent();
l2.clearLastEvent();
support.firePropertyChange(propName, oldValue, newValue);
assertNull(l1.lastEvent);
assertNull(l2.lastEvent);
support.addPropertyChangeListener(propName, l1);
l1.clearLastEvent();
l2.clearLastEvent();
support.firePropertyChange(propName, oldValue, newValue);
assertEquals(propName, l1.lastEvent.getPropertyName());
assertSame(oldValue, l1.lastEvent.getOldValue());
assertSame(newValue, l1.lastEvent.getNewValue());
assertSame(support, l1.lastEvent.getSource());
assertNull(l2.lastEvent);
support.addPropertyChangeListener(propName, l2);
l1.clearLastEvent();
l2.clearLastEvent();
support.firePropertyChange(propName, oldValue, newValue);
assertEquals(propName, l1.lastEvent.getPropertyName());
assertSame(oldValue, l1.lastEvent.getOldValue());
assertSame(newValue, l1.lastEvent.getNewValue());
assertSame(support, l1.lastEvent.getSource());
assertEquals(propName, l2.lastEvent.getPropertyName());
assertSame(oldValue, l2.lastEvent.getOldValue());
assertSame(newValue, l2.lastEvent.getNewValue());
assertSame(support, l2.lastEvent.getSource());
l1.clearLastEvent();
l2.clearLastEvent();
support.firePropertyChange("xxx", oldValue, newValue);
assertNull(l1.lastEvent);
assertNull(l2.lastEvent);
}