diff options
author | aclement <aclement> | 2006-01-19 09:40:04 +0000 |
---|---|---|
committer | aclement <aclement> | 2006-01-19 09:40:04 +0000 |
commit | 7e6cfb2bbb19a01ba9043a3e791d9128dd162e75 (patch) | |
tree | 08b891aad76177c7a22fa36fd2b28a60d90c04b8 /tests/src | |
parent | 04067a6017182b42f520e450240dc90a2ed86bb4 (diff) | |
download | aspectj-7e6cfb2bbb19a01ba9043a3e791d9128dd162e75.tar.gz aspectj-7e6cfb2bbb19a01ba9043a3e791d9128dd162e75.zip |
77166 - newarray joinpoint - testcode
Diffstat (limited to 'tests/src')
-rw-r--r-- | tests/src/org/aspectj/systemtest/ajc151/NewarrayJoinpointTests.java | 75 | ||||
-rw-r--r-- | tests/src/org/aspectj/systemtest/ajc151/newarray_joinpoint.xml | 153 |
2 files changed, 228 insertions, 0 deletions
diff --git a/tests/src/org/aspectj/systemtest/ajc151/NewarrayJoinpointTests.java b/tests/src/org/aspectj/systemtest/ajc151/NewarrayJoinpointTests.java new file mode 100644 index 000000000..fb46d3b8f --- /dev/null +++ b/tests/src/org/aspectj/systemtest/ajc151/NewarrayJoinpointTests.java @@ -0,0 +1,75 @@ +/******************************************************************************* + * Copyright (c) 2006 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Andy Clement - initial implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc151; + +import java.io.File; + +import junit.framework.Test; + +import org.aspectj.testing.XMLBasedAjcTestCase; + +/* + * The design: + * + * There are 3 instructions that create arrays: + * + * - NEWARRAY for primitive arrays + * - ANEWARRAY for object arrays + * - MULTIANEWARRAY for multidimensional arrays + * + * The changes to expose the new joinpoint are in: + * BcelClassWeaver.match(LazyMethodGen mg,InstructionHandle ih,BcelShadow enclosingShadow,List shadowAccumulator) + * + * Determining the type of the array is easy. Determining the size of the array is not easily statically, it is on the stack. + * + * + * to think about: + * + * args + * thisJoinPoint - does anything need to manifest in it? + * wildcards in declaringtype 'Integer*' matches 'Integer[]' ? + * what is the signature of the joinpoint - are its modifiers simply 'public' ? + */ + + +public class NewarrayJoinpointTests extends XMLBasedAjcTestCase { + + // when its the creation of a new 'object' (not a primitive) single dimension array + public void testTheBasics_1() { runTest("basics"); } + public void testTheBasics_2() { runTest("basics - 2"); } + public void testWhatShouldntMatch() { runTest("shouldnt match"); } + public void testThisJoinPoint() { runTest("thisjoinpoint"); } + public void testDifferentAdviceKinds() { runTest("different advice kinds");} + public void testArgs() { runTest("args");} + + // when it is the creation of a new array of primitives + public void testBasicWithAPrimitiveArray() { runTest("basic primitive array creation");} + + + // when it is the creation of a new multi-dimensional array + public void testBasicWithAMultiDimensionalArray() { runTest("multi dimensional array creation"); } + public void testArgsWithAMultiDimensionalArray() { runTest("multi dimensional array args");} + + // complicated + public void testUsingTargetAndAfterReturningAdvice() { runTest("using target and after returning");} + public void testUsingItForReal() { runTest("using it for real");} + public void testDifferentiatingArrayTypes() { runTest("differentiating array types");} + + // + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(NewarrayJoinpointTests.class); + } + + protected File getSpecFile() { + return new File("../tests/src/org/aspectj/systemtest/ajc151/newarray_joinpoint.xml"); + } + +} diff --git a/tests/src/org/aspectj/systemtest/ajc151/newarray_joinpoint.xml b/tests/src/org/aspectj/systemtest/ajc151/newarray_joinpoint.xml new file mode 100644 index 000000000..39fa37225 --- /dev/null +++ b/tests/src/org/aspectj/systemtest/ajc151/newarray_joinpoint.xml @@ -0,0 +1,153 @@ +<!DOCTYPE suite SYSTEM "../tests/ajcTestSuite.dtd"[]> + +<!-- AspectJ v1.5.1 Tests --> +<suite> + + <ajc-test dir="features151/newarrayjoinpoint" title="basics"> + <compile files="One.java" options="-1.5 -showWeaveInfo"> + <message kind="weave" text="Join point 'constructor-call(void java.lang.Integer[].<init>(int))' in Type 'One' (One.java:4) advised by before advice from 'X' (One.java:9)"/> + </compile> + <run class="One"> + <stderr> + <line text="advice running"/> + </stderr> + </run> + </ajc-test> + + + <ajc-test dir="features151/newarrayjoinpoint" title="basics - 2"> + <compile files="Two.java" options="-1.5 -showWeaveInfo"> + <message kind="weave" text="Join point 'constructor-call(void java.lang.Integer[].<init>(int))' in Type 'Two' (Two.java:4) advised by before advice from 'X' (Two.java:9)"/> + </compile> + <run class="Two"> + <stderr> + <line text="advice running"/> + </stderr> + </run> + </ajc-test> + + <ajc-test dir="features151/newarrayjoinpoint" title="shouldnt match"> + <compile files="Three.java" options="-1.5 -showWeaveInfo"> + <message kind="warning" line="9" text="advice defined in X has not been applied [Xlint:adviceDidNotMatch]"/> + <message kind="warning" line="10" text="advice defined in X has not been applied [Xlint:adviceDidNotMatch]"/> + <message kind="warning" line="11" text="advice defined in X has not been applied [Xlint:adviceDidNotMatch]"/> + <message kind="warning" line="12" text="advice defined in X has not been applied [Xlint:adviceDidNotMatch]"/> + </compile> + </ajc-test> + + <ajc-test dir="features151/newarrayjoinpoint" title="thisjoinpoint"> + <compile files="Four.java" options="-1.5 -showWeaveInfo"> + <message kind="weave" text="Join point 'constructor-call(void java.lang.Integer[].<init>(int))' in Type 'Four' (Four.java:4) advised by before advice from 'X' (Four.java:10)"/> + <message kind="weave" text="Join point 'constructor-call(void Foo.<init>(int))' in Type 'Four' (Four.java:5) advised by before advice from 'X' (Four.java:13)"/> + </compile> + <run class="Four"> + <stderr> + <line text="tjp1=>call(java.lang.Integer[](int))"/> + <line text="tjp2=>call(Foo(int))"/> + </stderr> + </run> + </ajc-test> + + <ajc-test dir="features151/newarrayjoinpoint" title="different advice kinds"> + <compile files="Five.java" options="-1.5 -showWeaveInfo"> + <message kind="weave" text="Join point 'constructor-call(void java.lang.Integer[].<init>(int))' in Type 'Five' (Five.java:4) advised by around advice from 'Z' (Five.java:16)"/> + <message kind="weave" text="Join point 'constructor-call(void java.lang.Integer[].<init>(int))' in Type 'Five' (Five.java:4) advised by after advice from 'Y' (Five.java:12)"/> + <message kind="weave" text="Join point 'constructor-call(void java.lang.Integer[].<init>(int))' in Type 'Five' (Five.java:4) advised by afterReturning advice from 'Y' (Five.java:13)"/> + <message kind="weave" text="Join point 'constructor-call(void java.lang.Integer[].<init>(int))' in Type 'Five' (Five.java:4) advised by before advice from 'X' (Five.java:9)"/> + </compile> + <run class="Five"> + <stderr> + <line text="before"/> + <line text="around!"/> + <line text="after"/> + <line text="after returning"/> + </stderr> + </run> + </ajc-test> + + <ajc-test dir="features151/newarrayjoinpoint" title="args"> + <compile files="Six.java" options="-1.5"/> + <run class="Six"> + <stderr> + <line text="Array size = 5"/> + </stderr> + </run> + </ajc-test> + + <ajc-test dir="features151/newarrayjoinpoint" title="basic primitive array creation"> + <compile files="Seven.java" options="-1.5"/> + <run class="Seven"> + <stderr> + <line text="advice running"/> + </stderr> + </run> + </ajc-test> + + <ajc-test dir="features151/newarrayjoinpoint" title="multi dimensional array creation"> + <compile files="Eight.java" options="-1.5"/> + <run class="Eight"> + <stderr> + <line text="advice running 2"/> + <line text="advice running 1"/> + </stderr> + </run> + </ajc-test> + + <ajc-test dir="features151/newarrayjoinpoint" title="multi dimensional array args"> + <compile files="Nine.java" options="-1.5"/> + <run class="Nine"> + <stderr> + <line text="advice running 2 (5,6)"/> + <line text="advice running 1 (2,4)"/> + </stderr> + </run> + </ajc-test> + + <ajc-test dir="features151/newarrayjoinpoint" title="using target and after returning"> + <compile files="Ten.java" options="-1.5 -showWeaveInfo"> + <message kind="warning" line="13" text="advice defined in X has not been applied [Xlint:adviceDidNotMatch]"/> + <message kind="warning" line="17" text="advice defined in X has not been applied [Xlint:adviceDidNotMatch]"/> + <message kind="weave" text="Join point 'constructor-call(void Ten.<init>())' in Type 'Ten' (Ten.java:4) advised by afterReturning advice from 'X' (Ten.java:21)"/> + <message kind="weave" text="Join point 'constructor-call(void int[].<init>(int))' in Type 'Ten' (Ten.java:5) advised by afterReturning advice from 'X' (Ten.java:21)"/> + </compile> + <run class="Ten"> + <stderr> + <line text="afterReturning class Ten"/> + <line text="afterReturning class [I"/> + </stderr> + </run> + </ajc-test> + + <ajc-test dir="features151/newarrayjoinpoint" title="using it for real"> + <compile files="Eleven.java" options="-1.5"> + <!--message kind="weave" text="Join point 'constructor-call(void Ten.<init>())' in Type 'Ten' (Ten.java:4) advised by afterReturning advice from 'X' (Ten.java:21)"/> + <message kind="weave" text="Join point 'constructor-call(void int[].<init>(int))' in Type 'Ten' (Ten.java:5) advised by afterReturning advice from 'X' (Ten.java:21)"/--> + </compile> + <run class="Eleven"> + <stderr> + <line text="Found the interesting array"/> + </stderr> + </run> + </ajc-test> + + <ajc-test dir="features151/newarrayjoinpoint" title="differentiating array types"> + <compile files="Twelve.java" options="-1.5"/> + <run class="Twelve"> + <stderr> + <line text="It is class [I"/> + <line text="Is it an array? true"/> + <line text="Component type is int"/> + <line text="--"/> + <line text="It is class [Ljava.lang.Integer;"/> + <line text="Is it an array? true"/> + <line text="Component type is class java.lang.Integer"/> + <line text="--"/> + <line text="It is class [[Ljava.lang.String;"/> + <line text="Is it an array? true"/> + <line text="Component type is class [Ljava.lang.String;"/> + <line text="--"/> + </stderr> + </run> + </ajc-test> + +</suite>
\ No newline at end of file |