From 69845b3545539b7961e8b4a3ef4a5ac416a305bb Mon Sep 17 00:00:00 2001 From: acolyer Date: Wed, 9 Mar 2005 11:18:05 +0000 Subject: test cases from ajdk:annotations chapter --- .../org/aspectj/systemtest/ajc150/Annotations.java | 87 +++++++++++--- tests/src/org/aspectj/systemtest/ajc150/ajc150.xml | 130 +++++++++++++++++++++ 2 files changed, 198 insertions(+), 19 deletions(-) (limited to 'tests/src') diff --git a/tests/src/org/aspectj/systemtest/ajc150/Annotations.java b/tests/src/org/aspectj/systemtest/ajc150/Annotations.java index f8bc17ce1..5480d50a6 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/Annotations.java +++ b/tests/src/org/aspectj/systemtest/ajc150/Annotations.java @@ -11,6 +11,9 @@ package org.aspectj.systemtest.ajc150; import java.io.File; +import java.lang.annotation.Annotation; +import java.net.URL; +import java.net.URLClassLoader; import junit.framework.Test; @@ -75,35 +78,81 @@ public class Annotations extends XMLBasedAjcTestCase { } // more implementation work needed before this test passes -// public void testAnnotatedITDs() { -// runTest("annotated itds"); -// } + public void testAnnotatedITDs() { + runTest("annotated itds"); + } public void testAnnotatedITDsWithWrongAnnotationType() { runTest("annotated itds with bad target"); } -// these tests to be completed -// public void testAnnotatedAdvice() { -// runTest("annotated advice"); -// } -// -// public void testAnnotatedAdviceWithWrongAnnotationType() { -// runTest("annotated advice with bad target"); -// } -// -// public void testAnnotatedPointcut() { -// runTest("annotated pointcut"); -// } -// -// public void testAnnotatedDeclareStatements() { -// runTest("annotated declare statements"); -// } + public void testAnnotatedAdvice() { + runTest("annotated advice"); + try { + File classFile = new File(ajc.getSandboxDirectory(),"a/AnnotatedAspect05.class"); + ClassLoader cl = new URLClassLoader(new URL[] {ajc.getSandboxDirectory().toURI().toURL()}); + Class c = cl.loadClass("a.AnnotatedAspect05"); + Class ann = cl.loadClass("a.AnyAnnotation"); + java.lang.reflect.Method[] methods = c.getDeclaredMethods(); + for (int i = 0; i < methods.length; i++) { + if (methods[i].getName().startsWith("ajc$afterThrowing")) { + Annotation annotation = methods[i].getAnnotation(ann); + assertNotNull("Should have @AnyAnnotation",annotation); + } + } + } catch (Exception ex) { + fail(ex.getMessage()); + } + } + + public void testAnnotatedAdviceWithWrongAnnotationType() { + runTest("annotated advice with bad target"); + } + + public void testAnnotatedPointcut() { + runTest("annotated pointcut"); + } + + public void testAnnotatedDeclareStatements() { + runTest("annotated declare statements"); + } public void testBasicDeclareAnnotation() { runTest("basic declare annotation parse test"); } + public void testAJDKAnnotatingAspects() { + runTest("ajdk: annotating aspects chapter"); + } + + public void testAJDKAnnotatingAspects2() { + runTest("ajdk: annotating aspects chapter, ex 2"); + } + + public void testAnnotationPatterns() { + runTest("ajdk: annotation pattern matching"); + } + + public void testAnnotationTypePatterns() { + runTest("ajdk: annotation type pattern matching"); + } + + public void testAnnotationSigPatterns() { + runTest("ajdk: annotations in sig patterns"); + } + + public void testAnnotationRuntimeMatching() { + runTest("ajdk: runtime annotations"); + } + + public void testAnnotationRetentionChecking() { + runTest("ajdk: @retention checking"); + } + + public void testAnnotationInheritance() { + runTest("ajdk: @inherited"); + } + // helper methods..... public SyntheticRepository createRepos(File cpentry) { diff --git a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml index 5cf5084fa..6b7fad53e 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml +++ b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml @@ -994,11 +994,13 @@ + + @@ -1021,5 +1023,133 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3