1 15 package org.apache.hivemind.methodmatch; 16 17 import java.lang.reflect.Method ; 18 19 import junit.framework.AssertionFailedError; 20 21 import org.apache.hivemind.service.MethodSignature; 22 import org.apache.hivemind.test.HiveMindTestCase; 23 24 29 public abstract class AbstractMethodTestCase extends HiveMindTestCase 30 { 31 protected MethodSignature getMethodSignature(Class target, String name) 32 { 33 Method [] methods = target.getMethods(); 34 35 for (int i = 0; i < methods.length; i++) 36 { 37 if (methods[i].getName().equals(name)) 38 return new MethodSignature(methods[i]); 39 } 40 41 throw new AssertionFailedError( 42 "Class " + target.getName() + " does not contain a method named: '" + name + "'."); 43 } 44 45 protected MethodSignature getMethodSignature(Object object, String name) 46 { 47 return getMethodSignature(object.getClass(), name); 48 } 49 50 } 51 | Popular Tags |