FileDocCategorySizeDatePackage
TestJavaClass.javaAPI DocApache Axis 1.42574Sat Apr 22 18:57:28 BST 2006test.utils.cache

TestJavaClass

public class TestJavaClass extends TestCase

Fields Summary
Constructors Summary
public TestJavaClass(String name)

        super(name);
    
Methods Summary
protected voidsetup()

    
public static junit.framework.Testsuite()

        return new TestSuite(TestJavaClass.class);
    
public voidtestGetJavaClass()

        Class c = new java.util.Date().getClass(); 
        JavaClass jc = new JavaClass(c);
        assertNotNull("The JavaClass was null", jc);
        assertTrue("JavaClass name is not 'java.util.Date', it is: " + jc.getClass().getName(),
                   jc.getJavaClass().getName().equals("java.util.Date"));
        assertTrue("JavaClass cut off the name of the real class.",
                   !jc.getJavaClass().getName().equals("java.util.D"));
    
public voidtestGetMethod()

        Class v = new java.util.Vector().getClass(); 
        Class st = new java.util.StringTokenizer("some string").getClass();
        JavaClass jcVec = new JavaClass(v);
        JavaClass jcST = new JavaClass(st);

        Method countTkns = jcST.getMethod("countTokens")[0];
        Method nextTkn = jcST.getMethod("nextToken")[0];

        Method[] adds = jcVec.getMethod("add");

        assertEquals("countTkns name was not 'countTokens', it is: " + countTkns.getName(),
                     "countTokens", countTkns.getName());
        assertEquals("nextTkn name was not 'nextToken', it is: " + nextTkn.getName(),
                     "nextToken", nextTkn.getName());

        assertEquals("There are not 2 add methods as expected, there are " + adds.length, 2, adds.length);

        for (int i = 0; i < adds.length; ++i) {
            if (adds[i].getReturnType().equals(boolean.class)) {
                assertEquals("Unexpected boolean add signature",
                   "public synchronized boolean java.util.Vector.add(java.lang.Object)",
                   adds[i].toString());
            }
            else {
                assertEquals("Unexpected void add signature",
                    "public void java.util.Vector.add(int,java.lang.Object)",
                    adds[i].toString());
            }
        }
    
public voidtestNoSuchMethod()

        Class v = new java.util.Vector().getClass(); 
        JavaClass jcVec = new JavaClass(v);

        Method[] gorp = jcVec.getMethod("gorp");
        assertNull("gorp was not null", gorp);