1 package org.apache.velocity.test.util.introspection;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import junit.framework.Test;
23 import junit.framework.TestSuite;
24
25 import org.apache.velocity.app.Velocity;
26 import org.apache.velocity.runtime.log.Log;
27 import org.apache.velocity.runtime.log.NullLogChute;
28 import org.apache.velocity.test.BaseTestCase;
29 import org.apache.velocity.util.introspection.ClassMap;
30
31
32
33
34 public class ClassMapTestCase
35 extends BaseTestCase
36 {
37 public ClassMapTestCase(final String name)
38 throws Exception
39 {
40 super(name);
41 }
42
43 public static Test suite()
44 {
45 return new TestSuite(ClassMapTestCase.class);
46 }
47
48 public void setUp()
49 throws Exception
50 {
51 Velocity.setProperty(
52 Velocity.RUNTIME_LOG_LOGSYSTEM_CLASS, NullLogChute.class.getName());
53
54 Velocity.init();
55 }
56
57 public void tearDown()
58 {
59 }
60
61 public void testPrimitives()
62 throws Exception
63 {
64 Log log = Velocity.getLog();
65
66 ClassMap c = new ClassMap(TestClassMap.class, log);
67 assertNotNull(c.findMethod("setBoolean", new Object[] { Boolean.TRUE }));
68 assertNotNull(c.findMethod("setByte", new Object[] { new Byte((byte) 4)}));
69 assertNotNull(c.findMethod("setCharacter", new Object[] { new Character('c')}));
70 assertNotNull(c.findMethod("setDouble", new Object[] { new Double(8.0) }));
71 assertNotNull(c.findMethod("setFloat", new Object[] { new Float(15.0) }));
72 assertNotNull(c.findMethod("setInteger", new Object[] { new Integer(16) }));
73 assertNotNull(c.findMethod("setLong", new Object[] { new Long(23) }));
74 assertNotNull(c.findMethod("setShort", new Object[] { new Short((short)42)}));
75 }
76
77 public static final class TestClassMap
78 {
79 public void setBoolean(boolean b)
80 {
81 }
82
83 public void setByte(byte b)
84 {
85 }
86
87 public void setCharacter(char c)
88 {
89 }
90
91 public void setDouble(double d)
92 {
93 }
94
95 public void setFloat(float f)
96 {
97 }
98
99 public void setInteger(int i)
100 {
101 }
102
103 public void setLong(long l)
104 {
105 }
106
107 public void setShort(short s)
108 {
109 }
110 }
111 }