Hi,

can anyone commit this testcase for MethodUtils class

Regards !!

Sanka

******************************************************
******************************************************


package org.apache.bsf.test.utilTests;

import org.apache.bsf.util.MethodUtils;

import junit.framework.TestCase;

/**
 * This is a testcase for MethodUtils class
 *
 * @author Sanka Samaranayake <[EMAIL PROTECTED]>
 * @author Nilupa Bandara     <[EMAIL PROTECTED]>
 *
 */
public class MethodUtilsTest extends TestCase {

        public void testGetConstructor() {
                try{
                        MethodUtils.getConstructor(MethodUtilsBean.class,null);
                }catch(NoSuchMethodException nsme){
                        fail(nsme.getMessage());
                }

                try{
                        MethodUtils.getConstructor(MethodUtilsBean.class,
                                        new Class[]{String.class});
                        fail("calling a non existing constructor with parms");
                }catch(NoSuchMethodException nsme){
                }

        }

        /*
         * Class under test for Method getMethod(Class, String, Class[], boolean)
         */
        public void testGetMethodClassStringClassArrayboolean() {

                try {
                        MethodUtils.getMethod(MethodUtilsBean.class, "setValues",
                                        new Class[]{Integer.TYPE, Integer.TYPE}, 
false);
                } catch (NoSuchMethodException nsme) {
                        fail("should not throw an exception when there is a exact 
method");
                }

                try {
                        MethodUtils.getMethod(MethodUtilsBean.class, "setValues",
                                        new Class[]{Integer.TYPE, Short.TYPE}, false);
                }catch (NoSuchMethodException nsme){
                        fail("should not throw an exception when there is an 
appropriate" +
                                        "method");
                }

                try {
                        MethodUtils.getMethod(MethodUtilsBean.class, "setValues",
                                        new Class[] {Integer.TYPE, String.class}, 
false);
                        fail("should throw a NoSuchMethodException for a non " +
                                        "existing method");
                }catch (NoSuchMethodException nsme){
                }
        }

        /*
         * Class under test for Method getMethod(Object, String, Class[])
         */
        public void testGetMethodObjectStringClassArray() {

                MethodUtilsBean bean = new MethodUtilsBean();
                try {
                        MethodUtils.getMethod(bean, "getValues", new 
Class[]{Integer.TYPE});
                } catch (NoSuchMethodException nsme) {
                        fail("should not throw an exception when there is a excat 
match");
                }

                try {
                        MethodUtils.getMethod(bean, "getValues", new 
Class[]{Short.TYPE});

                }catch (NoSuchMethodException nsme) {
                        fail("should not throw an exception when there is an 
appropriate" +
                                        "method");
                }

                try {
                        MethodUtils.getMethod(bean,"getValues", new 
Class[]{String.class});
                        fail("should throw a NoSuchMethodException");
                } catch (NoSuchMethodException nsme){
                }

        }

}




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to