Java 类java.beans.beancontext.BeanContextChildSupport 实例源码

项目:cn1    文件:BeanContextChildSupportTest.java   
public void testFirePropertyChange() {
    BeanContextChildSupport support = new MockBeanContextChildSupport();
    MockPropertyChangeListener l1 = new MockPropertyChangeListener();
    MockPropertyChangeListener l2 = new MockPropertyChangeListener();
    String propName = "property name";
    Object oldValue = new Integer(1);
    Object newValue = new Integer(5);

    support.addPropertyChangeListener(propName, l1);
    support.addPropertyChangeListener("xxx", l2);
    l1.clearLastEvent();
    l2.clearLastEvent();
    support.firePropertyChange(propName, oldValue, newValue);
    assertEquals(propName, l1.lastEvent.getPropertyName());
    assertSame(oldValue, l1.lastEvent.getOldValue());
    assertSame(newValue, l1.lastEvent.getNewValue());
    assertSame(support, l1.lastEvent.getSource());
    assertNull(l2.lastEvent);
}
项目:cn1    文件:BeanContextChildSupportTest.java   
public void testFirePropertyChange_OldEqualsNew() {
    BeanContextChildSupport support = new MockBeanContextChildSupport();
    MockPropertyChangeListener l1 = new MockPropertyChangeListener();
    MockPropertyChangeListener l2 = new MockPropertyChangeListener();
    String propName = "property name";
    Object oldValue = new Integer(1);
    Object newValue = new Integer(1);

    support.addPropertyChangeListener(propName, l1);
    support.addPropertyChangeListener("xxx", l2);
    l1.clearLastEvent();
    l2.clearLastEvent();
    support.firePropertyChange(propName, oldValue, newValue);
    assertNull(l1.lastEvent);
    assertNull(l2.lastEvent);
}
项目:cn1    文件:BeanContextChildSupportTest.java   
public void testFirePropertyChange_OldEqualsNew_IsNull() {
    BeanContextChildSupport support = new MockBeanContextChildSupport();
    MockPropertyChangeListener l1 = new MockPropertyChangeListener();
    MockPropertyChangeListener l2 = new MockPropertyChangeListener();
    String propName = "property name";
    Object oldValue = null;
    Object newValue = null;

    support.addPropertyChangeListener(propName, l1);
    support.addPropertyChangeListener("xxx", l2);
    l1.clearLastEvent();
    l2.clearLastEvent();
    support.firePropertyChange(propName, oldValue, newValue);
    assertEquals(propName, l1.lastEvent.getPropertyName());
    assertNull(l1.lastEvent.getOldValue());
    assertNull(l1.lastEvent.getNewValue());
    assertSame(support, l1.lastEvent.getSource());
    assertNull(l2.lastEvent);
}
项目:cn1    文件:BeanContextChildSupportTest.java   
public void testFireVetoableChange() 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("xxx", 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());
    assertNull(l2.lastEvent);
}
项目:cn1    文件:BeanContextChildSupportTest.java   
public void testFireVetoableChange_OldEqualsNew()
        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(1);

    support.addVetoableChangeListener(propName, l1);
    support.addVetoableChangeListener("xxx", l2);
    l1.clearLastEvent();
    l2.clearLastEvent();
    support.fireVetoableChange(propName, oldValue, newValue);
    assertNull(l1.lastEvent);
    assertNull(l2.lastEvent);
}
项目:cn1    文件:BeanContextChildSupportTest.java   
public void testFireVetoableChange_OldEqualsNew_IsNull()
        throws PropertyVetoException {
    BeanContextChildSupport support = new MockBeanContextChildSupport();
    MockVetoableChangeListener l1 = new MockVetoableChangeListener();
    MockVetoableChangeListener l2 = new MockVetoableChangeListener();
    String propName = "property name";
    Object oldValue = null;
    Object newValue = null;

    support.addVetoableChangeListener(propName, l1);
    support.addVetoableChangeListener("xxx", l2);
    l1.clearLastEvent();
    l2.clearLastEvent();
    support.fireVetoableChange(propName, oldValue, newValue);
    assertEquals(propName, l1.lastEvent.getPropertyName());
    assertNull(l1.lastEvent.getOldValue());
    assertNull(l1.lastEvent.getNewValue());
    assertSame(support, l1.lastEvent.getSource());
    assertNull(l2.lastEvent);
}
项目:cn1    文件:BeanContextChildSupportTest.java   
public void testSerialization_NoPeer() throws IOException,
        ClassNotFoundException {
    BeanContextChildSupport support = new BeanContextChildSupport();
    MockPropertyChangeListener pcl1 = new MockPropertyChangeListener();
    MockPropertyChangeListenerS pcl2 = new MockPropertyChangeListenerS(
            "id of pcl2");
    MockVetoableChangeListener vcl1 = new MockVetoableChangeListener();
    MockVetoableChangeListenerS vcl2 = new MockVetoableChangeListenerS(
            "id of vcl2");
    support.addPropertyChangeListener("beanContext", pcl1);
    support.addPropertyChangeListener("beanContext", pcl2);
    support.addVetoableChangeListener("beanContext", vcl1);
    support.addVetoableChangeListener("beanContext", vcl2);

    assertEqualsSerially(support,
            (BeanContextChildSupport) SerializationTester
                    .getDeserilizedObject(support));
}
项目:cn1    文件:BeanContextChildSupportTest.java   
public void testSerialization_WithNonSerializablePeer() throws IOException,
        ClassNotFoundException {
    MockBeanContextChild peer = new MockBeanContextChild();
    BeanContextChildSupport support = new BeanContextChildSupport(peer);
    MockPropertyChangeListener pcl1 = new MockPropertyChangeListener();
    MockPropertyChangeListenerS pcl2 = new MockPropertyChangeListenerS(
            "id of pcl2");
    MockVetoableChangeListener vcl1 = new MockVetoableChangeListener();
    MockVetoableChangeListenerS vcl2 = new MockVetoableChangeListenerS(
            "id of vcl2");
    support.addPropertyChangeListener("beanContext", pcl1);
    support.addPropertyChangeListener("beanContext", pcl2);
    support.addVetoableChangeListener("beanContext", vcl1);
    support.addVetoableChangeListener("beanContext", vcl2);

    try {
        SerializationTester.getDeserilizedObject(support);
        fail();
    } catch (IOException e) {
        // expected
    }
}
项目:cn1    文件:BeanContextChildSupportTest.java   
public void testSerialization_WithPeer() throws IOException,
        ClassNotFoundException {
    MockBeanContextChildDelegateS peer = new MockBeanContextChildDelegateS(
            "id of peer");
    BeanContextChildSupport support = peer.support;
    MockPropertyChangeListener pcl1 = new MockPropertyChangeListener();
    MockPropertyChangeListenerS pcl2 = new MockPropertyChangeListenerS(
            "id of pcl2");
    MockVetoableChangeListener vcl1 = new MockVetoableChangeListener();
    MockVetoableChangeListenerS vcl2 = new MockVetoableChangeListenerS(
            "id of vcl2");
    support.addPropertyChangeListener("beanContext", pcl1);
    support.addPropertyChangeListener("beanContext", pcl2);
    support.addVetoableChangeListener("beanContext", vcl1);
    support.addVetoableChangeListener("beanContext", vcl2);

    assertEqualsSerially(support,
            (BeanContextChildSupport) SerializationTester
                    .getDeserilizedObject(support));
}
项目:cn1    文件:BeanContextChildSupportTest.java   
public void testSerialization_Compatibility() throws IOException,
        ClassNotFoundException, Exception {
    MockBeanContextChildDelegateS peer = new MockBeanContextChildDelegateS(
            "id of peer");
    BeanContextChildSupport support = peer.support;
    MockPropertyChangeListener pcl1 = new MockPropertyChangeListener();
    MockPropertyChangeListenerS pcl2 = new MockPropertyChangeListenerS(
            "id of pcl2");
    MockVetoableChangeListener vcl1 = new MockVetoableChangeListener();
    MockVetoableChangeListenerS vcl2 = new MockVetoableChangeListenerS(
            "id of vcl2");
    support.addPropertyChangeListener("beanContext", pcl1);
    support.addPropertyChangeListener("beanContext", pcl2);
    support.addVetoableChangeListener("beanContext", vcl1);
    support.addVetoableChangeListener("beanContext", vcl2);
    SerializationTest.verifyGolden(this, support, new SerializableAssert(){
        public void assertDeserialized(Serializable orig, Serializable ser) {
            assertEqualsSerially((BeanContextChildSupport) orig,
                    (BeanContextChildSupport) ser);
        }
    });
}
项目:cn1    文件:BeanContextSupportTest.java   
public void testGetChildBeanContextChild_BeanContextChild() {
    MockBeanContextChild child = new MockBeanContextChild();
    BeanContextChild result = MockBeanContextSupport
            .publicGetChildBeanContextChild(child);
    assertSame(child, result);

    // Regression for HARMONY-1393
    class TestBeanException extends BeanContextChildSupport implements
            BeanContextProxy {
        private static final long serialVersionUID = -8544245159647566063L;
        private final BeanContextChildSupport childSupport = new BeanContextChildSupport();

        public BeanContextChild getBeanContextProxy() {
            return childSupport;
        }
    }
    TestBeanException bean = new TestBeanException();
    try {
        MockBeanContextSupport.publicGetChildBeanContextChild(bean);
        fail("IllegalArgumentException expected");
    } catch (IllegalArgumentException e) {
        // expected
    }
}
项目:freeVM    文件:BeanContextChildSupportTest.java   
public void testFirePropertyChange() {
    BeanContextChildSupport support = new MockBeanContextChildSupport();
    MockPropertyChangeListener l1 = new MockPropertyChangeListener();
    MockPropertyChangeListener l2 = new MockPropertyChangeListener();
    String propName = "property name";
    Object oldValue = new Integer(1);
    Object newValue = new Integer(5);

    support.addPropertyChangeListener(propName, l1);
    support.addPropertyChangeListener("xxx", l2);
    l1.clearLastEvent();
    l2.clearLastEvent();
    support.firePropertyChange(propName, oldValue, newValue);
    assertEquals(propName, l1.lastEvent.getPropertyName());
    assertSame(oldValue, l1.lastEvent.getOldValue());
    assertSame(newValue, l1.lastEvent.getNewValue());
    assertSame(support, l1.lastEvent.getSource());
    assertNull(l2.lastEvent);
}
项目:freeVM    文件:BeanContextChildSupportTest.java   
public void testFirePropertyChange_OldEqualsNew() {
    BeanContextChildSupport support = new MockBeanContextChildSupport();
    MockPropertyChangeListener l1 = new MockPropertyChangeListener();
    MockPropertyChangeListener l2 = new MockPropertyChangeListener();
    String propName = "property name";
    Object oldValue = new Integer(1);
    Object newValue = new Integer(1);

    support.addPropertyChangeListener(propName, l1);
    support.addPropertyChangeListener("xxx", l2);
    l1.clearLastEvent();
    l2.clearLastEvent();
    support.firePropertyChange(propName, oldValue, newValue);
    assertNull(l1.lastEvent);
    assertNull(l2.lastEvent);
}
项目:freeVM    文件:BeanContextChildSupportTest.java   
public void testFirePropertyChange_OldEqualsNew_IsNull() {
    BeanContextChildSupport support = new MockBeanContextChildSupport();
    MockPropertyChangeListener l1 = new MockPropertyChangeListener();
    MockPropertyChangeListener l2 = new MockPropertyChangeListener();
    String propName = "property name";
    Object oldValue = null;
    Object newValue = null;

    support.addPropertyChangeListener(propName, l1);
    support.addPropertyChangeListener("xxx", l2);
    l1.clearLastEvent();
    l2.clearLastEvent();
    support.firePropertyChange(propName, oldValue, newValue);
    assertEquals(propName, l1.lastEvent.getPropertyName());
    assertNull(l1.lastEvent.getOldValue());
    assertNull(l1.lastEvent.getNewValue());
    assertSame(support, l1.lastEvent.getSource());
    assertNull(l2.lastEvent);
}
项目:freeVM    文件:BeanContextChildSupportTest.java   
public void testFireVetoableChange() 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("xxx", 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());
    assertNull(l2.lastEvent);
}
项目:freeVM    文件:BeanContextChildSupportTest.java   
public void testFireVetoableChange_OldEqualsNew()
        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(1);

    support.addVetoableChangeListener(propName, l1);
    support.addVetoableChangeListener("xxx", l2);
    l1.clearLastEvent();
    l2.clearLastEvent();
    support.fireVetoableChange(propName, oldValue, newValue);
    assertNull(l1.lastEvent);
    assertNull(l2.lastEvent);
}
项目:freeVM    文件:BeanContextChildSupportTest.java   
public void testFireVetoableChange_OldEqualsNew_IsNull()
        throws PropertyVetoException {
    BeanContextChildSupport support = new MockBeanContextChildSupport();
    MockVetoableChangeListener l1 = new MockVetoableChangeListener();
    MockVetoableChangeListener l2 = new MockVetoableChangeListener();
    String propName = "property name";
    Object oldValue = null;
    Object newValue = null;

    support.addVetoableChangeListener(propName, l1);
    support.addVetoableChangeListener("xxx", l2);
    l1.clearLastEvent();
    l2.clearLastEvent();
    support.fireVetoableChange(propName, oldValue, newValue);
    assertEquals(propName, l1.lastEvent.getPropertyName());
    assertNull(l1.lastEvent.getOldValue());
    assertNull(l1.lastEvent.getNewValue());
    assertSame(support, l1.lastEvent.getSource());
    assertNull(l2.lastEvent);
}
项目:freeVM    文件:BeanContextChildSupportTest.java   
public void testIsDelegated() throws Exception {
    BeanContextChildSupport support = new MockBeanContextChildSupport();
    assertFalse(support.isDelegated());

    BeanContextChild mockChild = new MockBeanContextChild();
    support = new MockBeanContextChildSupport(mockChild);
    assertTrue(support.isDelegated());

    support.beanContextChildPeer = support;
    assertFalse(support.isDelegated());

    BeanContextChildSupport sup = new BeanContextChildSupport();

    assertFalse("Child is not supposed to be delegated",
            sup.isDelegated());
}
项目:freeVM    文件:BeanContextChildSupportTest.java   
public void testSerialization_NoPeer() throws IOException,
        ClassNotFoundException {
    BeanContextChildSupport support = new BeanContextChildSupport();
    MockPropertyChangeListener pcl1 = new MockPropertyChangeListener();
    MockPropertyChangeListenerS pcl2 = new MockPropertyChangeListenerS(
            "id of pcl2");
    MockVetoableChangeListener vcl1 = new MockVetoableChangeListener();
    MockVetoableChangeListenerS vcl2 = new MockVetoableChangeListenerS(
            "id of vcl2");
    support.addPropertyChangeListener("beanContext", pcl1);
    support.addPropertyChangeListener("beanContext", pcl2);
    support.addVetoableChangeListener("beanContext", vcl1);
    support.addVetoableChangeListener("beanContext", vcl2);

    assertEqualsSerially(support,
            (BeanContextChildSupport) SerializationTester
                    .getDeserilizedObject(support));
}
项目:freeVM    文件:BeanContextChildSupportTest.java   
public void testSerialization_WithNonSerializablePeer() throws IOException,
        ClassNotFoundException {
    MockBeanContextChild peer = new MockBeanContextChild();
    BeanContextChildSupport support = new BeanContextChildSupport(peer);
    MockPropertyChangeListener pcl1 = new MockPropertyChangeListener();
    MockPropertyChangeListenerS pcl2 = new MockPropertyChangeListenerS(
            "id of pcl2");
    MockVetoableChangeListener vcl1 = new MockVetoableChangeListener();
    MockVetoableChangeListenerS vcl2 = new MockVetoableChangeListenerS(
            "id of vcl2");
    support.addPropertyChangeListener("beanContext", pcl1);
    support.addPropertyChangeListener("beanContext", pcl2);
    support.addVetoableChangeListener("beanContext", vcl1);
    support.addVetoableChangeListener("beanContext", vcl2);

    try {
        SerializationTester.getDeserilizedObject(support);
        fail();
    } catch (IOException e) {
        // expected
    }
}
项目:freeVM    文件:BeanContextChildSupportTest.java   
public void testSerialization_WithPeer() throws IOException,
        ClassNotFoundException {
    MockBeanContextChildDelegateS peer = new MockBeanContextChildDelegateS(
            "id of peer");
    BeanContextChildSupport support = peer.support;
    MockPropertyChangeListener pcl1 = new MockPropertyChangeListener();
    MockPropertyChangeListenerS pcl2 = new MockPropertyChangeListenerS(
            "id of pcl2");
    MockVetoableChangeListener vcl1 = new MockVetoableChangeListener();
    MockVetoableChangeListenerS vcl2 = new MockVetoableChangeListenerS(
            "id of vcl2");
    support.addPropertyChangeListener("beanContext", pcl1);
    support.addPropertyChangeListener("beanContext", pcl2);
    support.addVetoableChangeListener("beanContext", vcl1);
    support.addVetoableChangeListener("beanContext", vcl2);

    assertEqualsSerially(support,
            (BeanContextChildSupport) SerializationTester
                    .getDeserilizedObject(support));
}
项目:freeVM    文件:BeanContextChildSupportTest.java   
public void testSerialization_Compatibility() throws IOException,
        ClassNotFoundException, Exception {
    MockBeanContextChildDelegateS peer = new MockBeanContextChildDelegateS(
            "id of peer");
    BeanContextChildSupport support = peer.support;
    MockPropertyChangeListener pcl1 = new MockPropertyChangeListener();
    MockPropertyChangeListenerS pcl2 = new MockPropertyChangeListenerS(
            "id of pcl2");
    MockVetoableChangeListener vcl1 = new MockVetoableChangeListener();
    MockVetoableChangeListenerS vcl2 = new MockVetoableChangeListenerS(
            "id of vcl2");
    support.addPropertyChangeListener("beanContext", pcl1);
    support.addPropertyChangeListener("beanContext", pcl2);
    support.addVetoableChangeListener("beanContext", vcl1);
    support.addVetoableChangeListener("beanContext", vcl2);

    assertEqualsSerially(
            support,
            (BeanContextChildSupport) SerializationTester
                    .readObject(support,
                            "serialization/java/beans/beancontext/BeanContextChildSupport.ser"));
}
项目:freeVM    文件:BeanContextSupportTest.java   
public void testGetChildBeanContextChild_BeanContextChild() {
    MockBeanContextChild child = new MockBeanContextChild();
    BeanContextChild result = MockBeanContextSupport
            .publicGetChildBeanContextChild(child);
    assertSame(child, result);

    // Regression for HARMONY-1393
    class TestBeanException extends BeanContextChildSupport implements
            BeanContextProxy {
        private static final long serialVersionUID = -8544245159647566063L;
        private final BeanContextChildSupport childSupport = new BeanContextChildSupport();

        public BeanContextChild getBeanContextProxy() {
            return childSupport;
        }
    }
    TestBeanException bean = new TestBeanException();
    try {
        MockBeanContextSupport.publicGetChildBeanContextChild(bean);
        fail("IllegalArgumentException expected");
    } catch (IllegalArgumentException e) {
        // expected
    }
}
项目:freeVM    文件:BeanContextChildSupportTest.java   
public void testFirePropertyChange() {
    BeanContextChildSupport support = new MockBeanContextChildSupport();
    MockPropertyChangeListener l1 = new MockPropertyChangeListener();
    MockPropertyChangeListener l2 = new MockPropertyChangeListener();
    String propName = "property name";
    Object oldValue = new Integer(1);
    Object newValue = new Integer(5);

    support.addPropertyChangeListener(propName, l1);
    support.addPropertyChangeListener("xxx", l2);
    l1.clearLastEvent();
    l2.clearLastEvent();
    support.firePropertyChange(propName, oldValue, newValue);
    assertEquals(propName, l1.lastEvent.getPropertyName());
    assertSame(oldValue, l1.lastEvent.getOldValue());
    assertSame(newValue, l1.lastEvent.getNewValue());
    assertSame(support, l1.lastEvent.getSource());
    assertNull(l2.lastEvent);
}
项目:freeVM    文件:BeanContextChildSupportTest.java   
public void testFirePropertyChange_OldEqualsNew() {
    BeanContextChildSupport support = new MockBeanContextChildSupport();
    MockPropertyChangeListener l1 = new MockPropertyChangeListener();
    MockPropertyChangeListener l2 = new MockPropertyChangeListener();
    String propName = "property name";
    Object oldValue = new Integer(1);
    Object newValue = new Integer(1);

    support.addPropertyChangeListener(propName, l1);
    support.addPropertyChangeListener("xxx", l2);
    l1.clearLastEvent();
    l2.clearLastEvent();
    support.firePropertyChange(propName, oldValue, newValue);
    assertNull(l1.lastEvent);
    assertNull(l2.lastEvent);
}
项目:freeVM    文件:BeanContextChildSupportTest.java   
public void testFirePropertyChange_OldEqualsNew_IsNull() {
    BeanContextChildSupport support = new MockBeanContextChildSupport();
    MockPropertyChangeListener l1 = new MockPropertyChangeListener();
    MockPropertyChangeListener l2 = new MockPropertyChangeListener();
    String propName = "property name";
    Object oldValue = null;
    Object newValue = null;

    support.addPropertyChangeListener(propName, l1);
    support.addPropertyChangeListener("xxx", l2);
    l1.clearLastEvent();
    l2.clearLastEvent();
    support.firePropertyChange(propName, oldValue, newValue);
    assertEquals(propName, l1.lastEvent.getPropertyName());
    assertNull(l1.lastEvent.getOldValue());
    assertNull(l1.lastEvent.getNewValue());
    assertSame(support, l1.lastEvent.getSource());
    assertNull(l2.lastEvent);
}
项目:freeVM    文件:BeanContextChildSupportTest.java   
public void testFireVetoableChange() 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("xxx", 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());
    assertNull(l2.lastEvent);
}
项目:freeVM    文件:BeanContextChildSupportTest.java   
public void testFireVetoableChange_OldEqualsNew()
        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(1);

    support.addVetoableChangeListener(propName, l1);
    support.addVetoableChangeListener("xxx", l2);
    l1.clearLastEvent();
    l2.clearLastEvent();
    support.fireVetoableChange(propName, oldValue, newValue);
    assertNull(l1.lastEvent);
    assertNull(l2.lastEvent);
}
项目:freeVM    文件:BeanContextChildSupportTest.java   
public void testFireVetoableChange_OldEqualsNew_IsNull()
        throws PropertyVetoException {
    BeanContextChildSupport support = new MockBeanContextChildSupport();
    MockVetoableChangeListener l1 = new MockVetoableChangeListener();
    MockVetoableChangeListener l2 = new MockVetoableChangeListener();
    String propName = "property name";
    Object oldValue = null;
    Object newValue = null;

    support.addVetoableChangeListener(propName, l1);
    support.addVetoableChangeListener("xxx", l2);
    l1.clearLastEvent();
    l2.clearLastEvent();
    support.fireVetoableChange(propName, oldValue, newValue);
    assertEquals(propName, l1.lastEvent.getPropertyName());
    assertNull(l1.lastEvent.getOldValue());
    assertNull(l1.lastEvent.getNewValue());
    assertSame(support, l1.lastEvent.getSource());
    assertNull(l2.lastEvent);
}
项目:freeVM    文件:BeanContextChildSupportTest.java   
public void testSerialization_NoPeer() throws IOException,
        ClassNotFoundException {
    BeanContextChildSupport support = new BeanContextChildSupport();
    MockPropertyChangeListener pcl1 = new MockPropertyChangeListener();
    MockPropertyChangeListenerS pcl2 = new MockPropertyChangeListenerS(
            "id of pcl2");
    MockVetoableChangeListener vcl1 = new MockVetoableChangeListener();
    MockVetoableChangeListenerS vcl2 = new MockVetoableChangeListenerS(
            "id of vcl2");
    support.addPropertyChangeListener("beanContext", pcl1);
    support.addPropertyChangeListener("beanContext", pcl2);
    support.addVetoableChangeListener("beanContext", vcl1);
    support.addVetoableChangeListener("beanContext", vcl2);

    assertEqualsSerially(support,
            (BeanContextChildSupport) SerializationTester
                    .getDeserilizedObject(support));
}
项目:freeVM    文件:BeanContextChildSupportTest.java   
public void testSerialization_WithNonSerializablePeer() throws IOException,
        ClassNotFoundException {
    MockBeanContextChild peer = new MockBeanContextChild();
    BeanContextChildSupport support = new BeanContextChildSupport(peer);
    MockPropertyChangeListener pcl1 = new MockPropertyChangeListener();
    MockPropertyChangeListenerS pcl2 = new MockPropertyChangeListenerS(
            "id of pcl2");
    MockVetoableChangeListener vcl1 = new MockVetoableChangeListener();
    MockVetoableChangeListenerS vcl2 = new MockVetoableChangeListenerS(
            "id of vcl2");
    support.addPropertyChangeListener("beanContext", pcl1);
    support.addPropertyChangeListener("beanContext", pcl2);
    support.addVetoableChangeListener("beanContext", vcl1);
    support.addVetoableChangeListener("beanContext", vcl2);

    try {
        SerializationTester.getDeserilizedObject(support);
        fail();
    } catch (IOException e) {
        // expected
    }
}
项目:freeVM    文件:BeanContextChildSupportTest.java   
public void testSerialization_WithPeer() throws IOException,
        ClassNotFoundException {
    MockBeanContextChildDelegateS peer = new MockBeanContextChildDelegateS(
            "id of peer");
    BeanContextChildSupport support = peer.support;
    MockPropertyChangeListener pcl1 = new MockPropertyChangeListener();
    MockPropertyChangeListenerS pcl2 = new MockPropertyChangeListenerS(
            "id of pcl2");
    MockVetoableChangeListener vcl1 = new MockVetoableChangeListener();
    MockVetoableChangeListenerS vcl2 = new MockVetoableChangeListenerS(
            "id of vcl2");
    support.addPropertyChangeListener("beanContext", pcl1);
    support.addPropertyChangeListener("beanContext", pcl2);
    support.addVetoableChangeListener("beanContext", vcl1);
    support.addVetoableChangeListener("beanContext", vcl2);

    assertEqualsSerially(support,
            (BeanContextChildSupport) SerializationTester
                    .getDeserilizedObject(support));
}
项目:freeVM    文件:BeanContextChildSupportTest.java   
public void testSerialization_Compatibility() throws IOException,
        ClassNotFoundException, Exception {
    MockBeanContextChildDelegateS peer = new MockBeanContextChildDelegateS(
            "id of peer");
    BeanContextChildSupport support = peer.support;
    MockPropertyChangeListener pcl1 = new MockPropertyChangeListener();
    MockPropertyChangeListenerS pcl2 = new MockPropertyChangeListenerS(
            "id of pcl2");
    MockVetoableChangeListener vcl1 = new MockVetoableChangeListener();
    MockVetoableChangeListenerS vcl2 = new MockVetoableChangeListenerS(
            "id of vcl2");
    support.addPropertyChangeListener("beanContext", pcl1);
    support.addPropertyChangeListener("beanContext", pcl2);
    support.addVetoableChangeListener("beanContext", vcl1);
    support.addVetoableChangeListener("beanContext", vcl2);
    SerializationTest.verifyGolden(this, support, new SerializableAssert(){
        public void assertDeserialized(Serializable orig, Serializable ser) {
            assertEqualsSerially((BeanContextChildSupport) orig,
                    (BeanContextChildSupport) ser);
        }
    });
}
项目:freeVM    文件:BeanContextSupportTest.java   
public void testGetChildBeanContextChild_BeanContextChild() {
    MockBeanContextChild child = new MockBeanContextChild();
    BeanContextChild result = MockBeanContextSupport
            .publicGetChildBeanContextChild(child);
    assertSame(child, result);

    // Regression for HARMONY-1393
    class TestBeanException extends BeanContextChildSupport implements
            BeanContextProxy {
        private static final long serialVersionUID = -8544245159647566063L;
        private final BeanContextChildSupport childSupport = new BeanContextChildSupport();

        public BeanContextChild getBeanContextProxy() {
            return childSupport;
        }
    }
    TestBeanException bean = new TestBeanException();
    try {
        MockBeanContextSupport.publicGetChildBeanContextChild(bean);
        fail("IllegalArgumentException expected");
    } catch (IllegalArgumentException e) {
        // expected
    }
}
项目:freeVM    文件:TestCollectionBeanContext.java   
/**
 * @see java.beans.beancontext.BeanContextSupport#retainAll(Collection)
 * @see java.beans.beancontext.BeanContextSupport#iterator()
 */
