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

    /*
     * Class under test for Object create(Class, Object, String)
     */
    public void testCreateClassObjectString() {
        MockTarget target = new MockTarget();
        MockButton button = new MockButton();
        PropertyChangeListener proxy = EventHandler.create(
                PropertyChangeListener.class, target, "setCalled");
        button.addPropertyChangeListener(proxy);
        button.setLabel("new label value");
        assertTrue(Proxy.isProxyClass(proxy.getClass()));
        assertTrue(target.isCalled());
    }
View Full Code Here

    /*
     * the target's method is null
     */
    public void testCreateClassObjectString_MethodNull() {
        MockTarget target = new MockTarget();
        MockButton button = new MockButton();
        try {
            PropertyChangeListener proxy = EventHandler.create(
                    PropertyChangeListener.class, target, null);
            fail("Should throw NullPointerException.");
        } catch (NullPointerException e) {
        }
        PropertyChangeListener proxy = EventHandler.create(
                PropertyChangeListener.class, target, "");
        button.addPropertyChangeListener(proxy);
        try {
            button.setLabel("new label value");
            fail("Should throw RuntimeException.");
        } catch (RuntimeException e) {
        }
        assertTrue(Proxy.isProxyClass(proxy.getClass()));
    }
View Full Code Here

    /*
     * the target's method is invalid
     */
    public void testCreateClassObjectString_MethodEmpty() {
        MockTarget target = new MockTarget();
        MockButton button = new MockButton();
        PropertyChangeListener proxy = EventHandler.create(
                PropertyChangeListener.class, target, "");
        button.addPropertyChangeListener(proxy);
        try {
            button.setLabel("new label value");
            fail("Should throw RuntimeException.");
        } catch (RuntimeException e) {
        }
        assertTrue(Proxy.isProxyClass(proxy.getClass()));
    }
View Full Code Here

    /*
     * Class under test for Object create(Class, Object, String, String)
     */
    public void testCreateClassObjectStringString() {
        MockTarget target = new MockTarget();
        MockButton button = new MockButton();
        PropertyChangeListener proxy = EventHandler.create(
                PropertyChangeListener.class, target, "text", "source.label");
        assertTrue(Proxy.isProxyClass(proxy.getClass()));

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

    /*
     * the action is null
     */
    public void testCreateClassObjectStringString_ActionNull() {
        MockTarget target = new MockTarget();
        MockButton button = new MockButton();
        try {
            PropertyChangeListener proxy = EventHandler.create(
                    PropertyChangeListener.class, target, null, "source.label");
            fail("should throw NPE");
        } catch (NullPointerException e) {
View Full Code Here

    /*
     * action is invalid
     */
    public void testCreateClassObjectStringString_ActionInvalid() {
        MockTarget target = new MockTarget();
        MockButton button = new MockButton();
        PropertyChangeListener proxy = EventHandler.create(
                PropertyChangeListener.class, target, "action_invalid",
                "source.label");
        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.