01: // Copyright 2006 The Apache Software Foundation
02: //
03: // Licensed under the Apache License, Version 2.0 (the "License");
04: // you may not use this file except in compliance with the License.
05: // You may obtain a copy of the License at
06: //
07: // http://www.apache.org/licenses/LICENSE-2.0
08: //
09: // Unless required by applicable law or agreed to in writing, software
10: // distributed under the License is distributed on an "AS IS" BASIS,
11: // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12: // See the License for the specific language governing permissions and
13: // limitations under the License.
14:
15: package org.apache.tapestry.services;
16:
17: import static org.apache.tapestry.services.TransformUtils.getDefaultValue;
18: import static org.apache.tapestry.services.TransformUtils.getUnwrapperMethodName;
19: import static org.apache.tapestry.services.TransformUtils.getWrapperType;
20: import static org.apache.tapestry.services.TransformUtils.getWrapperTypeName;
21: import static org.apache.tapestry.services.TransformUtils.isPrimitive;
22:
23: import java.util.Map;
24:
25: import org.testng.Assert;
26: import org.testng.annotations.Test;
27:
28: /**
29: *
30: */
31: public class TransformUtilsTest extends Assert {
32: @Test
33: public void wrapper_type_by_name() {
34: assertEquals(getWrapperTypeName("char"), "java.lang.Character");
35: assertEquals(getWrapperTypeName("java.util.Map"),
36: "java.util.Map");
37: }
38:
39: @Test
40: public void wrapper_type_by_class() {
41: assertEquals(getWrapperType(char.class), Character.class);
42: assertEquals(getWrapperType(Map.class), Map.class);
43: }
44:
45: @Test
46: public void default_value() {
47: assertEquals(getDefaultValue("long"), "0L");
48: assertEquals(getDefaultValue("java.util.Map"), "null");
49: }
50:
51: @Test
52: public void is_primitive() {
53: assertTrue(isPrimitive("int"));
54: assertFalse(isPrimitive("java.lang.Integer"));
55: }
56:
57: @Test
58: public void unwrapper_method_name() {
59: assertEquals(getUnwrapperMethodName("boolean"), "booleanValue");
60: assertEquals(getUnwrapperMethodName("int"), "intValue");
61: assertNull(getUnwrapperMethodName("java.lang.Integer"));
62: }
63: }
|