]> source.dussan.org Git - aspectj.git/commitdiff
tests for 133532 - also tidied up the statelistener code
authoraclement <aclement>
Tue, 4 Apr 2006 08:10:07 +0000 (08:10 +0000)
committeraclement <aclement>
Tue, 4 Apr 2006 08:10:07 +0000 (08:10 +0000)
tests/src/org/aspectj/systemtest/incremental/IncrementalTests.java
tests/src/org/aspectj/systemtest/incremental/tools/AjdeInteractionTestbed.java
tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java

index 3b7aefce3bdeceb228b56a63cf08e4dd7acbc446..09f8248bc87a0b6aa1a9b828c49a678b9f6d29ec 100644 (file)
@@ -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 {
index e8f0e4d08c8047bc406e715042a023f9189b6372..38be2dd601a84a4066b00fd76f65e6f83a658c7f 100644 (file)
@@ -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
index 0260f1bcc20e132659bffa232c98215f93a87030..e4e88e3770ea857f4bb053543602ed316f0119c0 100644 (file)
@@ -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?)