use of java.beans.VetoableChangeSupport in project jdk8u_jdk by JetBrains.
the class Test6630275 method main.
public static void main(String[] args) {
CheckListener first = new CheckListener(false);
CheckListener second = new CheckListener(true);
CheckListener third = new CheckListener(false);
VetoableChangeSupport vcs = new VetoableChangeSupport(Test6630275.class);
vcs.addVetoableChangeListener(first);
vcs.addVetoableChangeListener(PROPERTY, first);
vcs.addVetoableChangeListener(PROPERTY, second);
vcs.addVetoableChangeListener(PROPERTY, third);
try {
vcs.fireVetoableChange(PROPERTY, true, false);
} catch (PropertyVetoException exception) {
first.validate();
second.validate();
third.validate();
// expected exception
return;
}
throw new Error("exception should be thrown");
}
use of java.beans.VetoableChangeSupport in project jdk8u_jdk by JetBrains.
the class Test4092906 method main.
public static void main(String[] args) {
VetoableChangeSupport pcs = new VetoableChangeSupport(args);
pcs.addVetoableChangeListener(PUBLIC, new PublicListener());
pcs.addVetoableChangeListener(PRIVATE, new PrivateListener());
if (!pcs.hasListeners(PUBLIC)) {
throw new Error("no public listener");
}
if (!pcs.hasListeners(PRIVATE)) {
throw new Error("no private listener");
}
try {
// serialize into byte array
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream output = new ObjectOutputStream(baos);
output.writeObject(pcs);
output.flush();
// deserialize from byte array
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
ObjectInputStream input = new ObjectInputStream(bais);
pcs = (VetoableChangeSupport) input.readObject();
} catch (Exception exception) {
throw new Error("unexpected exception", exception);
}
if (!pcs.hasListeners(PUBLIC)) {
throw new Error("no public listener");
}
if (pcs.hasListeners(PRIVATE)) {
throw new Error("unexpected private listener");
}
}
use of java.beans.VetoableChangeSupport in project jdk8u_jdk by JetBrains.
the class TestEquals method main.
public static void main(String[] args) throws PropertyVetoException {
TestEquals one = new TestEquals(1);
TestEquals two = new TestEquals(2);
Object source = TestEquals.class;
VetoableChangeSupport vcs = new VetoableChangeSupport(source);
vcs.addVetoableChangeListener(PROPERTY, one);
vcs.addVetoableChangeListener(PROPERTY, two);
PropertyChangeEvent event = new PropertyChangeEvent(source, PROPERTY, one, two);
vcs.fireVetoableChange(event);
// only one check
test(one, two, 1);
vcs.fireVetoableChange(PROPERTY, one, two);
// because it invokes fireVetoableChange(PropertyChangeEvent)
test(one, two, 2);
}
use of java.beans.VetoableChangeSupport in project jdk8u_jdk by JetBrains.
the class Test4425885 method main.
public static void main(String[] args) {
CheckListener first = new CheckListener();
VetoListener second = new VetoListener();
CheckListener third = new CheckListener();
VetoableChangeSupport vcs = new VetoableChangeSupport(Test4425885.class);
vcs.addVetoableChangeListener(PROPERTY, first);
vcs.addVetoableChangeListener(PROPERTY, second);
vcs.addVetoableChangeListener(PROPERTY, third);
try {
vcs.fireVetoableChange(PROPERTY, 0, 1);
} catch (PropertyVetoException exception) {
if (first.odd)
throw new Error("no undo for the first listener", exception);
if (third.odd)
throw new Error("no undo for the third listener", exception);
// expected exception
return;
}
throw new Error("exception should be thrown");
}
use of java.beans.VetoableChangeSupport in project jdk8u_jdk by JetBrains.
the class Test7148143 method main.
public static void main(String[] args) {
VetoableChangeListener listener = new CustomProxy();
VetoableChangeSupport support = new VetoableChangeSupport(listener);
support.addVetoableChangeListener(listener);
// cast class exception
support.addVetoableChangeListener("foo", listener);
}
Aggregations