1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
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 |
| |
19 |
| |
20 |
| |
21 |
| |
22 |
| public class MethodCallTest extends TestCase |
23 |
| { |
24 |
| Log log_ = LogFactory.getLog(MethodCallTest.class); |
25 |
| |
26 |
2
| public MethodCallTest(String name)
|
27 |
| { |
28 |
2
| super(name);
|
29 |
| } |
30 |
| |
31 |
2
| protected void setUp() throws Exception
|
32 |
| { |
33 |
2
| super.setUp();
|
34 |
2
| log_.info("setUp() ....");
|
35 |
| } |
36 |
| |
37 |
2
| protected void tearDown() throws Exception
|
38 |
| { |
39 |
2
| super.tearDown();
|
40 |
| } |
41 |
| |
42 |
| |
43 |
| |
44 |
2
| public void testBasic() throws Throwable
|
45 |
| { |
46 |
2
| Integer i = 1;
|
47 |
2
| Method method = Foo.class.getDeclaredMethod("setFoo",
|
48 |
| new Class[]{Integer.class}); |
49 |
| |
50 |
2
| Object[] args = new Object[]{i};
|
51 |
2
| Foo foo = new Foo();
|
52 |
2
| MethodCall mc = new MethodCall(method, args, foo);
|
53 |
| |
54 |
2
| mc.invoke();
|
55 |
| } |
56 |
| |
57 |
2
| public static Test suite() throws Exception
|
58 |
| { |
59 |
2
| return new TestSuite(MethodCallTest.class);
|
60 |
| } |
61 |
| |
62 |
| |
63 |
0
| public static void main(String[] args) throws Exception
|
64 |
| { |
65 |
0
| junit.textui.TestRunner.run(MethodCallTest.suite());
|
66 |
| } |
67 |
| |
68 |
| public static class Foo |
69 |
| { |
70 |
| Integer i; |
71 |
| |
72 |
2
| public void setFoo(Integer i)
|
73 |
| { |
74 |
2
| this.i = i;
|
75 |
| } |
76 |
| |
77 |
0
| public Integer getFoo()
|
78 |
| { |
79 |
0
| return i;
|
80 |
| } |
81 |
| } |
82 |
| } |