--- /dev/null
+import org.aspectj.lang.annotation.*;
+
+@Aspect
+public class AtAJAspect {
+ @Before("staticinitialization(*)")
+ public void m() { }
+}
--- /dev/null
+import org.aspectj.lang.annotation.*;
+
+public class AtInnerAJAspect {
+ @Aspect
+ public static class SimpleAspect {
+ @Before("staticinitialization(*)")
+ public void m() { }
+ }
+}
--- /dev/null
+public class ClassOne {
+ public static void main(String[] args) {
+ new ClassOne().printMessage("I am ClassOne");
+ }
+
+ public void printMessage(String message) {
+ System.out.println(message);
+ }
+}
\ No newline at end of file
--- /dev/null
+public class ClassTwo {
+ public static void main(String[] args) {
+ new ClassTwo().printMessage("I am ClassTwo");
+ }
+
+ public void printMessage(String message) {
+ System.out.println(message);
+ }
+}
\ No newline at end of file
--- /dev/null
+public aspect SimpleAspect {
+ before(): staticinitialization(*) {
+
+ }
+}
\ No newline at end of file
--- /dev/null
+public aspect SimpleAspect2 {
+ before(): staticinitialization(*) {
+ }
+}
--- /dev/null
+public aspect SubAspect extends SuperClass {
+ before(): p() { }
+}
--- /dev/null
+public class SuperClass {
+ pointcut p(): staticinitialization(*);
+}
--- /dev/null
+import java.lang.annotation.*;
+
+public aspect AnAspect {
+
+ declare @type: Foo: @SimpleAnnotation(id=5); // one type in an array
+
+
+ declare @type: Foo: @AnnotationClassElement(clz=Integer.class); // one type not in an array
+
+
+ before(): call(* (@SimpleAnnotation *).m(..)) {
+ }
+
+// declare @type: Foo: @AnnotationStringElement(stringval="www"); // two types in an array
+}
--- /dev/null
+// Use all the variants of annotations - to exercise the
+// eclipse transform code in EclipseSourceType
+
+import java.lang.annotation.*;
+
+@AnnotationStringElement(stringval="hello")
+@SimpleAnnotation(id=1)
+@AnnotationClassElement(clz=Integer.class)
+@CombinedAnnotation({@SimpleAnnotation(id=4)})
+@AnnotationEnumElement(enumval=SimpleEnum.Red)
+@ComplexAnnotation(ival=4,bval=2,cval='5',fval=3.0f,dval=33.4,zval=false,jval=56,sval=99)
+public class DecoratedClass {
+public void m() {}
+
+}
+
+@Target(value={ElementType.TYPE})
+@Retention(RetentionPolicy.RUNTIME)
+@interface SimpleAnnotation {
+ int id();
+ String fruit() default "bananas";
+}
+enum SimpleEnum { Red,Orange,Yellow,Green,Blue,Indigo,Violet };
+
+@Retention(RetentionPolicy.RUNTIME)
+@interface SimpleStringAnnotation {
+ String fruit();
+}
+
+
+@Target({ElementType.TYPE,ElementType.FIELD})
+@Retention(RetentionPolicy.RUNTIME)
+@interface AnnotationClassElement {
+ Class clz();
+}
+
+@Retention(RetentionPolicy.RUNTIME)
+@interface AnnotationEnumElement {
+ SimpleEnum enumval();
+}
+@Target({ElementType.TYPE,ElementType.METHOD,ElementType.FIELD})
+@Retention(RetentionPolicy.RUNTIME)
+@interface AnnotationStringElement {
+ String stringval();
+}
+@Retention(RetentionPolicy.RUNTIME)
+@interface CombinedAnnotation {
+ SimpleAnnotation[] value();
+}
+@Retention(RetentionPolicy.RUNTIME)
+@interface ComplexAnnotation {
+ int ival();
+ byte bval();
+ char cval();
+ long jval();
+ double dval();
+ boolean zval();
+ short sval();
+ float fval();
+}
+
--- /dev/null
+public class Foo {
+ public static void main(String []argv) {
+ new DecoratedClass().m();
+ }
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2006 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.ajc153;
+
+import java.io.File;
+
+import junit.framework.Test;
+
+import org.aspectj.ajdt.internal.compiler.AjCompilerAdapter;
+import org.aspectj.testing.XMLBasedAjcTestCase;
+
+/**
+ * testplan: (x = complete)
+ *
+ * x @AspectJ aspects - are they recognized and sorted correctly ?
+ * x compiling classes (various orderings)
+ * x compiling classes (inheritance relationships)
+ * x compiling aspects and classes (various orderings - aspects first/last)
+ * x eclipse annotation transformation logic
+ * x aspects extending classes
+ * x nested types (and aspect inside a regular class)
+ * x set of files that are only aspects
+ * x pointcuts in super classes
+ * - classes with errors
+ * - aspects with errors
+ * - Xterminate after compilation (now == skip weaving??)
+ *
+ * That this pipeline works OK for large systems is kind of confirmed by using it to build shadows!
+ *
+ */
+public class PipeliningTests extends org.aspectj.testing.XMLBasedAjcTestCase {
+
+ // straightforward compilation
+ public void testBuildTwoClasses() { runTest("build two classes");}
+ public void testBuildOneAspectTwoClasses() { runTest("build one aspect and two classes");}
+ public void testBuildTwoClassesOneAspect() { runTest("build two classes and one aspect");}
+ public void testBuildTwoAspects() { runTest("build two aspects");}
+
+ public void testAspectExtendsClass() { runTest("aspect extends class"); }
+
+ // verifying the type sorting
+ public void testRecognizingAnnotationStyleAspects1() {
+ AjCompilerAdapter.pipelineTesting=true;
+ runTest("recognizing annotation style aspects - 1");
+
+ String filesContainingAspects = AjCompilerAdapter.getPipelineDebugOutput("filesContainingAspects");
+ assertTrue("Should be one file containing aspects but it thinks there are "+filesContainingAspects,filesContainingAspects.equals("1"));
+
+ String weaveOrder = AjCompilerAdapter.getPipelineDebugOutput("weaveOrder");
+ String expectedOrder="[AtAJAspect.java,ClassOne.java]";
+ assertTrue("Expected weaving order to be "+expectedOrder+" but was "+weaveOrder,weaveOrder.equals(expectedOrder));
+ }
+ public void testRecognizingAnnotationStyleAspects2() {
+ AjCompilerAdapter.pipelineTesting=true;
+ runTest("recognizing annotation style aspects - 2");
+
+ String filesContainingAspects = AjCompilerAdapter.getPipelineDebugOutput("filesContainingAspects");
+ assertTrue("Should be one file containing aspects but it thinks there are "+filesContainingAspects,filesContainingAspects.equals("1"));
+
+ String weaveOrder = AjCompilerAdapter.getPipelineDebugOutput("weaveOrder");
+ String expectedOrder="[AtInnerAJAspect.java,ClassOne.java]";
+ assertTrue("Expected weaving order to be "+expectedOrder+" but was "+weaveOrder,weaveOrder.equals(expectedOrder));
+ }
+
+ // verifying the new code for transforming Eclipse Annotations into AspectJ ones
+ public void testAnnotationTransformation() { runTest("annotation transformation"); }
+
+ // --
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ AjCompilerAdapter.pipelineTesting=false;
+ }
+ public static Test suite() {
+ return XMLBasedAjcTestCase.loadSuite(PipeliningTests.class);
+ }
+ protected File getSpecFile() {
+ return new File("../tests/src/org/aspectj/systemtest/ajc153/pipelining.xml");
+ }
+}
\ No newline at end of file
--- /dev/null
+<!DOCTYPE suite SYSTEM "../tests/ajcTestSuite.dtd"[]>
+
+<!-- Pipelining tests -->
+<suite>
+
+ <!-- testing the very very basics of pipelining -->
+ <ajc-test dir="features153/pipelining" title="build two classes">
+ <compile files="ClassOne.java,ClassTwo.java" options="-verbose"/>
+ </ajc-test>
+
+ <!-- testing the basics when an aspect is included, it is placed at the front deliberately -->
+ <ajc-test dir="features153/pipelining" title="build one aspect and two classes">
+ <compile files="SimpleAspect.java,ClassOne.java,ClassTwo.java" options="-verbose -showWeaveInfo">
+ <message kind="weave" text="Join point 'staticinitialization(void SimpleAspect.<clinit>())' in Type 'SimpleAspect' (SimpleAspect.java:1) advised by before advice from 'SimpleAspect' (SimpleAspect.java:2)"/>
+ <message kind="weave" text="Join point 'staticinitialization(void ClassOne.<clinit>())' in Type 'ClassOne' (ClassOne.java:1) advised by before advice from 'SimpleAspect' (SimpleAspect.java:2)"/>
+ <message kind="weave" text="Join point 'staticinitialization(void ClassTwo.<clinit>())' in Type 'ClassTwo' (ClassTwo.java:1) advised by before advice from 'SimpleAspect' (SimpleAspect.java:2)"/>
+ </compile>
+ </ajc-test>
+
+ <!-- testing the basics when an aspect is included, aspect should be moved to the front after diet parsing -->
+ <ajc-test dir="features153/pipelining" title="build two classes and one aspect">
+ <compile files="ClassOne.java,ClassTwo.java,SimpleAspect.java" options="-verbose -showWeaveInfo">
+ <message kind="weave" text="Join point 'staticinitialization(void SimpleAspect.<clinit>())' in Type 'SimpleAspect' (SimpleAspect.java:1) advised by before advice from 'SimpleAspect' (SimpleAspect.java:2)"/>
+ <message kind="weave" text="Join point 'staticinitialization(void ClassOne.<clinit>())' in Type 'ClassOne' (ClassOne.java:1) advised by before advice from 'SimpleAspect' (SimpleAspect.java:2)"/>
+ <message kind="weave" text="Join point 'staticinitialization(void ClassTwo.<clinit>())' in Type 'ClassTwo' (ClassTwo.java:1) advised by before advice from 'SimpleAspect' (SimpleAspect.java:2)"/>
+ </compile>
+ </ajc-test>
+
+ <!-- just building aspects, no classes around - will the sorting behave -->
+ <ajc-test dir="features153/pipelining" title="build two aspects">
+ <compile files="SimpleAspect.java,SimpleAspect2.java" options="-verbose -showWeaveInfo">
+ <message kind="weave" text="Join point 'staticinitialization(void SimpleAspect.<clinit>())' in Type 'SimpleAspect' (SimpleAspect.java:1) advised by before advice from 'SimpleAspect2' (SimpleAspect2.java:2)"/>
+ <message kind="weave" text="Join point 'staticinitialization(void SimpleAspect.<clinit>())' in Type 'SimpleAspect' (SimpleAspect.java:1) advised by before advice from 'SimpleAspect' (SimpleAspect.java:2)"/>
+ <message kind="weave" text="Join point 'staticinitialization(void SimpleAspect2.<clinit>())' in Type 'SimpleAspect2' (SimpleAspect2.java:1) advised by before advice from 'SimpleAspect2' (SimpleAspect2.java:2)"/>
+ <message kind="weave" text="Join point 'staticinitialization(void SimpleAspect2.<clinit>())' in Type 'SimpleAspect2' (SimpleAspect2.java:1) advised by before advice from 'SimpleAspect' (SimpleAspect.java:2)"/>
+ </compile>
+ </ajc-test>
+
+ <!-- pointcut in a superclass, subaspect extends the class - pointcut class is supplied after the superclass -->
+ <ajc-test dir="features153/pipelining" title="aspect extends class">
+ <compile files="ClassOne.java,SubAspect.java,ClassTwo.java,SuperClass.java" options="-verbose -showWeaveInfo">
+ <message kind="weave" text="Join point 'staticinitialization(void SubAspect.<clinit>())' in Type 'SubAspect' (SubAspect.java:1) advised by before advice from 'SubAspect' (SubAspect.java:2)"/>
+ <message kind="weave" text="Join point 'staticinitialization(void ClassOne.<clinit>())' in Type 'ClassOne' (ClassOne.java:1) advised by before advice from 'SubAspect' (SubAspect.java:2)"/>
+ <message kind="weave" text="Join point 'staticinitialization(void ClassTwo.<clinit>())' in Type 'ClassTwo' (ClassTwo.java:1) advised by before advice from 'SubAspect' (SubAspect.java:2)"/>
+ <message kind="weave" text="Join point 'staticinitialization(void SuperClass.<clinit>())' in Type 'SuperClass' (SuperClass.java:1) advised by before advice from 'SubAspect' (SubAspect.java:2)"/>
+ </compile>
+ </ajc-test>
+
+ <!-- testing eclipse to aspectj annotation transformation -->
+ <ajc-test dir="features153/pipelining/annotations" title="annotation transformation">
+ <compile files="AnAspect.java,Foo.java,DecoratedClass.java" options="-1.5 -verbose"/>
+ </ajc-test>
+
+ <!-- does the aspect sorter recognize annotation style aspects, pass the aspects last -->
+ <ajc-test dir="features153/pipelining" title="recognizing annotation style aspects - 1">
+ <compile files="ClassOne.java,AtAJAspect.java" options="-1.5 -verbose"/>
+ </ajc-test>
+
+ <!-- does the aspect sorter recognize annotation style aspects (inner type), pass the aspects last -->
+ <ajc-test dir="features153/pipelining" title="recognizing annotation style aspects - 2">
+ <compile files="ClassOne.java,AtInnerAJAspect.java" options="-1.5 -verbose"/>
+ </ajc-test>
+
+</suite>
\ No newline at end of file