diff options
author | aclement <aclement> | 2008-01-25 18:55:53 +0000 |
---|---|---|
committer | aclement <aclement> | 2008-01-25 18:55:53 +0000 |
commit | bf5bf21b7c668f73401ec1515d60ff1f12dd1d63 (patch) | |
tree | 2c765894980d3629ad527423bbdffd9e6e7c2e2b /tests | |
parent | 7131d6ad9132eb620463e66a7b8cfce1397e5538 (diff) | |
download | aspectj-bf5bf21b7c668f73401ec1515d60ff1f12dd1d63.tar.gz aspectj-bf5bf21b7c668f73401ec1515d60ff1f12dd1d63.zip |
paramannos: testcode
Diffstat (limited to 'tests')
-rw-r--r-- | tests/src/org/aspectj/systemtest/ajc160/ParameterAnnotationMatchingTests.java | 107 | ||||
-rw-r--r-- | tests/src/org/aspectj/systemtest/ajc160/parameterAnnotations.xml | 118 |
2 files changed, 225 insertions, 0 deletions
diff --git a/tests/src/org/aspectj/systemtest/ajc160/ParameterAnnotationMatchingTests.java b/tests/src/org/aspectj/systemtest/ajc160/ParameterAnnotationMatchingTests.java new file mode 100644 index 000000000..6065a9c4e --- /dev/null +++ b/tests/src/org/aspectj/systemtest/ajc160/ParameterAnnotationMatchingTests.java @@ -0,0 +1,107 @@ +/* ******************************************************************* + * Copyright (c) 2008 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://www.eclipse.org/legal/epl-v10.html + * + * Contributors + * Andy Clement + * ******************************************************************/ +package org.aspectj.systemtest.ajc160; + + +import java.io.File; + +import org.aspectj.testing.XMLBasedAjcTestCase; + +import junit.framework.Test; + +/** + * Parameter annotation matching + * + * The full implementation will require static matching, binding and possibly runtime + * matching (need to check on inheritance of annotations specified in these positions). + * The extension to the syntax for method-signatures is to require parentheses when + * specifying annotations relating to parameters and parameter types - the position of + * the parentheses enable the distinction to be made between annotations attached to + * the type of the parameter and annotations attached to the parameter itself. + * + * For example: + * + * public void goo(MyType s) {} // where MyType has annotation @B + * public void foo(@A String s) {} // String has no annotations, @A is a parameter annotation + * + * A method signature to match the former would be: + * execution(public void goo(@B MyType)) + * or execution(public void goo((@B MyType))) + * + * To match the latter: + * execution(public void foo(@A (String))) + * The parentheses around String are telling us that there are no annotations attached to the + * parameter type we are interested in, and @A should be treated as an intent to match on + * parameter annotation A. + * + * In a more complex case: + * public void hoo(@A MyType s) {} // now there are two potential annotations we are interested in + * the match expression is: + * execution(public void hoo(@A (@B MyType))) + * the parentheses associating @B with the type of the parameter leaving @A outside to be + * treated as a parameter annotation. + * + +TODO BEFORE FIRST UPLOAD: +2. Don't set the param annos on the type patterns - add new methods and pass them through + +doc + + + + + * Testplan: + * Test cases for the parameter annotation matching: + * DONE: + * 1. Basic pointcut parsing for the new method signature syntax + * 2. Expression matching with the new syntax + * 3. Real static matching with the new syntax + * 4. hasmethod should pick up the new syntax + * 5. ellipsis usage not impacted + * 6. recognizing varargs + * 7. constructor matching + * 8. binary weaving + * + * NOT DONE: + * . New pointcut designator parsing + * . Expression matching with the new syntax + * . Real matching with the new syntax + * . Binding with the new syntax. + * . complaining about annotations that dont target the right type + * . itds + * . visibility tests + * . wildcarded @Ann*1 - broken (not my doing) + * . ltw + * + * to be done: + * - equals/hashcode where the new flags have been introduced - is it all ok? + * + */ +public class ParameterAnnotationMatchingTests extends XMLBasedAjcTestCase { + + public void testVariousCombinations() { runTest("various combinations"); } + public void testVariousCombinationsCtors() { runTest("various combinations - ctors"); } + public void testHasMethod() { runTest("hasmethod"); } + public void testBinaryWeaving() { runTest("binary weaving"); } + // this is broken and it was already broken before I added parameter annotation matching ! +// public void testWildcardedAnnotationMatching() { runTest("wildcarded matching"); } + + + ///////////////////////////////////////// + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(ParameterAnnotationMatchingTests.class); + } + + protected File getSpecFile() { + return new File("../tests/src/org/aspectj/systemtest/ajc160/parameterAnnotations.xml"); + } +} diff --git a/tests/src/org/aspectj/systemtest/ajc160/parameterAnnotations.xml b/tests/src/org/aspectj/systemtest/ajc160/parameterAnnotations.xml new file mode 100644 index 000000000..560ffa585 --- /dev/null +++ b/tests/src/org/aspectj/systemtest/ajc160/parameterAnnotations.xml @@ -0,0 +1,118 @@ +<!DOCTYPE suite SYSTEM "../tests/ajcTestSuite.dtd"[]> + +<!-- AspectJ v1.6.0 Parameter Annotation Matching Tests --> +<suite> + + <ajc-test dir="features160/parameterAnnotationMatching" title="various combinations"> + <compile options="-1.5 -showWeaveInfo" files="TestMatching.aj Anno1.java Anno2.java AnnotatedWithAnno1.java AnnotatedWithAnno2.java"> + <message kind="weave" text="'TestMatching' (TestMatching.aj:4) advised by before advice from 'TestMatching' (TestMatching.aj:3)"/> + + <message kind="weave" text="'TestMatching' (TestMatching.aj:7) advised by before advice from 'TestMatching' (TestMatching.aj:6)"/> + + <message kind="weave" text="'TestMatching' (TestMatching.aj:11) advised by before advice from 'TestMatching' (TestMatching.aj:10)"/> + + <message kind="weave" text="'TestMatching' (TestMatching.aj:16) advised by before advice from 'TestMatching' (TestMatching.aj:15)"/> + + <message kind="weave" text="'TestMatching' (TestMatching.aj:22) advised by before advice from 'TestMatching' (TestMatching.aj:21)"/> + + <message kind="weave" text="'TestMatching' (TestMatching.aj:27) advised by before advice from 'TestMatching' (TestMatching.aj:26)"/> + <message kind="weave" text="'TestMatching' (TestMatching.aj:31) advised by before advice from 'TestMatching' (TestMatching.aj:26)"/> + + <message kind="weave" text="'TestMatching' (TestMatching.aj:34) advised by before advice from 'TestMatching' (TestMatching.aj:33)"/> + + <message kind="weave" text="'TestMatching' (TestMatching.aj:40) advised by before advice from 'TestMatching' (TestMatching.aj:39)"/> + <message kind="weave" text="'TestMatching' (TestMatching.aj:41) advised by before advice from 'TestMatching' (TestMatching.aj:39)"/> + <message kind="weave" text="'TestMatching' (TestMatching.aj:42) advised by before advice from 'TestMatching' (TestMatching.aj:39)"/> + + <message kind="weave" text="'TestMatching' (TestMatching.aj:47) advised by before advice from 'TestMatching' (TestMatching.aj:46)"/> + <message kind="weave" text="'TestMatching' (TestMatching.aj:48) advised by before advice from 'TestMatching' (TestMatching.aj:46)"/> + + <message kind="weave" text="'TestMatching' (TestMatching.aj:53) advised by before advice from 'TestMatching' (TestMatching.aj:52)"/> + <message kind="weave" text="'TestMatching' (TestMatching.aj:54) advised by before advice from 'TestMatching' (TestMatching.aj:52)"/> + + <message kind="warning" line="57" text="not been applied"/> + + <message kind="weave" text="'TestMatching' (TestMatching.aj:62) advised by before advice from 'TestMatching' (TestMatching.aj:61)"/> + + </compile> + </ajc-test> + + <ajc-test dir="features160/parameterAnnotationMatching" title="wildcarded matching"> + <compile options="-1.5 -showWeaveInfo" files="WildcardedMatching.aj Anno1.java Anno2.java AnnotatedWithAnno1.java AnnotatedWithAnno2.java"> + <!-- tbd --> + </compile> + </ajc-test> + + + <ajc-test dir="features160/parameterAnnotationMatching" title="various combinations - ctors"> + <compile options="-1.5 -showWeaveInfo" files="TestMatchingCtors.aj Anno1.java Anno2.java AnnotatedWithAnno1.java AnnotatedWithAnno2.java"> + <message kind="weave" text="(TestMatchingCtors.aj:4) advised by before advice from 'TestMatching' (TestMatchingCtors.aj:3)"/> + + <message kind="weave" text="(TestMatchingCtors.aj:7) advised by before advice from 'TestMatching' (TestMatchingCtors.aj:6)"/> + + <message kind="weave" text="(TestMatchingCtors.aj:11) advised by before advice from 'TestMatching' (TestMatchingCtors.aj:10)"/> + + <message kind="weave" text="(TestMatchingCtors.aj:16) advised by before advice from 'TestMatching' (TestMatchingCtors.aj:15)"/> + + <message kind="weave" text="(TestMatchingCtors.aj:22) advised by before advice from 'TestMatching' (TestMatchingCtors.aj:21)"/> + + <message kind="weave" text="(TestMatchingCtors.aj:27) advised by before advice from 'TestMatching' (TestMatchingCtors.aj:26)"/> + <message kind="weave" text="(TestMatchingCtors.aj:31) advised by before advice from 'TestMatching' (TestMatchingCtors.aj:26)"/> + + <message kind="weave" text="(TestMatchingCtors.aj:34) advised by before advice from 'TestMatching' (TestMatchingCtors.aj:33)"/> + + <message kind="weave" text="(TestMatchingCtors.aj:40) advised by before advice from 'TestMatching' (TestMatchingCtors.aj:39)"/> + <message kind="weave" text="(TestMatchingCtors.aj:41) advised by before advice from 'TestMatching' (TestMatchingCtors.aj:39)"/> + <message kind="weave" text="(TestMatchingCtors.aj:42) advised by before advice from 'TestMatching' (TestMatchingCtors.aj:39)"/> + + <message kind="weave" text="(TestMatchingCtors.aj:47) advised by before advice from 'TestMatching' (TestMatchingCtors.aj:46)"/> + <message kind="weave" text="(TestMatchingCtors.aj:48) advised by before advice from 'TestMatching' (TestMatchingCtors.aj:46)"/> + + <message kind="weave" text="(TestMatchingCtors.aj:53) advised by before advice from 'TestMatching' (TestMatchingCtors.aj:52)"/> + <message kind="weave" text="(TestMatchingCtors.aj:54) advised by before advice from 'TestMatching' (TestMatchingCtors.aj:52)"/> + + <message kind="warning" line="57" text="not been applied"/> + + <message kind="weave" text="(TestMatchingCtors.aj:62) advised by before advice from 'TestMatching' (TestMatchingCtors.aj:61)"/> + + </compile> + </ajc-test> + + <ajc-test dir="features160/parameterAnnotationMatching" title="hasmethod"> + <compile options="-1.5 -showWeaveInfo -XhasMember" files="HasMethodMatching.aj Anno1.java Anno2.java AnnotatedWithAnno1.java AnnotatedWithAnno2.java"> + <message kind="weave" text="Extending interface set for type 'Target1' (HasMethodMatching.aj) to include 'java.io.Serializable' (HasMethodMatching.aj)"/> + <message kind="weave" text="Extending interface set for type 'Target3' (HasMethodMatching.aj) to include 'java.io.Serializable' (HasMethodMatching.aj)"/> + <message kind="weave" text="Extending interface set for type 'Target4' (HasMethodMatching.aj) to include 'java.io.Serializable' (HasMethodMatching.aj)"/> + </compile> + <run class="HasMethodMatching"> + <stdout> + <line text="Target1? true"/> + <line text="Target2? false"/> + <line text="Target3? true"/> + <line text="Target4? true"/> + <line text="Target5? false"/> + </stdout> + </run> + </ajc-test> + + <ajc-test dir="features160/parameterAnnotationMatching" title="binary weaving"> + <compile options="-1.5" files="SimpleType.java Anno1.java Anno2.java AnnotatedWithAnno1.java AnnotatedWithAnno2.java AnnotatedWithBoth.java" outjar="code.jar"/> + <compile options="-1.5 -showWeaveInfo" files="SimpleAspect.java" inpath="code.jar"> + <message kind="weave" text="(SimpleType.java:2) advised by before advice from 'SimpleAspect' (SimpleAspect.java:2)"/> + <message kind="weave" text="(SimpleType.java:3) advised by before advice from 'SimpleAspect' (SimpleAspect.java:4)"/> + <message kind="weave" text="(SimpleType.java:4) advised by before advice from 'SimpleAspect' (SimpleAspect.java:6)"/> + <message kind="weave" text="(SimpleType.java:4) advised by before advice from 'SimpleAspect' (SimpleAspect.java:4)"/> + <message kind="weave" text="(SimpleType.java:4) advised by before advice from 'SimpleAspect' (SimpleAspect.java:3)"/> + <message kind="weave" text="(SimpleType.java:5) advised by before advice from 'SimpleAspect' (SimpleAspect.java:5)"/> + <message kind="weave" text="(SimpleType.java:5) advised by before advice from 'SimpleAspect' (SimpleAspect.java:4)"/> + <message kind="weave" text="(SimpleType.java:6) advised by before advice from 'SimpleAspect' (SimpleAspect.java:7)"/> + <message kind="weave" text="(SimpleType.java:6) advised by before advice from 'SimpleAspect' (SimpleAspect.java:6)"/> + <message kind="weave" text="(SimpleType.java:6) advised by before advice from 'SimpleAspect' (SimpleAspect.java:5)"/> + <message kind="weave" text="(SimpleType.java:6) advised by before advice from 'SimpleAspect' (SimpleAspect.java:4)"/> + <message kind="weave" text="(SimpleType.java:6) advised by before advice from 'SimpleAspect' (SimpleAspect.java:3)"/> + <message kind="weave" text="(SimpleType.java:6) advised by before advice from 'SimpleAspect' (SimpleAspect.java:2)"/> + </compile> + </ajc-test> + + +</suite>
\ No newline at end of file |