public static void main(String[] args) throws PropertyVetoException {
VetoableChangeSupport vcs = new VetoableChangeSupport(TestListeners.class);
vcs.addVetoableChangeListener(new TestListeners(0));
vcs.addVetoableChangeListener(NAME, new TestListeners(2));
vcs.addVetoableChangeListener(new TestListeners(1));
vcs.addVetoableChangeListener(NAME, new VetoableChangeListenerProxy(NAME, new TestListeners(3)));
current = 0;
vcs.fireVetoableChange(NAME, 0, 1);
if (current != 4)
throw new Error("Expected 4 listeners, but called " + current);
current = 0;
vcs.fireVetoableChange(NONE, 1, 0);
if (current != 2)
throw new Error("Expected 2 listeners, but called " + current);
VetoableChangeListener[] all = vcs.getVetoableChangeListeners();
if (all.length != 4)
throw new Error("Expected 4 listeners, but contained " + all.length);
VetoableChangeListener[] named = vcs.getVetoableChangeListeners(NAME);
if (named.length != 2)
throw new Error("Expected 2 named listeners, but contained " + named.length);
VetoableChangeListener[] other = vcs.getVetoableChangeListeners(NONE);
if (other.length != 0)
throw new Error("Expected 0 other listeners, but contained " + other.length);
vcs.removeVetoableChangeListener(new TestListeners(0));
vcs.removeVetoableChangeListener(new TestListeners(1));
vcs.removeVetoableChangeListener(NAME, new TestListeners(2));
vcs.removeVetoableChangeListener(NAME, new VetoableChangeListenerProxy(NAME, new TestListeners(3)));
all = vcs.getVetoableChangeListeners();
if (all.length != 0)
throw new Error("Expected 4 listeners, but contained " + all.length);