/*
* add a listener which has already been added.
*/
public void testAddVetoableChangeListenerStringVetoableChangeListener_duplicate() {
MockSource source = new MockSource();
VetoableChangeSupport support = new VetoableChangeSupport(source);
VetoableChangeListener proxy = EventHandler.create(
VetoableChangeListener.class, source, "setText");
String propertyName = "label";
support.addVetoableChangeListener(propertyName, proxy);
{
assertTrue(support.hasListeners(propertyName));
assertFalse(support.hasListeners("text"));
VetoableChangeListener[] listeners1 = support
.getVetoableChangeListeners();
VetoableChangeListener[] listeners2 = support
.getVetoableChangeListeners(propertyName);
VetoableChangeListener[] listeners3 = support
.getVetoableChangeListeners("text");
assertEquals(0, listeners3.length);
assertEquals(1, listeners1.length);
assertEquals(1, listeners2.length);
assertSame(proxy, listeners2[0]);
VetoableChangeListenerProxy wrappers = (VetoableChangeListenerProxy) listeners1[0];
assertSame(proxy, wrappers.getListener());
assertEquals(propertyName, wrappers.getPropertyName());
}
support.addVetoableChangeListener(propertyName, proxy);
{
assertTrue(support.hasListeners(propertyName));
assertFalse(support.hasListeners("text"));
VetoableChangeListener[] listeners1 = support
.getVetoableChangeListeners();
VetoableChangeListener[] listeners2 = support
.getVetoableChangeListeners(propertyName);
VetoableChangeListener[] listeners3 = support
.getVetoableChangeListeners("text");
assertEquals(0, listeners3.length);
assertEquals(2, listeners1.length);
assertEquals(2, listeners2.length);