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

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


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


    /*
     * property name is null
     */
    public void testCreateClassObjectStringStringString_PropertyNull() {
        MockTarget target = new MockTarget();
        MockButton button = new MockButton();
        String newLabel = "New Value: set text.";
        PropertyChangeListener proxy = EventHandler.create(
                PropertyChangeListener.class, target, "text", null,
                "propertyChange");

        assertTrue(Proxy.isProxyClass(proxy.getClass()));
        button.addPropertyChangeListener(proxy);

        try {
            button.setLabel(newLabel);
            fail("Should throw RuntimeException.");
        } catch (RuntimeException e) {
        }
    }
View Full Code Here

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

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

    /*
     * 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

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

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

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.