public Result testContainsAllBeanContext()throws Exception {

    bean = new BeanContextChildSupport();
    beanWithContext = new BeanWithBeanContext();
    subContext = new BeanContextSupport();

    vector = new Vector();

    // Adding the components
    context.add(bean);
    context.add(beanWithContext);
    context.add(subContext);

    // Adding the components from bean context to Vector
    for (int i = 0; i < context.size(); i++) {
        vector.add(context.iterator().next());
    }

    // It's verified that objects in the specified Vector are children of this bean context 
    if (context.containsAll(vector)) {
        return passed();
    } else {
        return failed("testCollectionContainsAll() - failed ");
    }
}
项目:freeVM    文件:TestSizeBeanContext.java   
/**
 * @see java.beans.beancontext.BeanContextSupport#size()
 */
public Result testSize() throws Exception {

    // The BeanContext object to be checked by the test
    BeanContextSupport contextForSize = new BeanContextSupport(); 

    // Components that should be added to context
    BeanContextSupport subContext = new BeanContextSupport();                                                                  
    BeanWithBeanContext beanWithContext = new BeanWithBeanContext();        
    BeanContextChildSupport bean = new BeanContextChildSupport();

    // Adding the components
    contextForSize.add(subContext);
    contextForSize.add(beanWithContext);
    contextForSize.add(bean);

    // It's verified that the BeanContext contains 4 components
    if (contextForSize.size() == 4) {
        return passed();
    } else {
        return failed("testSize() - failed ");
    }
}
项目:freeVM    文件:TestSizeBeanContext.java   
/**
 * @see java.beans.beancontext.BeanContextSupport#isEmpty()
 */
