01: package jaxx.junit;
02:
03: import java.awt.*;
04: import junit.framework.TestCase;
05:
06: import jaxx.reflect.*;
07:
08: public class ClassDescriptorTest extends TestCase {
09: public void testBuiltInClassName() throws ClassNotFoundException,
10: NoSuchMethodException {
11: ClassDescriptor object = ClassDescriptorLoader
12: .getClassDescriptor("java.lang.Object");
13: MethodDescriptor toString = object.getMethodDescriptor(
14: "toString", new ClassDescriptor[0]);
15: assertEquals(toString.getName(), "toString");
16: assertEquals(toString.getParameterTypes().length, 0);
17:
18: MethodDescriptor equals = object.getMethodDescriptor("equals",
19: new ClassDescriptor[] { object });
20: assertEquals(equals.getName(), "equals");
21: assertEquals(equals.getParameterTypes().length, 1);
22: assertEquals(equals.getParameterTypes()[0], object);
23: }
24:
25: public void testBuiltInClass() throws ClassNotFoundException,
26: NoSuchMethodException {
27: ClassDescriptor object1 = ClassDescriptorLoader
28: .getClassDescriptor("java.lang.Object");
29: ClassDescriptor object2 = ClassDescriptorLoader
30: .getClassDescriptor(Object.class);
31: assertEquals(object1, object2);
32: }
33:
34: public void testUserClassName() throws ClassNotFoundException,
35: NoSuchMethodException {
36: ClassDescriptor me = ClassDescriptorLoader.getClassDescriptor(
37: "jaxx.junit.ClassDescriptorTest", getClass()
38: .getClassLoader());
39: MethodDescriptor testUserClassName = me.getMethodDescriptor(
40: "testUserClassName", new ClassDescriptor[0]);
41: assertEquals(testUserClassName.getName(), "testUserClassName");
42: assertEquals(testUserClassName.getParameterTypes().length, 0);
43: }
44:
45: public void testWrongCase() {
46: try {
47: ClassDescriptor object = ClassDescriptorLoader
48: .getClassDescriptor(
49: "jaxx.junit.classdescriptortest",
50: getClass().getClassLoader());
51: fail("Found descriptor using wrong case: " + object);
52: } catch (ClassNotFoundException e) {
53: }
54: }
55:
56: public void testArrays() throws ClassNotFoundException {
57: ClassDescriptor intArray = ClassDescriptorLoader
58: .getClassDescriptor(int[].class);
59: ClassDescriptor objectArray = ClassDescriptorLoader
60: .getClassDescriptor(Object[].class);
61: }
62: }
|