Package java.beans

Examples of java.beans.Statement.execute()


     */
    public void testArraySetter() throws Exception {
        int[] a = { 1, 2, 3 };
        Statement s = new Statement(a, "set", new Object[] { new Integer(1),
                new Integer(7) });
        s.execute();
        assertEquals(7, a[1]);
    }

    /**
     * The test checks the method execute() for static method
View Full Code Here


     */
    public void testStatic() throws Exception {
        int currentId = getTestId();
        Statement s = new Statement(StatementTest.class, "nextTestId",
                new Object[] {});
        s.execute();
        assertEquals(++currentId, getTestId());
    }

    /**
     * The test checks the method execute() if exception is thrown on method
View Full Code Here

        Bean bean = new Bean("hello");
        Statement s = new Statement(bean, "setChar", new Object[] {
                new Integer(5), new Character('a') });

        try {
            s.execute();
            fail("Exception must be thrown while Bean.setChar(5, 'a') "
                    + "invocation.");
        } catch (Exception e) {
            // correct situation
        }
View Full Code Here

    public void testExceptionThrownOnStaticMethodCall() throws Exception {
        Statement s = new Statement(StatementTest.class, "methodWithException",
                new Object[] {});

        try {
            s.execute();
            fail("Exception must be thrown with methodWithException call");
        } catch (SampleException se) {
            // SampleException is thrown as expected
        }
    }
View Full Code Here

     * The test checks the method execute() with array as parameter
     */
    public void testMethodWithArrayParam() throws Exception {
        Statement s = new Statement(StatementTest.class, "methodWithIntArray",
                new Object[] { new int[] { 3 } });
        s.execute();
    }

    /**
     *
     */
 
View Full Code Here

     * valid arguments.
     */
    public void testExecute_NormalInstanceMethod() throws Exception {
        MockObject mo = new MockObject(false);
        Statement t = new Statement(mo, "method", new Object[0]);
        t.execute();
        MockObject.assertCalled("method1", new Object[0]);
        t = new Statement(mo, "method", null);
        t.execute();
        MockObject.assertCalled("method1", new Object[0]);
    }
View Full Code Here

        MockObject mo = new MockObject(false);
        Statement t = new Statement(mo, "method", new Object[0]);
        t.execute();
        MockObject.assertCalled("method1", new Object[0]);
        t = new Statement(mo, "method", null);
        t.execute();
        MockObject.assertCalled("method1", new Object[0]);
    }

    /*
     * Test the method execute() with a normal object, normal method and null
View Full Code Here

    public void testExecute_NormalInstanceMethodNull() throws Exception {
        MockObject mo = new MockObject(false);
        Object[] arguments = new Object[] { null, null, null };
        Statement t = new Statement(mo, "method", arguments);

        t.execute();
        MockObject.assertCalled("method5", arguments);
    }

    /*
     * Test the method execute() with a normal object, a valid method that
View Full Code Here

     */
    public void testExecute_ExceptionalMethod() throws Exception {
        MockObject mo = new MockObject(false);
        Statement t = new Statement(mo, "method", new Object[] { null, null });
        try {
            t.execute();
            fail("Should throw NullPointerException!");
        } catch (NullPointerException ex) {
            // expected
        }
        MockObject.assertCalled("method4", new Object[] { null, null });
View Full Code Here

    public void testExecute_NonExistingMethod() throws Exception {
        MockObject mo = new MockObject(false);
        Statement t = new Statement(mo, "method_not_existing", new Object[] {
                null, null });
        try {
            t.execute();
            fail("Should throw NoSuchMethodException!");
        } catch (NoSuchMethodException ex) {
            // expected
        }
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.