}
public void testGetMethodWithVectorMethods()
{
Class vector = new java.util.Vector().getClass();
JavaMethod jmAdd = new JavaMethod(vector, "add");
assertNotNull("jmAdd was null", jmAdd);
Method methodWithOneParam = jmAdd.getMethod(1);
assertEquals("Method with one param was not 'add'", "add", methodWithOneParam.getName());
Method methodWithTwoParams = jmAdd.getMethod(2);
assertEquals("Method with two params was not 'add'", "add", methodWithTwoParams.getName());
assertEquals("Method with one param return type was not 'boolean'", "boolean", methodWithOneParam.getReturnType().getName());
assertEquals("Method with two params return type was not 'void'", "void", methodWithTwoParams.getReturnType().getName());
boolean gotError = false;
try {
Method nonceMethod = jmAdd.getMethod(0); //should be no add() method with 0 params
nonceMethod.getName();
}
catch (NullPointerException ex) {
gotError = true;
}
assertTrue("Expected NullPointerException", gotError);
//on the other hand, make sure methods with 0 params work...
JavaMethod jmCapacity = new JavaMethod(vector, "capacity");
Method methodWithNoParams = jmCapacity.getMethod(0);
assertEquals("Method with no params was not 'capacity'", "capacity", methodWithNoParams.getName());
}