001: package org.apache.velocity.test.util.introspection;
002:
003: /*
004: * Licensed to the Apache Software Foundation (ASF) under one
005: * or more contributor license agreements. See the NOTICE file
006: * distributed with this work for additional information
007: * regarding copyright ownership. The ASF licenses this file
008: * to you under the Apache License, Version 2.0 (the
009: * "License"); you may not use this file except in compliance
010: * with the License. You may obtain a copy of the License at
011: *
012: * http://www.apache.org/licenses/LICENSE-2.0
013: *
014: * Unless required by applicable law or agreed to in writing,
015: * software distributed under the License is distributed on an
016: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017: * KIND, either express or implied. See the License for the
018: * specific language governing permissions and limitations
019: * under the License.
020: */
021:
022: import junit.framework.Test;
023: import junit.framework.TestSuite;
024:
025: import org.apache.velocity.app.Velocity;
026: import org.apache.velocity.runtime.log.Log;
027: import org.apache.velocity.runtime.log.NullLogChute;
028: import org.apache.velocity.test.BaseTestCase;
029: import org.apache.velocity.util.introspection.ClassMap;
030:
031: /**
032: * Test the ClassMap Lookup
033: */
034: public class ClassMapTestCase extends BaseTestCase {
035: public ClassMapTestCase(final String name) throws Exception {
036: super (name);
037: }
038:
039: public static Test suite() {
040: return new TestSuite(ClassMapTestCase.class);
041: }
042:
043: public void setUp() throws Exception {
044: Velocity.setProperty(Velocity.RUNTIME_LOG_LOGSYSTEM_CLASS,
045: NullLogChute.class.getName());
046:
047: Velocity.init();
048: }
049:
050: public void tearDown() {
051: }
052:
053: public void testPrimitives() throws Exception {
054: Log log = Velocity.getLog();
055:
056: ClassMap c = new ClassMap(TestClassMap.class, log);
057: assertNotNull(c.findMethod("setBoolean",
058: new Object[] { Boolean.TRUE }));
059: assertNotNull(c.findMethod("setByte", new Object[] { new Byte(
060: (byte) 4) }));
061: assertNotNull(c.findMethod("setCharacter",
062: new Object[] { new Character('c') }));
063: assertNotNull(c.findMethod("setDouble",
064: new Object[] { new Double(8.0) }));
065: assertNotNull(c.findMethod("setFloat",
066: new Object[] { new Float(15.0) }));
067: assertNotNull(c.findMethod("setInteger",
068: new Object[] { new Integer(16) }));
069: assertNotNull(c.findMethod("setLong", new Object[] { new Long(
070: 23) }));
071: assertNotNull(c.findMethod("setShort",
072: new Object[] { new Short((short) 42) }));
073: }
074:
075: public static final class TestClassMap {
076: public void setBoolean(boolean b) {
077: }
078:
079: public void setByte(byte b) {
080: }
081:
082: public void setCharacter(char c) {
083: }
084:
085: public void setDouble(double d) {
086: }
087:
088: public void setFloat(float f) {
089: }
090:
091: public void setInteger(int i) {
092: }
093:
094: public void setLong(long l) {
095: }
096:
097: public void setShort(short s) {
098: }
099: }
100: }
|