aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authoravasseur <avasseur>2005-10-25 10:00:58 +0000
committeravasseur <avasseur>2005-10-25 10:00:58 +0000
commit76ebbc76add2abd815b3a8b5ea0beb11c94c8c49 (patch)
tree08ac38010d43c13554209b03653af744edec4722 /tests
parentbd951ed3eaf19b17ac1b1541d6072246a21a2ca8 (diff)
downloadaspectj-76ebbc76add2abd815b3a8b5ea0beb11c94c8c49.tar.gz
aspectj-76ebbc76add2abd815b3a8b5ea0beb11c94c8c49.zip
concrete-aspect impl and doc for LTW - see #95529
pbly some issue on abstract @Pointcut() in ajdt core - fix coming
Diffstat (limited to 'tests')
-rw-r--r--tests/java5/ataspectj/ataspectj/ConcreteAspectTest.aj62
-rw-r--r--tests/java5/ataspectj/ataspectj/ConcreteAtAspectTest.java72
-rw-r--r--tests/java5/ataspectj/ataspectj/aop-concreteaspect.xml9
-rw-r--r--tests/java5/ataspectj/ataspectj/aop-concreteataspect.xml10
-rw-r--r--tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjLTWTests.java7
-rw-r--r--tests/src/org/aspectj/systemtest/ajc150/ataspectj/ltw.xml16
6 files changed, 176 insertions, 0 deletions
diff --git a/tests/java5/ataspectj/ataspectj/ConcreteAspectTest.aj b/tests/java5/ataspectj/ataspectj/ConcreteAspectTest.aj
new file mode 100644
index 000000000..d3bcd2136
--- /dev/null
+++ b/tests/java5/ataspectj/ataspectj/ConcreteAspectTest.aj
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 2005 Contributors.
+ * 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://eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexandre Vasseur initial implementation
+ *******************************************************************************/
+package ataspectj;
+
+import junit.framework.TestCase;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.Before;
+import org.aspectj.lang.annotation.Pointcut;
+
+/**
+ * @author <a href="mailto:alex AT gnilux DOT com">Alexandre Vasseur</a>
+ */
+public class ConcreteAspectTest extends TestCase {
+
+ static int I;
+
+ void target() {
+ I++;
+ }
+
+ // abstract aspect
+ // pc() is undefined hence always false, and advice not applied
+ // this aspect is illegal as is in aop.xml
+ // ones must use a concrete-aspect
+ static abstract aspect ConcreteAspect {
+
+ abstract pointcut pc();
+ // must be abstract
+ // for concrete-aspect, must further be no-arg, void
+ // but can be more complex for non-xml inheritance
+
+ before() : pc() {
+ I++;
+ }
+ }
+
+ public void testConcrete() {
+ I = 0;
+ target();
+ assertEquals(2, I);
+ }
+
+ public static void main(String[] args) {
+ TestHelper.runAndThrowOnFailure(suite());
+ }
+
+ public static Test suite() {
+ return new TestSuite(ConcreteAspectTest.class);
+ }
+
+}
diff --git a/tests/java5/ataspectj/ataspectj/ConcreteAtAspectTest.java b/tests/java5/ataspectj/ataspectj/ConcreteAtAspectTest.java
new file mode 100644
index 000000000..180ec4f2b
--- /dev/null
+++ b/tests/java5/ataspectj/ataspectj/ConcreteAtAspectTest.java
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 2005 Contributors.
+ * 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://eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexandre Vasseur initial implementation
+ *******************************************************************************/
+package ataspectj;
+
+import junit.framework.TestCase;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.Before;
+import org.aspectj.lang.annotation.Pointcut;
+
+/**
+ * @author <a href="mailto:alex AT gnilux DOT com">Alexandre Vasseur</a>
+ */
+public class ConcreteAtAspectTest extends TestCase {
+
+ static int I;
+
+ void target() {
+ I++;
+ }
+
+ // abstract aspect
+ // pc() is undefined hence always false, and advice not applied
+ // this aspect is illegal as is in aop.xml
+ // ones must use a concrete-aspect
+ @Aspect
+ abstract static class ConcreteAtAspect {
+
+ @Pointcut()
+ abstract void pc();
+ // must be abstract
+ // for concrete-aspect, must further be no-arg, void
+ // but can be more complex for non-xml inheritance
+
+ @Before("pc()")
+ public void before() {
+ I++;
+ }
+ }
+
+ // legal abstract aspect resolved with inheritance
+ @Aspect
+ static class ConcreteAtAspectSub extends ConcreteAtAspect {
+ @Pointcut("execution(* ataspectj.ConcreteAtAspectTest.target())")
+ void pc() {}
+ }
+
+ public void testConcrete() {
+ I = 0;
+ target();
+ assertEquals(3, I);
+ }
+
+ public static void main(String[] args) {
+ TestHelper.runAndThrowOnFailure(suite());
+ }
+
+ public static Test suite() {
+ return new TestSuite(ConcreteAtAspectTest.class);
+ }
+
+}
diff --git a/tests/java5/ataspectj/ataspectj/aop-concreteaspect.xml b/tests/java5/ataspectj/ataspectj/aop-concreteaspect.xml
new file mode 100644
index 000000000..a9f40938d
--- /dev/null
+++ b/tests/java5/ataspectj/ataspectj/aop-concreteaspect.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0"?>
+<aspectj>
+ <weaver options="-XmessageHandlerClass:ataspectj.TestHelper -1.5"/>
+ <aspects>
+ <concrete-aspect name="ataspectj.Foo" extends="ataspectj.ConcreteAspectTest.ConcreteAspect">
+ <pointcut name="pc" expression="execution(* ataspectj.ConcreteAspectTest.target())"/>
+ </concrete-aspect>
+ </aspects>
+</aspectj>
diff --git a/tests/java5/ataspectj/ataspectj/aop-concreteataspect.xml b/tests/java5/ataspectj/ataspectj/aop-concreteataspect.xml
new file mode 100644
index 000000000..9b38b3d64
--- /dev/null
+++ b/tests/java5/ataspectj/ataspectj/aop-concreteataspect.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0"?>
+<aspectj>
+ <weaver options="-XmessageHandlerClass:ataspectj.TestHelper -1.5"/>
+ <aspects>
+ <concrete-aspect name="ataspectj.Foo" extends="ataspectj.ConcreteAtAspectTest.ConcreteAtAspect">
+ <pointcut name="pc" expression="execution(* ataspectj.ConcreteAtAspectTest.target())"/>
+ </concrete-aspect>
+ <aspect name="ataspectj.ConcreteAtAspectTest.ConcreteAtAspectSub"/>
+ </aspects>
+</aspectj>
diff --git a/tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjLTWTests.java b/tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjLTWTests.java
index 79e3dc307..d0a88a27e 100644
--- a/tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjLTWTests.java
+++ b/tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjLTWTests.java
@@ -94,4 +94,11 @@ public class AtAjLTWTests extends XMLBasedAjcTestCase {
runTest("Compile time aspects declared to ltw weaver");
}
+ public void testConcreteAtAspect() {
+ runTest("Concrete@Aspect");
+ }
+
+ public void testConcreteAspect() {
+ runTest("ConcreteAspect");
+ }
}
diff --git a/tests/src/org/aspectj/systemtest/ajc150/ataspectj/ltw.xml b/tests/src/org/aspectj/systemtest/ajc150/ataspectj/ltw.xml
index a316e6799..fd2b922f1 100644
--- a/tests/src/org/aspectj/systemtest/ajc150/ataspectj/ltw.xml
+++ b/tests/src/org/aspectj/systemtest/ajc150/ataspectj/ltw.xml
@@ -131,4 +131,20 @@
<ant file="ajc-ant.xml" target="ltw.oldAspectsDeclared" verbose="true"/>
</ajc-test>
+ <ajc-test dir="java5/ataspectj" title="Concrete@Aspect">
+ <compile
+ files="ataspectj/ConcreteAtAspectTest.java,ataspectj/TestHelper.java"
+ options="-1.5 -Xdev:NoAtAspectJProcessing -XnoWeave"
+ />
+ <run class="ataspectj.ConcreteAtAspectTest" ltw="ataspectj/aop-concreteataspect.xml"/>
+ </ajc-test>
+
+ <ajc-test dir="java5/ataspectj" title="ConcreteAspect">
+ <compile
+ files="ataspectj/ConcreteAspectTest.aj,ataspectj/TestHelper.java"
+ options="-1.5 -Xdev:NoAtAspectJProcessing -XnoWeave"
+ />
+ <run class="ataspectj.ConcreteAspectTest" ltw="ataspectj/aop-concreteaspect.xml"/>
+ </ajc-test>
+
</suite> \ No newline at end of file