From 9fcd1e6ce6ec27d7b3db919e1b3605e190b31d3b Mon Sep 17 00:00:00 2001 From: aclement Date: Wed, 26 Jul 2006 15:01:31 +0000 Subject: [PATCH] pipeline changes: testcode --- tests/features153/pipelining/AtAJAspect.java | 7 ++ .../pipelining/AtInnerAJAspect.java | 9 ++ tests/features153/pipelining/ClassOne.java | 9 ++ tests/features153/pipelining/ClassTwo.java | 9 ++ .../features153/pipelining/SimpleAspect.java | 5 ++ .../features153/pipelining/SimpleAspect2.java | 4 + tests/features153/pipelining/SubAspect.java | 3 + tests/features153/pipelining/SuperClass.java | 3 + .../pipelining/annotations/AnAspect.java | 15 ++++ .../annotations/DecoratedClass.java | 61 +++++++++++++ .../pipelining/annotations/Foo.java | 5 ++ .../systemtest/ajc153/PipeliningTests.java | 87 +++++++++++++++++++ .../aspectj/systemtest/ajc153/pipelining.xml | 64 ++++++++++++++ 13 files changed, 281 insertions(+) create mode 100644 tests/features153/pipelining/AtAJAspect.java create mode 100644 tests/features153/pipelining/AtInnerAJAspect.java create mode 100644 tests/features153/pipelining/ClassOne.java create mode 100644 tests/features153/pipelining/ClassTwo.java create mode 100644 tests/features153/pipelining/SimpleAspect.java create mode 100644 tests/features153/pipelining/SimpleAspect2.java create mode 100644 tests/features153/pipelining/SubAspect.java create mode 100644 tests/features153/pipelining/SuperClass.java create mode 100644 tests/features153/pipelining/annotations/AnAspect.java create mode 100644 tests/features153/pipelining/annotations/DecoratedClass.java create mode 100644 tests/features153/pipelining/annotations/Foo.java create mode 100644 tests/src/org/aspectj/systemtest/ajc153/PipeliningTests.java create mode 100644 tests/src/org/aspectj/systemtest/ajc153/pipelining.xml diff --git a/tests/features153/pipelining/AtAJAspect.java b/tests/features153/pipelining/AtAJAspect.java new file mode 100644 index 000000000..a739761cc --- /dev/null +++ b/tests/features153/pipelining/AtAJAspect.java @@ -0,0 +1,7 @@ +import org.aspectj.lang.annotation.*; + +@Aspect +public class AtAJAspect { + @Before("staticinitialization(*)") + public void m() { } +} diff --git a/tests/features153/pipelining/AtInnerAJAspect.java b/tests/features153/pipelining/AtInnerAJAspect.java new file mode 100644 index 000000000..7f0693806 --- /dev/null +++ b/tests/features153/pipelining/AtInnerAJAspect.java @@ -0,0 +1,9 @@ +import org.aspectj.lang.annotation.*; + +public class AtInnerAJAspect { + @Aspect + public static class SimpleAspect { + @Before("staticinitialization(*)") + public void m() { } + } +} diff --git a/tests/features153/pipelining/ClassOne.java b/tests/features153/pipelining/ClassOne.java new file mode 100644 index 000000000..b86d8e107 --- /dev/null +++ b/tests/features153/pipelining/ClassOne.java @@ -0,0 +1,9 @@ +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 diff --git a/tests/features153/pipelining/ClassTwo.java b/tests/features153/pipelining/ClassTwo.java new file mode 100644 index 000000000..8b2668664 --- /dev/null +++ b/tests/features153/pipelining/ClassTwo.java @@ -0,0 +1,9 @@ +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 diff --git a/tests/features153/pipelining/SimpleAspect.java b/tests/features153/pipelining/SimpleAspect.java new file mode 100644 index 000000000..431f93f66 --- /dev/null +++ b/tests/features153/pipelining/SimpleAspect.java @@ -0,0 +1,5 @@ +public aspect SimpleAspect { + before(): staticinitialization(*) { + + } +} \ No newline at end of file diff --git a/tests/features153/pipelining/SimpleAspect2.java b/tests/features153/pipelining/SimpleAspect2.java new file mode 100644 index 000000000..609256ed0 --- /dev/null +++ b/tests/features153/pipelining/SimpleAspect2.java @@ -0,0 +1,4 @@ +public aspect SimpleAspect2 { + before(): staticinitialization(*) { + } +} diff --git a/tests/features153/pipelining/SubAspect.java b/tests/features153/pipelining/SubAspect.java new file mode 100644 index 000000000..94f03768a --- /dev/null +++ b/tests/features153/pipelining/SubAspect.java @@ -0,0 +1,3 @@ +public aspect SubAspect extends SuperClass { + before(): p() { } +} diff --git a/tests/features153/pipelining/SuperClass.java b/tests/features153/pipelining/SuperClass.java new file mode 100644 index 000000000..474d44dc1 --- /dev/null +++ b/tests/features153/pipelining/SuperClass.java @@ -0,0 +1,3 @@ +public class SuperClass { + pointcut p(): staticinitialization(*); +} diff --git a/tests/features153/pipelining/annotations/AnAspect.java b/tests/features153/pipelining/annotations/AnAspect.java new file mode 100644 index 000000000..2b3d6eefe --- /dev/null +++ b/tests/features153/pipelining/annotations/AnAspect.java @@ -0,0 +1,15 @@ +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 +} diff --git a/tests/features153/pipelining/annotations/DecoratedClass.java b/tests/features153/pipelining/annotations/DecoratedClass.java new file mode 100644 index 000000000..769c72f19 --- /dev/null +++ b/tests/features153/pipelining/annotations/DecoratedClass.java @@ -0,0 +1,61 @@ +// 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(); +} + diff --git a/tests/features153/pipelining/annotations/Foo.java b/tests/features153/pipelining/annotations/Foo.java new file mode 100644 index 000000000..a7d68dd35 --- /dev/null +++ b/tests/features153/pipelining/annotations/Foo.java @@ -0,0 +1,5 @@ +public class Foo { + public static void main(String []argv) { + new DecoratedClass().m(); + } +} diff --git a/tests/src/org/aspectj/systemtest/ajc153/PipeliningTests.java b/tests/src/org/aspectj/systemtest/ajc153/PipeliningTests.java new file mode 100644 index 000000000..5da2dc836 --- /dev/null +++ b/tests/src/org/aspectj/systemtest/ajc153/PipeliningTests.java @@ -0,0 +1,87 @@ +/******************************************************************************* + * 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 diff --git a/tests/src/org/aspectj/systemtest/ajc153/pipelining.xml b/tests/src/org/aspectj/systemtest/ajc153/pipelining.xml new file mode 100644 index 000000000..409327ab7 --- /dev/null +++ b/tests/src/org/aspectj/systemtest/ajc153/pipelining.xml @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file -- 2.39.5