123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182 |
- /*******************************************************************************
- * Copyright (c) 2004 IBM
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Andy Clement - initial API and implementation
- *******************************************************************************/
- package org.aspectj.systemtest.ajc150;
-
- import java.io.File;
-
- import junit.framework.Test;
-
- import org.aspectj.apache.bcel.classfile.JavaClass;
- import org.aspectj.apache.bcel.classfile.Method;
- import org.aspectj.apache.bcel.util.ClassPath;
- import org.aspectj.apache.bcel.util.SyntheticRepository;
- import org.aspectj.testing.XMLBasedAjcTestCase;
-
- public class Annotations extends XMLBasedAjcTestCase {
-
- public static Test suite() {
- return XMLBasedAjcTestCase.loadSuite(Annotations.class);
- }
-
- protected File getSpecFile() {
- return new File("../tests/src/org/aspectj/systemtest/ajc150/ajc150.xml");
- }
-
- public void testCompilingAnnotation() {
- runTest("compiling an annotation");
- }
-
- public void testCompilingAnnotatedFile() {
- runTest("compiling annotated file");
- }
-
- public void testCompilingUsingWithinAndAnnotationTypePattern() {
- runTest("annotations and within (src)");
- }
-
- /**
- * We had a bug where annotations were not present in the output class file for methods
- * that got woven. This was due to unpacking bugs in LazyMethodGen. This test compiles
- * a simple program then checks the annotations were copied across.
- */
- public void testBugWithAnnotationsLostOnWovenMethods() throws ClassNotFoundException {
- runTest("losing annotations...");
- if (getCurrentTest().canRunOnThisVM()) {
-
- JavaClass jc = getClassFrom(ajc.getSandboxDirectory(),"Program");
- Method[] meths = jc.getMethods();
- for (int i = 0; i < meths.length; i++) {
- Method method = meths[i];
- if (method.getName().equals("m1")) {
- assertTrue("Didn't have annotations - were they lost? method="+method.getName(),method.getAnnotations().length==1);
- }
- }
- }
- }
-
- public void testAnnotatedAnnotations() {
- runTest("annotated annotations (@Target)");
- }
-
- public void testSimpleAnnotatedAspectMembers() {
- runTest("simple annotated aspect members");
- }
-
- public void testAnnotatedAspectMembersWithWrongAnnotationType() {
- runTest("simple annotated aspect members with bad target");
- }
-
- // more implementation work needed before this test passes
- public void testAnnotatedITDs() {
- runTest("annotated itds");
- }
-
- public void testAnnotatedITDs2() {
- runTest("annotated public itds");
- }
-
- public void testAnnotatedITDs3() {
- runTest("annotated public itds - values");
- }
-
- public void testAnnotatedITDs4() {
- runTest("annotated public itds - multiple complex annotations");
- }
-
- public void testAnnotatedITDsWithWrongAnnotationType() {
- runTest("annotated itds with bad target");
- }
-
- public void testAnnotatedAdvice() {
- runTest("annotated advice");
- }
-
- public void testAnnotatedAdviceWithWrongAnnotationType() {
- runTest("annotated advice with bad target");
- }
-
- public void testAnnotatedPointcut() {
- runTest("annotated pointcut");
- }
-
- // FIXME asc uncomment this test when parser is opened up
- // 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");
- }
-
- public void testAnnotationDEOW() {
- runTest("ajdk: deow-ann");
- }
-
- public void testAnnotationDecp() {
- runTest("ajdk: decp-ann");
- }
-
- public void testAnnotationDecPrecedence() {
- runTest("ajdk: dec precedence");
- }
-
- public void testAnnotationDecAnnotation() {
- runTest("ajdk: dec annotation");
- }
-
- public void testAnnotationsAndITDs() {
- runTest("nasty annotation and itds test");
- }
-
- // helper methods.....
-
- public SyntheticRepository createRepos(File cpentry) {
- ClassPath cp = new ClassPath(cpentry+File.pathSeparator+System.getProperty("java.class.path"));
- return SyntheticRepository.getInstance(cp);
- }
-
- protected JavaClass getClassFrom(File where,String clazzname) throws ClassNotFoundException {
- SyntheticRepository repos = createRepos(where);
- return repos.loadClass(clazzname);
- }
- }
|