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

Examples of org.apache.harmony.beans.tests.support.mock.MockButton


    /*
     * listenerMethodName is invalid
     */
    public void testCreateClassObjectStringStringString_MethodInvalid() {
        MockTarget target = new MockTarget();
        MockButton button = new MockButton();
        PropertyChangeListener proxy = EventHandler.create(
                PropertyChangeListener.class, target, "text", "source.label",
                "propertyChange_invalid");
        assertTrue(Proxy.isProxyClass(proxy.getClass()));

        button.addPropertyChangeListener(proxy);
        String newLabel = "New Value: set text.";
        button.setLabel(newLabel);
        assertNull(target.getText());
    }
View Full Code Here


        assertNull(handler.getListenerMethodName());
    }

    public void testInvoke_1() throws SecurityException, NoSuchMethodException {
        MockTarget target = new MockTarget();
        MockButton button = new MockButton();
        PropertyChangeListener proxy = EventHandler.create(
                PropertyChangeListener.class, target, "setCalled");

        String action = "text";
        String eventPropertyName = "source.label";
        EventHandler handler = new EventHandler(target, action,
                eventPropertyName, null);
        Method listenerMethod = PropertyChangeListener.class.getMethod(
                "propertyChange", new Class[] { PropertyChangeEvent.class });
        PropertyChangeEvent event = new PropertyChangeEvent(button, "label",
                "1", "5");
        handler.invoke(proxy, listenerMethod, new Object[] { event });
        assertEquals(button.getLabel(), target.getText());
        Method equalsMethod = Object.class.getMethod("equals",
                new Class[] { Object.class });
        assertEquals(Boolean.FALSE, handler.invoke(proxy, equalsMethod,
                new String[] { "mock" }));
        // Test null method with non-proxy Object.
View Full Code Here

        }
    }

    public void testIncompatibleMethod() {
        MockTarget target = new MockTarget();
        MockButton button = new MockButton();
        PropertyChangeListener proxy = EventHandler.create(
                PropertyChangeListener.class, target, "Text", "source");
        assertTrue(Proxy.isProxyClass(proxy.getClass()));

        button.addPropertyChangeListener(proxy);
        String newLabel = "New Value: set text.";
        try {
            button.setLabel(newLabel);
            fail("Should throw RuntimeException.");
        } catch (RuntimeException e) {

        }
    }
View Full Code Here

        }
    }

    public void testCoverage_1() {
        MockTarget target = new MockTarget();
        MockButton button = new MockButton();
        PropertyChangeListener proxy = EventHandler.create(
                PropertyChangeListener.class, target, "Text", "");
        assertTrue(Proxy.isProxyClass(proxy.getClass()));

        button.addPropertyChangeListener(proxy);
        String newLabel = "New Value: set text.";
        try {
            button.setLabel(newLabel);
            fail("Should throw RuntimeException.");
        } catch (RuntimeException e) {
        }

    }
View Full Code Here

TOP

Related Classes of org.apache.harmony.beans.tests.support.mock.MockButton

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.