[prev in list] [next in list] [prev in thread] [next in thread]
List: bsf-dev
Subject: Testcase for MethodUtils class
From: "Sanka Samaranayake" <sanka () opensource ! lk>
Date: 2004-06-21 2:58:19
Message-ID: 1996.220.247.253.77.1087786699.squirrel () 220 ! 247 ! 253 ! 77
[Download RAW message or body]
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 <sanka@opensource.lk>
* @author Nilupa Bandara <nilupa@opensource.lk>
*
*/
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: bsf-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: bsf-dev-help@jakarta.apache.org
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic