01: // Copyright 2006, 2007 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.ioc.services;
16:
17: import org.apache.tapestry.ioc.test.IOCTestCase;
18: import org.testng.annotations.DataProvider;
19: import org.testng.annotations.Test;
20:
21: public class ClassFabUtilsTest extends IOCTestCase {
22:
23: @Test(dataProvider="provider")
24: public void to_jvm_binary_name(String input, String expected) {
25: String actual = ClassFabUtils.toJVMBinaryName(input);
26:
27: assertEquals(actual, expected);
28: }
29:
30: @DataProvider(name="provider")
31: public Object[][] createInputs() {
32: return new Object[][] {
33: { "java.lang.Object", "java.lang.Object" },
34: { "int", "int" }, { "int[]", "[I" },
35: { "java.lang.Throwable[]", "[Ljava.lang.Throwable;" },
36: { "byte[][]", "[[B" },
37: { "java.lang.Runnable[][]", "[[Ljava.lang.Runnable;" } };
38: }
39:
40: @Test(dataProvider="typeCodeProvider")
41: public void get_type_code(Class input, String expected) {
42: assertEquals(ClassFabUtils.getTypeCode(input), expected);
43: }
44:
45: @DataProvider(name="typeCodeProvider")
46: public Object[][] get_type_code_provider() {
47: return new Object[][] { { int.class, "I" },
48: { int[].class, "[I" },
49: { Thread.class, "Ljava/lang/Thread;" },
50: { Thread[].class, "[Ljava/lang/Thread;" },
51: { Double[][].class, "[[Ljava/lang/Double;" },
52: { void.class, "V" },
53:
54: };
55: }
56:
57: @Test
58: public void unwrap_method() {
59: assertEquals(ClassFabUtils.getUnwrapMethodName("int"),
60: "intValue");
61: }
62:
63: @Test
64: public void wrapper_type_name() {
65: assertEquals(ClassFabUtils.getWrapperTypeName("int"),
66: "java.lang.Integer");
67: }
68:
69: @Test
70: public void wrapper_type() {
71: assertEquals(ClassFabUtils.getWrapperType(int.class),
72: Integer.class);
73: assertEquals(ClassFabUtils.getWrapperType(getClass()),
74: getClass());
75: }
76: }
|