Package java.beans

Examples of java.beans.Statement


     * Test the method execute() with the Class object, a static method name and
     * valid arguments.
     */
    public void testExecute_NormalStaticMethodViaClass() throws Exception {
        Object[] arguments = new Object[] { new Object() };
        Statement t = new Statement(MockObject.class, "staticMethod", arguments);
        t.execute();
        MockObject.assertCalled("staticMethod", arguments);
    }
View Full Code Here


     * arguments.
     */
    public void testExecute_NormalStaticMethodViaObject() throws Exception {
        MockObject mo = new MockObject(false);
        Object[] arguments = new Object[] { new Object() };
        Statement t = new Statement(mo, "staticMethod", arguments);
        t.execute();
        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 testExecute_AmbiguousStaticMethod() throws Exception {
        Object[] arguments = new String[] { "test" };
        Statement t = new Statement(MockObject.class, "forName", arguments);
        t.execute();
        MockObject.assertCalled("forName", arguments);

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

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

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

     * Test the method execute() with a normal array object, the method name
     * "get" and valid and invalid arguments.
     */
    public void testExecute_ArrayGet() throws Exception {
        Object[] array = new Object[] { "test" };
        Statement t = new Statement(array, "get",
                new Object[] { new Integer(0) });
        t.execute();

        array = new Object[] { "test" };
        t = new Statement(array, "get", new Object[0]);
        try {
            t.execute();
            fail("Should throw ArrayIndexOutOfBoundsException!");
        } catch (ArrayIndexOutOfBoundsException ex) {
            // expected
        }
    }
View Full Code Here

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

     * Test the method execute() with a normal array object, the method name
     * "set" and null index argument.
     */
    public void testExecute_ArrayNullIndex() throws Exception {
        Object[] array = new Object[] { "test" };
        Statement t = new Statement(array, "set",
                new Object[] { null, "test2" });
        try {
            t.execute();
            fail("Should throw NullPointerException!");
        } catch (NullPointerException ex) {
            // expected
        }
    }
View Full Code Here

     * Test the method execute() with a normal array object, the method name
     * "set" and invalid arguments.
     */
    public void testExecute_ArrayInvalidSet() throws Exception {
        Object[] array = new Object[] { "test" };
        Statement t = new Statement(array, "set", new Object[] {
                new Integer(0), "test2" });
        t.execute();
        assertEquals("test2", array[0]);

        try {
            t = new Statement(array, "set", new Object[] { "testtest", "test2",
                    new Object() });
            t.execute();
            fail("Should throw ClassCastException!");
        } catch (ClassCastException ex) {
            // expected
        }

        t = new Statement(array, "set", new Object[] { new Integer(0) });
        try {
            t.execute();
            fail("Should throw ArrayIndexOutOfBoundsException!");
        } catch (ArrayIndexOutOfBoundsException ex) {
            // expected
        }
    }
View Full Code Here

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

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

TOP

Related Classes of java.beans.Statement

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.