FileDocCategorySizeDatePackage
TestParamReader.javaAPI DocApache Axis 1.43675Sat Apr 22 18:57:26 BST 2006test.utils.bytecode

TestParamReader

public class TestParamReader extends junit.framework.TestCase
Description User: pengyu Date: Sep 12, 2003 Time: 11:51:28 PM

Fields Summary
private TestDerivedClass
test
private org.apache.axis.utils.bytecode.ParamReader
reader
Constructors Summary
public TestParamReader(String name)

       
        super(name);
    
Methods Summary
public static voidmain(java.lang.String[] arg)

        TestParamReader t = new TestParamReader("");
        t.testGetConstructorParameters();
    
protected voidsetup()

        test = this.new TestDerivedClass(1);
    
public static junit.framework.Testsuite()

        return new TestSuite(TestParamReader.class);
    
public voidtestGetConstructorParameters()

        try {
            reader = new ParamReader(TestDerivedClass.class);
            assertTrue("should not be null", reader != null);
            Constructor ctor = TestDerivedClass.class.getConstructor(new Class[] {
                TestParamReader.class, Integer.TYPE});

            String [] params = reader.getParameterNames(ctor);
            assertTrue("params is not null" , params.length == 2);
            assertTrue("param name is 'in'", params[1].equals("in"));
        }
        catch (IOException e) {
            fail("failed to setup paramreader:" + e.getMessage());
        }
        catch (NoSuchMethodException e) {
            fail(e.getMessage());
        }

    
public voidtestGetMethodParameters()

        try {
            reader = new ParamReader(TestDerivedClass.class);
        } catch (IOException e) {
            fail("failed to setup paramreader:" + e.getMessage());
        }
        assertTrue("should not be null", reader != null);
        //first get method1
        try {
            Method method1 = TestDerivedClass.class.getMethod("method1", new Class[] {Boolean.TYPE});
            String [] params = reader.getParameterNames(method1);
            assertTrue("one parameter only",params.length == 1);
            assertTrue("It is 'boolValue'", params[0].equals("boolValue"));

            Method method2 = TestDerivedClass.class.getMethod("method2", new Class[] {Boolean.TYPE});
            params = reader.getParameterNames(method2);
            assertTrue("one parameter only",params.length == 1);
            assertTrue("It is 'boolValue'", params[0].equals("boolValue"));
            method2= TestDerivedClass.class.getMethod("method2", new Class[] {Integer.TYPE});
            params = reader.getParameterNames(method2);
            assertTrue("one parameter only",params.length == 1);
            assertTrue("It is 'intValue'", params[0].equals("intValue"));

            Method method3 = TestDerivedClass.class.getMethod("subClassInherit", new Class[] {Integer.TYPE});
            params = reader.getParameterNames(method3);
            assertTrue("It should not find inherited method", params == null);
        } catch (NoSuchMethodException e) {
            fail(e.toString());
        } catch (SecurityException e) {
            fail(e.toString());
        }