From 76ebbc76add2abd815b3a8b5ea0beb11c94c8c49 Mon Sep 17 00:00:00 2001 From: avasseur Date: Tue, 25 Oct 2005 10:00:58 +0000 Subject: concrete-aspect impl and doc for LTW - see #95529 pbly some issue on abstract @Pointcut() in ajdt core - fix coming --- .../ataspectj/ataspectj/ConcreteAspectTest.aj | 62 +++++++++++++++++++ .../ataspectj/ataspectj/ConcreteAtAspectTest.java | 72 ++++++++++++++++++++++ .../ataspectj/ataspectj/aop-concreteaspect.xml | 9 +++ .../ataspectj/ataspectj/aop-concreteataspect.xml | 10 +++ 4 files changed, 153 insertions(+) create mode 100644 tests/java5/ataspectj/ataspectj/ConcreteAspectTest.aj create mode 100644 tests/java5/ataspectj/ataspectj/ConcreteAtAspectTest.java create mode 100644 tests/java5/ataspectj/ataspectj/aop-concreteaspect.xml create mode 100644 tests/java5/ataspectj/ataspectj/aop-concreteataspect.xml (limited to 'tests/java5') 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 Alexandre Vasseur + */ +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 Alexandre Vasseur + */ +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 @@ + + + + + + + + + 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 @@ + + + + + + + + + + -- cgit v1.2.3