1   package org.apache.velocity.test.util.introspection;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.    
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.test.misc.TestLogChute;
28  import org.apache.velocity.test.BaseTestCase;
29  import org.apache.velocity.util.introspection.ClassMap;
30  
31  /**
32   * Test the ClassMap Lookup
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, TestLogChute.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 }