KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > reflection > ClassInfoHelperTest


1 /**************************************************************************************
2  * Copyright (c) Jonas BonŽr, Alexandre Vasseur. All rights reserved. *
3  * http://aspectwerkz.codehaus.org *
4  * ---------------------------------------------------------------------------------- *
5  * The software in this package is published under the terms of the LGPL license *
6  * a copy of which has been included with this distribution in the license.txt file. *
7  **************************************************************************************/

8 package test.reflection;
9
10 import junit.framework.TestCase;
11
12 import org.codehaus.aspectwerkz.reflect.ClassInfo;
13 import org.codehaus.aspectwerkz.reflect.ClassInfoHelper;
14 import org.codehaus.aspectwerkz.reflect.impl.java.JavaClassInfo;
15
16
17 public class ClassInfoHelperTest extends TestCase {
18
19     public void testInterfaceImplements() {
20         ClassInfo ci = JavaClassInfo.getClassInfo(ClassInfoHelperTest.Intf2.class);
21         assertTrue(ClassInfoHelper.implementsInterface(ci, ClassInfoHelperTest.Intf1.class.getName()));
22     }
23     
24     public void testClassImplements() {
25         ClassInfo ci = JavaClassInfo.getClassInfo(ClassInfoHelperTest.ClassImpl.class);
26         
27         assertTrue(ClassInfoHelper.implementsInterface(ci, ClassInfoHelperTest.Intf2.class.getName()));
28         
29         assertTrue(ClassInfoHelper.implementsInterface(ci, ClassInfoHelperTest.Intf1.class.getName()));
30     }
31     
32     public void testInterfaceImplementsItself() {
33         ClassInfo ci = JavaClassInfo.getClassInfo(ClassInfoHelperTest.Intf2.class);
34         
35         assertFalse(ClassInfoHelper.implementsInterface(ci, ClassInfoHelperTest.Intf2.class.getName()));
36     }
37     
38
39     public static class ClassImpl implements Intf2 {
40     }
41     
42     public static interface Intf2 extends Intf1 {
43     }
44     
45     public static interface Intf1 {
46     }
47     
48     // -- JUnit
49
public static void main(String JavaDoc[] args) {
50         junit.textui.TestRunner.run(suite());
51     }
52
53     public static junit.framework.Test suite() {
54         return new junit.framework.TestSuite(ClassInfoHelperTest.class);
55     }
56 }
57
Popular Tags