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.annotation;
08:
09: import org.codehaus.aspectwerkz.reflect.ClassInfo;
10: import org.codehaus.aspectwerkz.reflect.MethodInfo;
11: import org.codehaus.aspectwerkz.reflect.impl.asm.AsmClassInfo;
12: import org.codehaus.aspectwerkz.annotation.Annotations;
13: import org.codehaus.aspectwerkz.annotation.AnnotationInfo;
14: import org.codehaus.aspectwerkz.annotation.instrumentation.asm.AsmAnnotations;
15: import junit.framework.TestCase;
16:
17: /**
18: * @author <a href="mailto:alex AT gnilux DOT com">Alexandre Vasseur</a>
19: */
20: public class AnnotationLoadingTest extends TestCase {
21:
22: public void testAnnotationLoadingWithClassRef() throws Throwable {
23: System.out.println("START");
24: ClassInfo klass = AsmClassInfo.getClassInfo(
25: "test.annotation.AnnotationLoadingTarget",
26: AnnotationLoadingTest.class.getClassLoader());
27: MethodInfo m = klass.getMethods()[0];
28: AnnotationInfo annInfo = (AnnotationInfo) m.getAnnotations()
29: .get(0);
30:
31: System.out.println("DONE");
32: System.out.println(annInfo.getAnnotation());
33: AnnotationParserTest.Complex c = ((AnnotationParserTest.Complex) annInfo
34: .getAnnotation());
35: System.out.println(c.klass().getName());
36: System.out.println(c.toString());
37: System.out.println(c.klass2()[0]);
38: }
39:
40: public static void main(String[] args) {
41: junit.textui.TestRunner.run(suite());
42: }
43:
44: public static junit.framework.Test suite() {
45: return new junit.framework.TestSuite(
46: AnnotationLoadingTest.class);
47: }
48:
49: }
|