diff options
author | aclement <aclement> | 2006-09-22 10:49:37 +0000 |
---|---|---|
committer | aclement <aclement> | 2006-09-22 10:49:37 +0000 |
commit | 98a5d925536b291ca760ca510a2e06b7e3cff13e (patch) | |
tree | d349cbb016ddc7b55dae0c6eace09803ca799f4f /tests | |
parent | 1138f942d5c2367ef8a6abb4d30e724730bc8f79 (diff) | |
download | aspectj-98a5d925536b291ca760ca510a2e06b7e3cff13e.tar.gz aspectj-98a5d925536b291ca760ca510a2e06b7e3cff13e.zip |
154054 testcode and fix: noticing changes in around advice and forcing full builds
Diffstat (limited to 'tests')
10 files changed, 151 insertions, 8 deletions
diff --git a/tests/bugs153/pr154054/changes/MyAspect.20.aj b/tests/bugs153/pr154054/changes/MyAspect.20.aj new file mode 100644 index 000000000..d2a7a7155 --- /dev/null +++ b/tests/bugs153/pr154054/changes/MyAspect.20.aj @@ -0,0 +1,10 @@ +public aspect MyAspect { + + pointcut mypointcut(): execution(* getX()) && !within(MyAspect); + + int around(): mypointcut() { + int w = proceed() + 4; + return w; + } + +} diff --git a/tests/bugs153/pr154054/src/MyAspect.aj b/tests/bugs153/pr154054/src/MyAspect.aj new file mode 100644 index 000000000..4aa4e9734 --- /dev/null +++ b/tests/bugs153/pr154054/src/MyAspect.aj @@ -0,0 +1,10 @@ +public aspect MyAspect { + + pointcut mypointcut(): execution(* getX()) && !within(MyAspect); + + int around(): mypointcut() { + int w = proceed() + 3; + return w; + } + +} diff --git a/tests/bugs153/pr154054/src/MyClass.java b/tests/bugs153/pr154054/src/MyClass.java new file mode 100644 index 000000000..4e81e3038 --- /dev/null +++ b/tests/bugs153/pr154054/src/MyClass.java @@ -0,0 +1,19 @@ +public class MyClass { + + int x; + + public int getX() { + return x; + } + + public void setX(int x) { + this.x = x; + } + + public static void main(String[] args) { + MyClass m = new MyClass(); + m.setX(10); + System.out.println(m.getX()); + } + +} diff --git a/tests/bugs153/pr154054_2/changes/MyAspect.30.aj b/tests/bugs153/pr154054_2/changes/MyAspect.30.aj new file mode 100644 index 000000000..f6d91ec38 --- /dev/null +++ b/tests/bugs153/pr154054_2/changes/MyAspect.30.aj @@ -0,0 +1,10 @@ +public aspect MyAspect { + + pointcut mypointcut(): execution(* getName()) && !within(MyAspect); + + String around(): mypointcut() { + String w = proceed() + " and Harry"; + return w; + } + +} diff --git a/tests/bugs153/pr154054_2/src/MyAspect.aj b/tests/bugs153/pr154054_2/src/MyAspect.aj new file mode 100644 index 000000000..b3b167963 --- /dev/null +++ b/tests/bugs153/pr154054_2/src/MyAspect.aj @@ -0,0 +1,10 @@ +public aspect MyAspect { + + pointcut mypointcut(): execution(* getName()) && !within(MyAspect); + + String around(): mypointcut() { + String w = proceed() + " and George"; + return w; + } + +} diff --git a/tests/bugs153/pr154054_2/src/MyClass.java b/tests/bugs153/pr154054_2/src/MyClass.java new file mode 100644 index 000000000..f0b28cb79 --- /dev/null +++ b/tests/bugs153/pr154054_2/src/MyClass.java @@ -0,0 +1,19 @@ +public class MyClass { + + String name; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public static void main(String[] args) { + MyClass m = new MyClass(); + m.setName("Fred"); + System.out.println(m.getName()); + } + +} diff --git a/tests/java5/ataspectj/ataspectj/IfPointcut2Test.java b/tests/java5/ataspectj/ataspectj/IfPointcut2Test.java index 37cd6f042..73b4b0f84 100644 --- a/tests/java5/ataspectj/ataspectj/IfPointcut2Test.java +++ b/tests/java5/ataspectj/ataspectj/IfPointcut2Test.java @@ -33,20 +33,24 @@ public class IfPointcut2Test extends TestCase { f.doo(); f.doo(1); f.dooMulti(); - assertEquals( - "test aop test2-doo-doo aop2 doo test3-1-doo-doo-doo aop3 doo-1 testTWO-dooMulti testONE-dooMulti aop doMulti ", - s_log.toString() - ); + // we don't want to rely on the order the if pcds are evaluated + String exp1 = "test aop test2-doo-doo aop2 doo test3-1-doo-doo-doo aop3 doo-1 testTWO-dooMulti testONE-dooMulti aop doMulti "; + String exp2 = "test aop test2-doo-doo aop2 doo test3-1-doo-doo-doo aop3 doo-1 testONE-dooMulti testTWO-dooMulti aop doMulti "; + boolean equ = (exp1.equals(s_log.toString()) || exp2.equals(s_log.toString())); + assertTrue("expected log to contain \n" + exp1 +"\n or \n" + exp2 + "\n but found \n" + s_log.toString(), equ); s_log = new StringBuffer(); IfAspect.ISON = false; f.doo(); f.doo(1); f.dooMulti(); - assertEquals( - "test test2-doo-doo doo test3-1-doo-doo-doo doo-1 testTWO-dooMulti doMulti ", - s_log.toString() - ); + + // we don't want to rely on the order the if pcds are evaluated + String exp3 = "test test2-doo-doo doo test3-1-doo-doo-doo doo-1 testTWO-dooMulti doMulti "; + String exp4 = "test test2-doo-doo doo test3-1-doo-doo-doo doo-1 testONE-dooMulti doMulti "; + + equ = (exp3.equals(s_log.toString()) || exp4.equals(s_log.toString())); + assertTrue("expected log to contain \n" + exp3 +"\n or \n" + exp4 + "\n but found \n" + s_log.toString(), equ); } public static void main(String[] args) { diff --git a/tests/src/org/aspectj/systemtest/incremental/IncrementalTests.java b/tests/src/org/aspectj/systemtest/incremental/IncrementalTests.java index cd6ed60a1..c977cd813 100644 --- a/tests/src/org/aspectj/systemtest/incremental/IncrementalTests.java +++ b/tests/src/org/aspectj/systemtest/incremental/IncrementalTests.java @@ -280,5 +280,30 @@ public class IncrementalTests extends org.aspectj.testing.XMLBasedAjcTestCase { RunResult before = run("pack.Main"); } + public void testIncrementalUpdateOfBodyInAroundAdvice_pr154054() throws Exception { + runTest("incremental update of body in around advice"); + nextIncrement(true); + RunResult before = run("MyClass"); + assertTrue("value should be 13 but was " + before.getStdOut(), + before.getStdOut().startsWith("13")); + // update value added to proceed + copyFileAndDoIncrementalBuild("changes/MyAspect.20.aj","src/MyAspect.aj"); + RunResult after = run("MyClass"); + assertTrue("value should be 14 but was " + after.getStdOut(), + after.getStdOut().startsWith("14")); + } + + public void testIncrementalUpdateOfBodyInAroundAdviceWithString_pr154054() throws Exception { + runTest("incremental update of body in around advice with string"); + nextIncrement(true); + RunResult before = run("MyClass"); + assertTrue("expected 'Fred and George' in output but found " + before.getStdOut(), + before.getStdOut().startsWith("Fred and George")); + // update value added to proceed + copyFileAndDoIncrementalBuild("changes/MyAspect.30.aj","src/MyAspect.aj"); + RunResult after = run("MyClass"); + assertTrue("expected 'Fred and Harry' in output but found " + after.getStdOut(), + after.getStdOut().startsWith("Fred and Harry")); + } } diff --git a/tests/src/org/aspectj/systemtest/incremental/incremental-junit-tests.xml b/tests/src/org/aspectj/systemtest/incremental/incremental-junit-tests.xml index 794a63dd3..48a6183ff 100644 --- a/tests/src/org/aspectj/systemtest/incremental/incremental-junit-tests.xml +++ b/tests/src/org/aspectj/systemtest/incremental/incremental-junit-tests.xml @@ -388,4 +388,22 @@ <!--inc-compile tag="20"/--> <!--run class="pack.Main"/--> </ajc-test> + + <ajc-test dir="bugs153/pr154054" pr="154054" + title="incremental update of body in around advice"> + <compile staging="true" + options="-incremental,-verbose" + sourceroots="src"/> + <!--inc-compile tag="20"/--> + <!--run class="MyClass"/--> + </ajc-test> + + <ajc-test dir="bugs153/pr154054_2" pr="154054" + title="incremental update of body in around advice with string"> + <compile staging="true" + options="-incremental,-verbose" + sourceroots="src"/> + <!--inc-compile tag="30"/--> + <!--run class="MyClass"/--> + </ajc-test>
\ No newline at end of file diff --git a/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java b/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java index 900033e2e..5214c898f 100644 --- a/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java +++ b/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java @@ -1524,6 +1524,24 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa +warnings,warnings.isEmpty()); } + // see comment #11 of bug 154054 + public void testNoFullBuildOnChangeInSysOutInAdviceBody_pr154054() { + initialiseProject("PR154054"); + build("PR154054"); + alter("PR154054","inc1"); + build("PR154054"); + checkWasntFullBuild(); + } + + // change exception type in around advice, does it notice? + public void testShouldFullBuildOnExceptionChange_pr154054() { + initialiseProject("PR154054_2"); + build("PR154054_2"); + alter("PR154054_2","inc1"); + build("PR154054_2"); + checkWasFullBuild(); + } + // --- helper code --- /** |