Package java.beans

Examples of java.beans.Expression


    /*
     * Test the method getValue() with the special method Class.forName().
     */
    public void testGetValue_UnboundedClassForName() throws Exception {
        Object[] arguments = new String[] { Expression.class.getName() };
        Expression t = new Expression(Class.class, "forName", arguments);
        assertSame(Expression.class, t.getValue());

        // t = new Expression(String.class, "forName", arguments);
        // assertSame(this.getClass(), t.getValue());
    }
View Full Code Here


     * Test the method getValue() with a normal array object, the method name
     * "get" and valid arguments.
     */
    public void testGetValue_UnboundedArrayGet() throws Exception {
        Object[] array = new Object[] { "test" };
        Expression t = new Expression(array, "get", new Object[] { new Integer(
                0) });
        assertEquals("test", t.getValue());
    }
View Full Code Here

     * Test the method getValue() with a normal array object, the method name
     * "getInt" and invalid arguments.
     */
    public void testGetValue_UnboundedArrayInvalidSetInt() throws Exception {
        int[] array = new int[] { 1 };
        Expression t = new Expression(array, "getInt",
                new Object[] { new Integer(0) });
        try {
            t.getValue();
            fail("Should throw NoSuchMethodException!");
        } catch (NoSuchMethodException ex) {
            // expected
        }
    }
View Full Code Here

     * Test the method getValue() with a normal array object, the method name
     * "gets".
     */
    public void testGetValue_UnboundedArrayInvalidName() throws Exception {
        Object[] array = new Object[] { "test" };
        Expression t = new Expression(array, "gets", new Object[] {
                new Integer(0), new Object() });
        try {
            t.getValue();
            fail("Should throw NoSuchMethodException!");
        } catch (NoSuchMethodException ex) {
            // expected
        }
    }
View Full Code Here

     * Note: decided by definition position!
     */
    public void testGetValue_UnboundedPrimitiveVSWrapper() throws Exception {
        MockObject mo = new MockObject(false);
        Object[] arguments = new Object[] { new Integer(1) };
        Expression t = new Expression(mo, "methodB", arguments);
        assertEquals("methodB2", t.getValue());
        MockObject.assertCalled("methodB2", arguments);

        arguments = new Object[] { Boolean.FALSE };
        t = new Expression(mo, "methodB", arguments);
        assertEquals("methodB3", t.getValue());
        MockObject.assertCalled("methodB3", arguments);
    }
View Full Code Here

     * valid arguments.
     */
    public void testGetValue_UnboundedVoidMethod() throws Exception {
        MockObject mo = new MockObject(false);
        Object[] arguments = new Object[] { new Integer(1) };
        Expression t = new Expression(mo, "voidMethod", arguments);
        assertNull(t.getValue());
        MockObject.assertCalled("voidMethod2", arguments);
    }
View Full Code Here

     * package.
     */
    public void testGetValue_ProtectedMethodWithPackage() throws Exception {
        DefaultPersistenceDelegate dpd = new DefaultPersistenceDelegate();
        Object[] arguments = new Object[] { "test", "test" };
        Expression t = new Expression(dpd, "mutatesTo", arguments);
        try {
            t.getValue();
            fail("Should throw NoSuchMethodException!");
        } catch (NoSuchMethodException e) {
            // expected
        }
    }
View Full Code Here

     */
    public void testGetValue_ApplicableViaTypeConversion() throws Exception {
        MockObject mo = new MockObject(false);
        // mo.methodB('c');
        Object[] arguments = new Object[] { new Character((char) 1) };
        Expression t = new Expression(mo, "methodB", arguments);
        try {
            t.getValue();
            fail("Should throw NoSuchMethodException!");
        } catch (NoSuchMethodException e) {
            // expected
        }
    }
View Full Code Here

        }
    }

    public void testGetValue_returnNull() throws Exception {
        MockTarget target = new MockTarget();
        Expression e = new Expression(target, "aMethod", new Object[] {});
        Object got = e.getValue();
        assertTrue(MockTarget.isCalled());
        got = e.getValue();
        assertFalse(MockTarget.isCalled());
    }
View Full Code Here

        // TBD
    }

    public void testInstantiate_Normal() throws Exception {
        Object obj = new int[] { 1, 2, 3 };
        Expression exp = pd.instantiate(obj, new Encoder());
        assertSame(obj, exp.getValue());
        assertSame(Array.class, exp.getTarget());
        assertEquals("newInstance", exp.getMethodName());
        assertEquals(2, exp.getArguments().length);
        assertSame(Integer.TYPE, exp.getArguments()[0]);
        assertEquals(new Integer(3), exp.getArguments()[1]);
    }
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.