Package org.apache.harmony.beans.tests.support.beancontext.mock

Examples of org.apache.harmony.beans.tests.support.beancontext.mock.MockVetoableChangeListener


    public void testAddVetoableChangeListener_NullParam()
            throws PropertyVetoException {
        BeanContextChildSupport support = new MockBeanContextChildSupport();
        support.addVetoableChangeListener(null,
                new MockVetoableChangeListener());
        support.addVetoableChangeListener("property name", null);
        support.fireVetoableChange("property name", "old value", "new value");
    }
View Full Code Here


        support.fireVetoableChange("property name", "old value", "new value");
    }

    public void testAddVetoableChangeListener() 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);

        l1.clearLastEvent();
        l2.clearLastEvent();
        support.fireVetoableChange(propName, oldValue, newValue);
        assertNull(l1.lastEvent);
        assertNull(l2.lastEvent);

        support.addVetoableChangeListener(propName, l1);
        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);

        support.addVetoableChangeListener(propName, 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());
        assertEquals(propName, l2.lastEvent.getPropertyName());
        assertSame(oldValue, l2.lastEvent.getOldValue());
        assertSame(newValue, l2.lastEvent.getNewValue());
        assertSame(support, l2.lastEvent.getSource());

        l1.clearLastEvent();
        l2.clearLastEvent();
        support.fireVetoableChange("xxx", oldValue, newValue);
        assertNull(l1.lastEvent);
        assertNull(l2.lastEvent);
    }
View Full Code Here

        support.fireVetoableChange(null, "a", "b");
    }

    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());
View Full Code Here

        assertNull(l2.lastEvent);
    }

    public void testFireVetoableChange_Vetoed() {
        BeanContextChildSupport support = new MockBeanContextChildSupport();
        MockVetoableChangeListener l1 = new MockVetoableChangeListener();
        MockVetoableChangeListener l2 = new MockVetoableChangeListener();
        MockVetoChangeListener l3 = new MockVetoChangeListener();
        String propName = "property name";
        Object oldValue = new Integer(1);
        Object newValue = new Integer(5);

        support.addVetoableChangeListener(propName, l1);
        support.addVetoableChangeListener(propName, l2);
        support.addVetoableChangeListener(propName, l3);
        l1.clearLastEvent();
        l2.clearLastEvent();
        l3.clearLastEvent();
        try {
            support.fireVetoableChange(propName, oldValue, newValue);
            fail();
        } catch (PropertyVetoException e) {
View Full Code Here

    }

    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);
    }
View Full Code Here

    }

    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());
View Full Code Here

        support.removeVetoableChangeListener("property name", null);
    }

    public void testRemoveVetoableChangeListener() 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(propName, 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());
        assertEquals(propName, l2.lastEvent.getPropertyName());
        assertSame(oldValue, l2.lastEvent.getOldValue());
        assertSame(newValue, l2.lastEvent.getNewValue());
        assertSame(support, l2.lastEvent.getSource());

        support.removeVetoableChangeListener(propName, l1);
        l1.clearLastEvent();
        l2.clearLastEvent();
        support.fireVetoableChange(propName, oldValue, newValue);
        assertNull(l1.lastEvent);
        assertEquals(l2.lastEvent.getPropertyName(), propName);
        assertSame(l2.lastEvent.getOldValue(), oldValue);
        assertSame(l2.lastEvent.getNewValue(), newValue);
        assertSame(l2.lastEvent.getSource(), support);

        support.removeVetoableChangeListener(propName, l2);
        l1.clearLastEvent();
        l2.clearLastEvent();
        support.fireVetoableChange(propName, oldValue, newValue);
        assertNull(l1.lastEvent);
        assertNull(l2.lastEvent);

        // remove not-registered listener
View Full Code Here

    public void testSetBeanContext() throws PropertyVetoException {
        BeanContextChild peer = new MockBeanContextChild();
        MockBeanContextChildSupport support = new MockBeanContextChildSupport(
                peer);
        MockPropertyChangeListener l1 = new MockPropertyChangeListener();
        MockVetoableChangeListener l2 = new MockVetoableChangeListener();
        support.addPropertyChangeListener("beanContext", l1);
        support.addVetoableChangeListener("beanContext", l2);

        MockBeanContext ctx = new MockBeanContext();
        assertNull(support.getBeanContext());

        support.clearLastRecords();
        l1.clearLastEvent();
        l2.clearLastEvent();
        support.setBeanContext(null);
        assertNull(support.getBeanContext());
        assertNull(support.lastInitBeanContext);
        assertNull(l1.lastEvent);
        assertNull(l2.lastEvent);

        support.clearLastRecords();
        l1.clearLastEvent();
        l2.clearLastEvent();
        support.setBeanContext(ctx);
        assertSame(ctx, support.getBeanContext());
        assertSame(ctx, support.lastInitBeanContext);
        assertEquals("beanContext", l1.lastEvent.getPropertyName());
        assertNull(l1.lastEvent.getOldValue());
        assertSame(ctx, l1.lastEvent.getNewValue());
        assertSame(peer, l1.lastEvent.getSource());
        assertEquals("beanContext", l2.lastEvent.getPropertyName());
        assertNull(l2.lastEvent.getOldValue());
        assertSame(ctx, l2.lastEvent.getNewValue());
        assertSame(peer, l2.lastEvent.getSource());

        support.clearLastRecords();
        l1.clearLastEvent();
        l2.clearLastEvent();
        support.setBeanContext(ctx);
        assertSame(ctx, support.getBeanContext());
        assertNull(support.lastInitBeanContext);
        assertNull(l1.lastEvent);
        assertNull(l2.lastEvent);

        support.clearLastRecords();
        l1.clearLastEvent();
        l2.clearLastEvent();
        support.setBeanContext(null);
        assertNull(support.getBeanContext());
        assertNull(support.lastInitBeanContext);
        assertSame(ctx, support.lastReleaseBeanContext);
        assertEquals("beanContext", l1.lastEvent.getPropertyName());
View Full Code Here

    public void testSetBeanContext_VetoedByValidateMethod() {
        MockBeanContextChildSupport support = new MockBeanContextChildSupport();
        support.vetoBeanContext = true;
        MockPropertyChangeListener l1 = new MockPropertyChangeListener();
        MockVetoableChangeListener l2 = new MockVetoableChangeListener();
        support.addPropertyChangeListener("beanContext", l1);
        support.addVetoableChangeListener("beanContext", l2);

        MockBeanContext ctx = new MockBeanContext();
        assertNull(support.getBeanContext());

        support.clearLastRecords();
        l1.clearLastEvent();
        l2.clearLastEvent();
        try {
            support.setBeanContext(ctx);
            fail();
        } catch (PropertyVetoException e) {
            // expected
View Full Code Here

            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);
View Full Code Here

TOP

Related Classes of org.apache.harmony.beans.tests.support.beancontext.mock.MockVetoableChangeListener

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.