public Result testIsContextEmpty() throws Exception {

    // The BeanContext object to be checked by the test
    BeanContextSupport context = new BeanContextSupport(); 

    // Components that should be added to context
    BeanContextSupport subContext = new BeanContextSupport();                                                                  
    BeanWithBeanContext beanWithContext = new BeanWithBeanContext();        
    BeanContextChildSupport bean = new BeanContextChildSupport();

    // Adding the components
    context.add(subContext);
    context.add(beanWithContext);
    context.add(bean);

    // It's verified that the BeanContext isn't empty
    if (!context.isEmpty()) {
        return passed();
    } else {
        return failed("testIsContextEmpty() - failed ");
    }
}
项目:freeVM    文件:TestBeanContextMembershipEvent.java   
/**
 * @see java.beans.beancontext.BeanContextMembershipEvent
 */
public Result testNullPointerException1() throws Exception {

    context = new BeanContextSupport();

    bean = new BeanContextChildSupport();

    // Adding the component
    context.add(bean);

    Object[] array = null;
    try {
        event = new BeanContextMembershipEvent(bean.getBeanContext(), array);
    } catch (java.lang.NullPointerException e) {
        return passed();
    }
    return failed("testNullPointerException1");
}
项目:freeVM    文件:TestBeanContextMembershipEvent.java   
/**
 * @see java.beans.beancontext.BeanContextMembershipEvent
 */
public Result testNullPointerException2() throws Exception {

    context = new BeanContextSupport();
    bean = new BeanContextChildSupport();

    // Adding the component
    context.add(bean);

    Collection[] array = null;
    try {
        event = new BeanContextMembershipEvent(bean.getBeanContext(), array);
    } catch (java.lang.NullPointerException e) {

        return passed();
    }
    return failed("testNullPointerException2");
}
项目:freeVM    文件:TestBeanContextMembershipEvent.java   
/**
 * @see java.beans.beancontext.BeanContextMembershipEvent#contains()
 */
public Result testContainsBeanContextMembershipEvent() throws Exception {

    context = new BeanContextSupport();
    bean = new BeanContextChildSupport();
    sBean = new ServiceBean();

    // Adding the component
    context.add(bean);
    context.add(sBean);

    event = new BeanContextMembershipEvent(bean.getBeanContext(), context
            .toArray());

    if ((event.contains(sBean)) || !(event.contains(context)))
        return passed();
    else
        return failed("testContainsBeanContextMembershipEvent");
}