{
dummy d = new dummy();
// Check that we can create and execute a statement
Object arg1[] = {"test"};
Statement stmt = new Statement(d, "method", arg1);
harness.check(stmt != null);
harness.check(stmt.getTarget() == d);
harness.check(stmt.getMethodName().equals("method"));
try
{
stmt.execute();
}
catch (Exception e)
{
harness.fail("Statement execute");
}
harness.check(d.s.equals("test"));
harness.check(d.x == 5);
// Check that we can create and execute a statement and that a
// wrapper class resolves to a method taking a primitive.
Object arg2[] = {"test", new Integer(6) };
stmt = new Statement(d, "method", arg2);
harness.check(stmt != null);
Object stmtArgs[] = stmt.getArguments();
harness.check(stmtArgs.length == arg2.length && stmtArgs[0] == arg2[0]
&& stmtArgs[1] == arg2[1]);
try
{
stmt.execute();
}
catch (Exception e)
{
harness.fail("Statement execute");
}
harness.check(d.s.equals("test"));
harness.check(d.x == 7);
// Check that we can create and execute a statement for a static method.
Object arg3[] = {new Integer(1)};
stmt = new Statement(this, "test1", arg3);
try
{
stmt.execute();
}
catch (Exception e)
{
harness.fail("Static method execute " + e.toString());
}
harness.check(x == 1);
// Check that we can call get and set on an array object in a statement
int iarray[] = {1, 2, 3, 4, 5};
Object arg4[] = { new Integer(2), new Integer(6) };
stmt = new Statement(iarray, "set", arg4);
try
{
stmt.execute();
}
catch (Exception e)
{
harness.fail("Array set");
}
Object arg5[] = { new Integer(2) };
stmt = new Statement(iarray, "get", arg5);
try
{
stmt.execute();
}
catch (Exception e)
{
harness.fail("Array get");
}