1 7 8 package org.jboss.cache.pojo.util; 9 10 import junit.framework.Test; 11 import junit.framework.TestCase; 12 import junit.framework.TestSuite; 13 import org.apache.commons.logging.Log; 14 import org.apache.commons.logging.LogFactory; 15 16 import java.lang.reflect.Method ; 17 18 21 22 public class MethodCallTest extends TestCase 23 { 24 Log log_ = LogFactory.getLog(MethodCallTest.class); 25 26 public MethodCallTest(String name) 27 { 28 super(name); 29 } 30 31 protected void setUp() throws Exception 32 { 33 super.setUp(); 34 log_.info("setUp() ...."); 35 } 36 37 protected void tearDown() throws Exception 38 { 39 super.tearDown(); 40 } 41 42 44 public void testBasic() throws Throwable 45 { 46 Integer i = 1; 47 Method method = Foo.class.getDeclaredMethod("setFoo", 48 new Class []{Integer .class}); 49 50 Object [] args = new Object []{i}; 51 Foo foo = new Foo(); 52 MethodCall mc = new MethodCall(method, args, foo); 53 54 mc.invoke(); 55 } 56 57 public static Test suite() throws Exception 58 { 59 return new TestSuite(MethodCallTest.class); 60 } 61 62 63 public static void main(String [] args) throws Exception 64 { 65 junit.textui.TestRunner.run(MethodCallTest.suite()); 66 } 67 68 public static class Foo 69 { 70 Integer i; 71 72 public void setFoo(Integer i) 73 { 74 this.i = i; 75 } 76 77 public Integer getFoo() 78 { 79 return i; 80 } 81 } 82 } 83 | Popular Tags |