01: /**************************************************************************************
02: * Copyright (c) Jonas BonŽr, Alexandre Vasseur. All rights reserved. *
03: * http://aspectwerkz.codehaus.org *
04: * ---------------------------------------------------------------------------------- *
05: * The software in this package is published under the terms of the LGPL license *
06: * a copy of which has been included with this distribution in the license.txt file. *
07: **************************************************************************************/package test.reflection;
08:
09: import junit.framework.TestCase;
10:
11: import org.codehaus.aspectwerkz.reflect.ClassInfo;
12: import org.codehaus.aspectwerkz.reflect.ClassInfoHelper;
13: import org.codehaus.aspectwerkz.reflect.impl.java.JavaClassInfo;
14:
15: public class ClassInfoHelperTest extends TestCase {
16:
17: public void testInterfaceImplements() {
18: ClassInfo ci = JavaClassInfo
19: .getClassInfo(ClassInfoHelperTest.Intf2.class);
20: assertTrue(ClassInfoHelper.implements Interface(ci,
21: ClassInfoHelperTest.Intf1.class.getName()));
22: }
23:
24: public void testClassImplements() {
25: ClassInfo ci = JavaClassInfo
26: .getClassInfo(ClassInfoHelperTest.ClassImpl.class);
27:
28: assertTrue(ClassInfoHelper.implements Interface(ci,
29: ClassInfoHelperTest.Intf2.class.getName()));
30:
31: assertTrue(ClassInfoHelper.implements Interface(ci,
32: ClassInfoHelperTest.Intf1.class.getName()));
33: }
34:
35: public void testInterfaceImplementsItself() {
36: ClassInfo ci = JavaClassInfo
37: .getClassInfo(ClassInfoHelperTest.Intf2.class);
38:
39: assertFalse(ClassInfoHelper.implements Interface(ci,
40: ClassInfoHelperTest.Intf2.class.getName()));
41: }
42:
43: public static class ClassImpl implements Intf2 {
44: }
45:
46: public static interface Intf2 extends Intf1 {
47: }
48:
49: public static interface Intf1 {
50: }
51:
52: // -- JUnit
53: public static void main(String[] args) {
54: junit.textui.TestRunner.run(suite());
55: }
56:
57: public static junit.framework.Test suite() {
58: return new junit.framework.TestSuite(ClassInfoHelperTest.class);
59: }
60: }
|