BeanContextChildSupport support = new MockBeanContextChildSupport();
support.removeVetoableChangeListener("property name", null);
}
public void testRemoveVetoableChangeListener() throws PropertyVetoException {
BeanContextChildSupport support = new MockBeanContextChildSupport();
MockVetoableChangeListener l1 = new MockVetoableChangeListener();
MockVetoableChangeListener l2 = new MockVetoableChangeListener();
String propName = "property name";
Object oldValue = new Integer(1);
Object newValue = new Integer(5);
support.addVetoableChangeListener(propName, l1);
support.addVetoableChangeListener(propName, l2);
l1.clearLastEvent();
l2.clearLastEvent();
support.fireVetoableChange(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());
support.removeVetoableChangeListener(propName, l1);
l1.clearLastEvent();
l2.clearLastEvent();
support.fireVetoableChange(propName, oldValue, newValue);
assertNull(l1.lastEvent);
assertEquals(l2.lastEvent.getPropertyName(), propName);
assertSame(l2.lastEvent.getOldValue(), oldValue);
assertSame(l2.lastEvent.getNewValue(), newValue);
assertSame(l2.lastEvent.getSource(), support);
support.removeVetoableChangeListener(propName, l2);
l1.clearLastEvent();
l2.clearLastEvent();
support.fireVetoableChange(propName, oldValue, newValue);
assertNull(l1.lastEvent);
assertNull(l2.lastEvent);
// remove not-registered listener
support.removeVetoableChangeListener(propName, l1);
}