Search in sources :

Example 1 with PropertyChangeListenerProxy

use of java.beans.PropertyChangeListenerProxy in project robovm by robovm.

the class PropertyChangeSupportTest method testAddingAListenerActuallyAddsAProxy.

public void testAddingAListenerActuallyAddsAProxy() {
    Object bean = new Object();
    PropertyChangeSupport support = new PropertyChangeSupport(bean);
    PropertyChangeListener listener = new PropertyChangeListener() {

        public void propertyChange(PropertyChangeEvent event) {
        }
    };
    support.addPropertyChangeListener("a", listener);
    PropertyChangeListenerProxy p1 = (PropertyChangeListenerProxy) support.getPropertyChangeListeners()[0];
    assertEquals(PropertyChangeListenerProxy.class, p1.getClass());
    // weird but consistent with the RI
    assertTrue(p1 != listener);
    assertEquals("a", p1.getPropertyName());
    assertEquals(listener, p1.getListener());
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener) PropertyChangeSupport(java.beans.PropertyChangeSupport) PropertyChangeListenerProxy(java.beans.PropertyChangeListenerProxy)

Example 2 with PropertyChangeListenerProxy

use of java.beans.PropertyChangeListenerProxy in project jdk8u_jdk by JetBrains.

the class TestSerialization method check.

private static void check(PropertyChangeListener listener, int index, String name) {
    if (!(listener instanceof PropertyChangeListenerProxy))
        throw new Error("Unexpected listener: " + listener);
    PropertyChangeListenerProxy object = (PropertyChangeListenerProxy) listener;
    if (!name.equals(object.getPropertyName()))
        throw new Error("Unexpected name: " + name + " != " + object.getPropertyName());
    check((PropertyChangeListener) object.getListener(), index);
}
Also used : PropertyChangeListenerProxy(java.beans.PropertyChangeListenerProxy)

Example 3 with PropertyChangeListenerProxy

use of java.beans.PropertyChangeListenerProxy in project j2objc by google.

the class PropertyChangeListenerProxyTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    proxy = new PropertyChangeListenerProxy(name, listener);
}
Also used : PropertyChangeListenerProxy(java.beans.PropertyChangeListenerProxy)

Example 4 with PropertyChangeListenerProxy

use of java.beans.PropertyChangeListenerProxy in project j2objc by google.

the class PropertyChangeListenerProxyTest method testPropertyChangeListenerProxy.

public void testPropertyChangeListenerProxy() {
    proxy = new PropertyChangeListenerProxy(null, listener);
    assertSame(listener, proxy.getListener());
    assertNull(proxy.getPropertyName());
    PropertyChangeEvent newevent = new PropertyChangeEvent(new Object(), "name", new Object(), new Object());
    proxy.propertyChange(newevent);
    assertSame(newevent, event);
    proxy = new PropertyChangeListenerProxy(name, null);
    assertSame(name, proxy.getPropertyName());
    assertNull(proxy.getListener());
    try {
        proxy.propertyChange(new PropertyChangeEvent(new Object(), "name", new Object(), new Object()));
        fail("NullPointerException expected");
    } catch (NullPointerException e) {
    }
    proxy = new PropertyChangeListenerProxy(name, listener);
    assertSame(listener, proxy.getListener());
    assertSame(name, proxy.getPropertyName());
    newevent = new PropertyChangeEvent(new Object(), "name", new Object(), new Object());
    assertSame(name, proxy.getPropertyName());
    proxy.propertyChange(newevent);
    assertSame(newevent, event);
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListenerProxy(java.beans.PropertyChangeListenerProxy)

Example 5 with PropertyChangeListenerProxy

use of java.beans.PropertyChangeListenerProxy in project j2objc by google.

the class PropertyChangeListenerProxyTest method testPropertyChange_PropertyChangeEvent.

/**
     * Regression for HARMONY-407
     */
public void testPropertyChange_PropertyChangeEvent() {
    PropertyChangeListenerProxy proxy = new PropertyChangeListenerProxy("harmony", null);
    try {
        proxy.propertyChange(null);
        fail("NullPointerException expected");
    } catch (NullPointerException e) {
    }
}
Also used : PropertyChangeListenerProxy(java.beans.PropertyChangeListenerProxy)

Aggregations

PropertyChangeListenerProxy (java.beans.PropertyChangeListenerProxy)8 PropertyChangeEvent (java.beans.PropertyChangeEvent)4 PropertyChangeSupport (java.beans.PropertyChangeSupport)4 PropertyChangeListener (java.beans.PropertyChangeListener)2