From 24d3c4539ea77e5eeebe8baf9dcb6cb373cdcb11 Mon Sep 17 00:00:00 2001 From: aclement Date: Tue, 4 Apr 2006 08:10:07 +0000 Subject: [PATCH] tests for 133532 - also tidied up the statelistener code --- .../incremental/IncrementalTests.java | 16 ++++++++----- .../tools/AjdeInteractionTestbed.java | 23 ++++++++++++++++++- .../tools/MultiProjectIncrementalTests.java | 23 +++++++++++++++++++ 3 files changed, 55 insertions(+), 7 deletions(-) diff --git a/tests/src/org/aspectj/systemtest/incremental/IncrementalTests.java b/tests/src/org/aspectj/systemtest/incremental/IncrementalTests.java index 3b7aefce3..09f8248bc 100644 --- a/tests/src/org/aspectj/systemtest/incremental/IncrementalTests.java +++ b/tests/src/org/aspectj/systemtest/incremental/IncrementalTests.java @@ -133,12 +133,16 @@ public class IncrementalTests extends org.aspectj.testing.XMLBasedAjcTestCase { public void buildSuccessful(boolean wasFullBuild) {} }; MyStateListener sl = new MyStateListener(); - AjState.stateListener = sl; - runTest("change source"); - nextIncrement(false); - copyFileAndDoIncrementalBuild("changes/Main.20.java","src/app/Main.java"); - assertTrue("Did not expect a path change to be detected ",!sl.pathChange); - run("app.Main"); + try { + AjState.stateListener = sl; + runTest("change source"); + nextIncrement(false); + copyFileAndDoIncrementalBuild("changes/Main.20.java","src/app/Main.java"); + assertTrue("Did not expect a path change to be detected ",!sl.pathChange); + run("app.Main"); + } finally { + AjState.stateListener=null; + } } public void test009() throws Exception { diff --git a/tests/src/org/aspectj/systemtest/incremental/tools/AjdeInteractionTestbed.java b/tests/src/org/aspectj/systemtest/incremental/tools/AjdeInteractionTestbed.java index e8f0e4d08..38be2dd60 100644 --- a/tests/src/org/aspectj/systemtest/incremental/tools/AjdeInteractionTestbed.java +++ b/tests/src/org/aspectj/systemtest/incremental/tools/AjdeInteractionTestbed.java @@ -80,6 +80,7 @@ public class AjdeInteractionTestbed extends TestCase { protected void setUp() throws Exception { super.setUp(); + if (AjState.stateListener==null) AjState.stateListener=MyStateListener.getInstance(); MyStateListener.reset(); MyBuildProgressMonitor.reset(); MyTaskListManager.reset(); @@ -89,6 +90,11 @@ public class AjdeInteractionTestbed extends TestCase { createEmptySandbox(); } + protected void tearDown() throws Exception { + super.tearDown(); + AjState.stateListener=null; + } + /** Drives a build */ public boolean build(String projectName,String configFile) { return AjdeManager.build(projectName,configFile); @@ -452,6 +458,10 @@ public class AjdeInteractionTestbed extends TestCase { File.pathSeparator + this.classPath + File.pathSeparator + System.getProperty("aspectjrt.path") + File.pathSeparator + "../lib/junit/junit.jar" + + "c:/batik/batik-1.6/lib/batik-util.jar;"+ + "c:/batik/batik-1.6/lib/batik-awt-util.jar;"+ + "c:/batik/batik-1.6/lib/batik-dom.jar;"+ + "c:/batik/batik-1.6/lib/batik-svggen.jar;"+ File.pathSeparator+".."+File.separator+"lib" + File.separator+"test"+File.separator+"aspectjrt.jar"; // look at dependant projects @@ -801,10 +811,11 @@ public class AjdeInteractionTestbed extends TestCase { public static boolean informedAboutKindOfBuild; public static boolean fullBuildOccurred; public static List detectedDeletions = new ArrayList(); - + public static StringBuffer decisions = new StringBuffer(); public static void reset() { informedAboutKindOfBuild=false; + decisions = new StringBuffer(); fullBuildOccurred=false; if (detectedDeletions!=null) detectedDeletions.clear(); } @@ -823,9 +834,19 @@ public class AjdeInteractionTestbed extends TestCase { fullBuildOccurred=wasFullBuild; } + public static String getDecisions() { + return decisions.toString(); + } + public static boolean wasFullBuild() { if (!informedAboutKindOfBuild) throw new RuntimeException("I never heard about what kind of build it was!!"); return fullBuildOccurred; } + + // not needed just yet... +// public void recordInformation(String s) { decisions.append(s).append("\n");} + public void recordDecision(String s) { + decisions.append(s).append("\n"); + } }; } \ 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 0260f1bcc..e4e88e377 100644 --- a/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java +++ b/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java @@ -822,6 +822,29 @@ public class MultiProjectIncrementalTests extends AjdeInteractionTestbed { checkXMLAspectCount("PR131505","pkg.A",1); } + public void testPr133532() { + initialiseProject("PR133532"); + build("PR133532"); + alter("PR133532","inc1"); + build("PR133532"); + alter("PR133532","inc2"); + build("PR133532"); + assertTrue("There should be no errors reported:\n"+MyTaskListManager.getErrorMessages(), + MyTaskListManager.getErrorMessages().isEmpty()); + } + + public void testPr133532_2() { + initialiseProject("pr133532_2"); + build("pr133532_2"); + alter("pr133532_2","inc2"); + build("pr133532_2"); + assertTrue("There should be no errors reported:\n"+MyTaskListManager.getErrorMessages(), + MyTaskListManager.getErrorMessages().isEmpty()); + String decisions = AjdeInteractionTestbed.MyStateListener.getDecisions(); + String expect="Need to recompile 'A.aj'"; + assertTrue("Couldn't find build decision: '"+expect+"' in the list of decisions made:\n"+decisions, + decisions.indexOf(expect)!=-1); + } // other possible tests: // - memory usage (freemem calls?) -- 2.39.5