Package java.beans

Examples of java.beans.Expression


    /*
     * Test the method getValue() with a null method name.
     */
    public void testGetValue_UnboundedNullMethodName() throws Exception {
        MockObject mo = new MockObject(false);
        Expression t = new Expression(mo, null, new Object[] { null, null });
        try {
            t.getValue();
            fail("Should throw NullPointerException!");
        } catch (NullPointerException ex) {
            // expected
        }
    }
View Full Code Here


     * Test the method getValue() with a normal object, a valid method and
     * invalid arguments (in terms of type, numbers, etc.).
     */
    public void testGetValue_UnboundedInvalidArguments() throws Exception {
        MockObject mo = new MockObject(false);
        Expression t = new Expression(mo, "method", new Object[] {
                new Object(), new Object(), new Object() });
        try {
            t.getValue();
            fail("Should throw NoSuchMethodException!");
        } catch (NoSuchMethodException ex) {
            // expected
        }
    }
View Full Code Here

     * valid arguments.
     */
    public void testGetValue_UnboundedOverloadedMethods() throws Exception {
        MockObject mo = new MockObject(false);
        Object[] arguments = new Object[] { new Object() };
        Expression t = new Expression(mo, "method", arguments);
        assertEquals("method2", t.getValue());
        MockObject.assertCalled("method2", arguments);

        arguments = new Object[] { "test" };
        t = new Expression(mo, "method", arguments);
        assertEquals("method3", t.getValue());
        MockObject.assertCalled("method3", arguments);
    }
View Full Code Here

    /*
     * Test the method getValue() with a normal object, the method name "new"
     * and valid arguments.
     */
    public void testGetValue_UnboundedNormalConstructor() throws Exception {
        Expression t = new Expression(MockObject.class, "new", new Object[0]);
        t.getValue();
        MockObject.assertCalled("new0", new Object[0]);
        t = new Expression(MockObject.class, "new", null);
        assertTrue(t.getValue() instanceof MockObject);
        MockObject.assertCalled("new0", new Object[0]);
    }
View Full Code Here

    /*
     * Test the method getValue() with a normal object, the method name "new"
     * that throws an exception and valid arguments.
     */
    public void testGetValue_UnboundedExceptionalConstructor() throws Exception {
        Expression t = new Expression(MockObject.class, "new", new Object[] {
                null, null });
        try {
            t.getValue();
            fail("Should throw NullPointerException!");
        } catch (NullPointerException ex) {
            // expected
        }
        MockObject.assertCalled("new4", new Object[] { null, null });
View Full Code Here

    /*
     * Test the method getValue() with a normal object, the method name "new"
     * and invalid arguments (in terms of type, numbers, etc.).
     */
    public void testGetValue_UnboundedNonExistingConstructor() throws Exception {
        Expression t = new Expression(MockObject.class, "new", new Object[] {
                null, null, null });
        try {
            t.getValue();
            fail("Should throw NoSuchMethodException!");
        } catch (NoSuchMethodException ex) {
            // expected
        }
    }
View Full Code Here

     *
     * Note: decided by definition position.
     */
    public void testGetValue_UnboundedOverloadedConstructors() throws Exception {
        Object[] arguments = new Object[] { new Object() };
        Expression t = new Expression(MockObject.class, "new", arguments);
        t.getValue();
        MockObject.assertCalled("new2", arguments);

        //FIXME: the following 2 commented assert cannot pass neither in RI nor in Harmony (HARMONY-4392),
        // waiting for dev-list approval to fix Harmony implementation following spec
        arguments = new Object[] { "test" };
        t = new Expression(MockObject.class, "new", arguments);
        assertTrue(t.getValue() instanceof MockObject);
//         MockObject.assertCalled("new3", arguments);

        arguments = new Object[] { new Integer(1) };
        t = new Expression(MockObject.class, "new", arguments);
        assertTrue(t.getValue() instanceof MockObject);
//        MockObject.assertCalled("new1-2", arguments);
    }
View Full Code Here

     * and valid arguments.
     */
    public void testGetValue_UnboundedNormalStaticMethodViaClass()
            throws Exception {
        Object[] arguments = new Object[] { new Object() };
        Expression t = new Expression(MockObject.class, "staticMethod",
                arguments);
        assertEquals("staticMethod", t.getValue());
        MockObject.assertCalled("staticMethod", arguments);
    }
View Full Code Here

     */
    public void testGetValue_UnboundedNormalStaticMethodViaObject()
            throws Exception {
        MockObject mo = new MockObject(false);
        Object[] arguments = new Object[] { new Object() };
        Expression t = new Expression(mo, "staticMethod", arguments);
        assertEquals("staticMethod", t.getValue());
        MockObject.assertCalled("staticMethod", arguments);
    }
View Full Code Here

     * a method of the same signature as Class.forName(String), a static method
     * name "forName" and valid argument "string".
     */
    public void testGetValue_UnboundedAmbitiousStaticMethod() throws Exception {
        Object[] arguments = new Object[] { "test" };
        Expression t = new Expression(MockObject.class, "forName", arguments);
        assertNull(t.getValue());
        MockObject.assertCalled("forName", arguments);

        t = new Expression(String.class, "forName",
                new Object[] { "java.lang.String" });
        assertSame(String.class, t.getValue());
    }
View Full Code Here

TOP

Related Classes of java.beans.Expression

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.