summaryrefslogtreecommitdiffstats
path: root/ajde
diff options
context:
space:
mode:
Diffstat (limited to 'ajde')
-rw-r--r--ajde/testdata/ReweavableTest/CalculatePI.java26
-rw-r--r--ajde/testdata/ReweavableTest/Logger.aj11
-rw-r--r--ajde/testdata/ReweavableTest/NonReweavable1.lst4
-rw-r--r--ajde/testdata/ReweavableTest/Reweavable1.lst5
-rw-r--r--ajde/testdata/ReweavableTest/Reweavable2.lst4
-rw-r--r--ajde/testdata/ReweavableTest/ReweavableCompress1.lst5
-rw-r--r--ajde/testdata/ReweavableTest/Second.lst3
-rw-r--r--ajde/testdata/ReweavableTest/SecondAspect.aj5
-rw-r--r--ajde/testdata/ReweavableTest/TJP1.lst5
-rw-r--r--ajde/testdata/ReweavableTest/TJP2.lst3
-rw-r--r--ajde/testdata/ReweavableTest/ThirdAspect.aj5
-rw-r--r--ajde/testdata/ReweavableTest/tjp/Demo.java38
-rw-r--r--ajde/testdata/ReweavableTest/tjp/GetInfo.java50
-rw-r--r--ajde/testsrc/org/aspectj/ajde/AjdeTests.java1
-rw-r--r--ajde/testsrc/org/aspectj/ajde/ReweavableTestCase.java426
15 files changed, 591 insertions, 0 deletions
diff --git a/ajde/testdata/ReweavableTest/CalculatePI.java b/ajde/testdata/ReweavableTest/CalculatePI.java
new file mode 100644
index 000000000..84ae08583
--- /dev/null
+++ b/ajde/testdata/ReweavableTest/CalculatePI.java
@@ -0,0 +1,26 @@
+import java.util.Random;
+
+public class CalculatePI {
+
+ static Random r = new Random();
+ static double piApproximation = 1.0f;
+ static int repetitions = 500000;
+ static int iteration = 0;
+ static double inSquare = 0;
+ static double inCircle = 0;
+
+ public static void main(String[] args) {
+ for (iteration = 0;iteration<repetitions;iteration++) approximate();
+ piApproximation = (inCircle/inSquare)*4.0f;
+ System.out.println("After "+repetitions+" iterations, pi is estimated to be "+piApproximation);
+ }
+
+ public static void approximate() {
+ double x = r.nextDouble();
+ double y = r.nextDouble();
+ inSquare++;
+ if (x*x + y*y < 1) {inCircle++;}
+ }
+
+
+} \ No newline at end of file
diff --git a/ajde/testdata/ReweavableTest/Logger.aj b/ajde/testdata/ReweavableTest/Logger.aj
new file mode 100644
index 000000000..b41c8842f
--- /dev/null
+++ b/ajde/testdata/ReweavableTest/Logger.aj
@@ -0,0 +1,11 @@
+
+
+public aspect Logger {
+
+ after(): call(* approximate(..)) {
+ if (CalculatePI.iteration%10000==0)
+ System.out.println("Approximation is now:"+
+ (CalculatePI.inCircle/CalculatePI.inSquare)*4.0f);
+ }
+
+} \ No newline at end of file
diff --git a/ajde/testdata/ReweavableTest/NonReweavable1.lst b/ajde/testdata/ReweavableTest/NonReweavable1.lst
new file mode 100644
index 000000000..c40df5e4c
--- /dev/null
+++ b/ajde/testdata/ReweavableTest/NonReweavable1.lst
@@ -0,0 +1,4 @@
+CalculatePI.java
+Logger.aj
+-verbose
+-noExit \ No newline at end of file
diff --git a/ajde/testdata/ReweavableTest/Reweavable1.lst b/ajde/testdata/ReweavableTest/Reweavable1.lst
new file mode 100644
index 000000000..43c6b246f
--- /dev/null
+++ b/ajde/testdata/ReweavableTest/Reweavable1.lst
@@ -0,0 +1,5 @@
+CalculatePI.java
+Logger.aj
+-Xreweavable
+-verbose
+-noExit \ No newline at end of file
diff --git a/ajde/testdata/ReweavableTest/Reweavable2.lst b/ajde/testdata/ReweavableTest/Reweavable2.lst
new file mode 100644
index 000000000..6f0b9d728
--- /dev/null
+++ b/ajde/testdata/ReweavableTest/Reweavable2.lst
@@ -0,0 +1,4 @@
+SecondAspect.aj
+-Xreweavable
+-verbose
+-noExit \ No newline at end of file
diff --git a/ajde/testdata/ReweavableTest/ReweavableCompress1.lst b/ajde/testdata/ReweavableTest/ReweavableCompress1.lst
new file mode 100644
index 000000000..af8fc60eb
--- /dev/null
+++ b/ajde/testdata/ReweavableTest/ReweavableCompress1.lst
@@ -0,0 +1,5 @@
+CalculatePI.java
+Logger.aj
+-Xreweavable:compress
+-verbose
+-noExit \ No newline at end of file
diff --git a/ajde/testdata/ReweavableTest/Second.lst b/ajde/testdata/ReweavableTest/Second.lst
new file mode 100644
index 000000000..9a3344121
--- /dev/null
+++ b/ajde/testdata/ReweavableTest/Second.lst
@@ -0,0 +1,3 @@
+Logger.aj
+-Xreweavable
+-verbose \ No newline at end of file
diff --git a/ajde/testdata/ReweavableTest/SecondAspect.aj b/ajde/testdata/ReweavableTest/SecondAspect.aj
new file mode 100644
index 000000000..413f4969e
--- /dev/null
+++ b/ajde/testdata/ReweavableTest/SecondAspect.aj
@@ -0,0 +1,5 @@
+
+public aspect SecondAspect {
+
+ declare parents: Logger implements java.io.Serializable;
+} \ No newline at end of file
diff --git a/ajde/testdata/ReweavableTest/TJP1.lst b/ajde/testdata/ReweavableTest/TJP1.lst
new file mode 100644
index 000000000..f686a5e88
--- /dev/null
+++ b/ajde/testdata/ReweavableTest/TJP1.lst
@@ -0,0 +1,5 @@
+tjp/Demo.java
+tjp/GetInfo.java
+-Xreweavable
+-verbose
+-noExit \ No newline at end of file
diff --git a/ajde/testdata/ReweavableTest/TJP2.lst b/ajde/testdata/ReweavableTest/TJP2.lst
new file mode 100644
index 000000000..27e22167e
--- /dev/null
+++ b/ajde/testdata/ReweavableTest/TJP2.lst
@@ -0,0 +1,3 @@
+-Xreweavable
+-verbose
+-noExit \ No newline at end of file
diff --git a/ajde/testdata/ReweavableTest/ThirdAspect.aj b/ajde/testdata/ReweavableTest/ThirdAspect.aj
new file mode 100644
index 000000000..c6c6b1a43
--- /dev/null
+++ b/ajde/testdata/ReweavableTest/ThirdAspect.aj
@@ -0,0 +1,5 @@
+
+public aspect ThirdAspect {
+
+ int CalculatePI.x;
+} \ No newline at end of file
diff --git a/ajde/testdata/ReweavableTest/tjp/Demo.java b/ajde/testdata/ReweavableTest/tjp/Demo.java
new file mode 100644
index 000000000..c4a4f057c
--- /dev/null
+++ b/ajde/testdata/ReweavableTest/tjp/Demo.java
@@ -0,0 +1,38 @@
+
+/*
+
+Copyright (c) Xerox Corporation 1998-2002. All rights reserved.
+
+Use and copying of this software and preparation of derivative works based
+upon this software are permitted. Any distribution of this software or
+derivative works must comply with all applicable United States export control
+laws.
+
+This software is made available AS IS, and Xerox Corporation makes no warranty
+about the software, its performance or its conformity to any specification.
+
+*/
+package tjp;
+
+public class Demo {
+ static Demo d;
+
+ public static void main(String[] args){
+ new Demo().go();
+ }
+
+ void go(){
+ d = new Demo();
+ d.foo(1,d);
+ System.out.println(d.bar(new Integer(3)));
+ }
+
+ void foo(int i, Object o){
+ System.out.println("Demo.foo(" + i + ", " + o + ")\n");
+ }
+
+ String bar (Integer j){
+ System.out.println("Demo.bar(" + j + ")\n");
+ return "Demo.bar(" + j + ")";
+ }
+}
diff --git a/ajde/testdata/ReweavableTest/tjp/GetInfo.java b/ajde/testdata/ReweavableTest/tjp/GetInfo.java
new file mode 100644
index 000000000..458acb56f
--- /dev/null
+++ b/ajde/testdata/ReweavableTest/tjp/GetInfo.java
@@ -0,0 +1,50 @@
+
+/*
+Copyright (c) Xerox Corporation 1998-2002. All rights reserved.
+
+Use and copying of this software and preparation of derivative works based
+upon this software are permitted. Any distribution of this software or
+derivative works must comply with all applicable United States export control
+laws.
+
+This software is made available AS IS, and Xerox Corporation makes no warranty
+about the software, its performance or its conformity to any specification.
+*/
+
+package tjp;
+
+import org.aspectj.lang.JoinPoint;
+import org.aspectj.lang.reflect.CodeSignature;
+
+aspect GetInfo {
+
+ static final void println(String s){ System.out.println(s); }
+
+ pointcut goCut(): cflow(this(Demo) && execution(void go()));
+
+ pointcut demoExecs(): within(Demo) && execution(* *(..));
+
+ Object around(): demoExecs() && !execution(* go()) && goCut() {
+ println("Intercepted message: " +
+ thisJoinPointStaticPart.getSignature().getName());
+ println("in class: " +
+ thisJoinPointStaticPart.getSignature().getDeclaringType().getName());
+ printParameters(thisJoinPoint);
+ println("Running original method: \n" );
+ Object result = proceed();
+ println(" result: " + result );
+ return result;
+ }
+
+ static private void printParameters(JoinPoint jp) {
+ println("Arguments: " );
+ Object[] args = jp.getArgs();
+ String[] names = ((CodeSignature)jp.getSignature()).getParameterNames();
+ Class[] types = ((CodeSignature)jp.getSignature()).getParameterTypes();
+ for (int i = 0; i < args.length; i++) {
+ println(" " + i + ". " + names[i] +
+ " : " + types[i].getName() +
+ " = " + args[i]);
+ }
+ }
+}
diff --git a/ajde/testsrc/org/aspectj/ajde/AjdeTests.java b/ajde/testsrc/org/aspectj/ajde/AjdeTests.java
index 22905ca8f..06ead0b2c 100644
--- a/ajde/testsrc/org/aspectj/ajde/AjdeTests.java
+++ b/ajde/testsrc/org/aspectj/ajde/AjdeTests.java
@@ -31,6 +31,7 @@ public class AjdeTests extends TestCase {
suite.addTestSuite(AsmDeclarationsTest.class);
suite.addTestSuite(AsmRelationshipsTest.class);
suite.addTestSuite(InpathTestcase.class);
+ suite.addTestSuite(ReweavableTestCase.class);
suite.addTestSuite(ResourceCopyTestCase.class);
suite.addTestSuite(ModelPerformanceTest.class);
suite.addTestSuite(SavedModelConsistencyTest. class);
diff --git a/ajde/testsrc/org/aspectj/ajde/ReweavableTestCase.java b/ajde/testsrc/org/aspectj/ajde/ReweavableTestCase.java
new file mode 100644
index 000000000..4f9608d55
--- /dev/null
+++ b/ajde/testsrc/org/aspectj/ajde/ReweavableTestCase.java
@@ -0,0 +1,426 @@
+/* *******************************************************************
+ * Copyright (c) 2004 Contributors.
+ * 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/cpl-v10.html
+ *
+ * Contributors:
+ * Andy Clement Initial version
+ * ******************************************************************/
+
+package org.aspectj.ajde;
+
+import java.io.File;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.aspectj.ajde.internal.CompilerAdapter;
+import org.aspectj.ajde.ui.UserPreferencesAdapter;
+import org.aspectj.ajde.ui.internal.AjcBuildOptions;
+import org.aspectj.ajdt.internal.core.builder.AjBuildConfig;
+import org.aspectj.bridge.MessageHandler;
+import org.aspectj.util.FileUtil;
+
+public class ReweavableTestCase extends AjdeTestCase {
+
+ private MessageHandler messageHandler;
+ private NullIdeProperties projectProperties;
+ private AjcBuildOptions buildOptions;
+ private UserPreferencesAdapter preferencesAdapter = null;
+ private CompilerAdapter compilerAdapter;
+ private static final String configFile =
+ AjdeTests.TESTDATA_PATH + "/examples/figures-coverage/all.lst";
+ public static final String PROJECT_DIR = "ReweavableTest";
+
+ private AjBuildConfig buildConfig = null;
+ public static final String binDir = "bin";
+
+ public static final String indir1Name = "indir1";
+ public static final String indir2Name = "indir2";
+ public static final String injarName = "injar.jar";
+ public static final String outjarName = "/bin/output.jar";
+
+
+ public static int nonreweavesize_CalculatePI;
+ public static int nonreweavesize_Logger;
+ public static int reweavablesize_CalculatePI;
+ public static int reweavablesize_Logger;
+
+ /**
+ * Constructor for JarResourceCopyTestCase.
+ * @param arg0
+ */
+ public ReweavableTestCase(String arg0) {
+ super(arg0);
+ }
+
+
+
+ /*
+ * Ensure the output directpry in clean
+ */
+ protected void setUp() throws Exception {
+ super.setUp(PROJECT_DIR);
+ FileUtil.deleteContents(openFile(binDir));
+ }
+
+
+ /**
+ * Aim: Check we haven't damaged 'normal compilation' when not supplying -Xreweavable. Also determines
+ * baseline sizes for the compiled class files for later comparison.
+ *
+ * Inputs to the compiler:
+ * NonReweavable1.lst
+ * -> CalculatePI.java
+ * -> Logger.aj
+ * -> -verbose
+ * -> -noExit
+ *
+ * Expected result = Compile successful, the types will not be reweavable and the weaver
+ * should not report it is running in reweavable mode.
+ */
+ public void testNonReweavableCompile() {
+ System.out.println("testNonReweavableCompile: Building with NonReweavable1.lst");
+ compilerAdapter = new CompilerAdapter();
+ compilerAdapter.showInfoMessages(true);
+ compilerAdapter.compile((String) openFile("NonReweavable1.lst").getAbsolutePath(),new BPM(),false);
+
+ assertFalse("Did not expect to find a message about the weaver operating in reweavable mode",
+ checkFor("weaver operating in reweavable mode"));
+
+ File fCalc = openFile("bin/CalculatePI.class");
+ File fLog = openFile("bin/Logger.class");
+ assertTrue("bin/CalculatePI.class should exist?!?",fCalc.exists());
+ assertTrue("bin/Logger.class should exist?!?",fLog.exists());
+ System.out.println("CalculatePI.class is of size: "+fCalc.length());
+ System.out.println("Logger.class is of size: "+fLog.length());
+ System.out.println("\n\n\n");
+ nonreweavesize_CalculatePI = (int)fCalc.length();
+ nonreweavesize_Logger = (int)fLog.length();
+ }
+
+
+ /**
+ * Aim: Basic call to -Xreweavable. Weaver should report it is in reweavable mode and the
+ * classes produced should be much larger than normal classes (those produced in the first
+ * test).
+ *
+ * Inputs to the compiler:
+ * Reweavable1.lst
+ * -> CalculatePI.java
+ * -> Logger.aj
+ * -> -Xreweavable
+ * -> -verbose
+ * -> -noExit
+ *
+ * Expected result = Compile successful, the types will be reweavable and the weaver
+ * should report it is running in reweavable mode. The files produced
+ * should be larger than those created during the last test.
+ */
+ public void testReweavableCompile() {
+ System.out.println("testReweavableCompile: Building with Reweavable1.lst");
+ compilerAdapter = new CompilerAdapter();
+ compilerAdapter.showInfoMessages(true);
+ compilerAdapter.compile((String) openFile("Reweavable1.lst").getAbsolutePath(),new BPM(),false);
+
+ assertTrue("Expected a message about operating in reweavable mode, but didn't get one",
+ checkFor("weaver operating in reweavable mode"));
+
+ File fCalc = openFile("bin/CalculatePI.class");
+ File fLog = openFile("bin/Logger.class");
+ assertTrue("bin/CalculatePI.class should exist?!?",fCalc.exists());
+ assertTrue("bin/Logger.class should exist?!?",fLog.exists());
+ System.out.println("CalculatePI.class is of size: "+fCalc.length());
+ System.out.println("Logger.class is of size: "+fLog.length());
+ assertTrue("Reweavable version should be larger than non-reweavable version of CalculatePI",
+ fCalc.length()>nonreweavesize_CalculatePI);
+ assertTrue("Reweavable version should be larger than non-reweavable version of Logger",
+ fLog.length()>nonreweavesize_Logger);
+
+ reweavablesize_CalculatePI = (int)fCalc.length();
+ reweavablesize_Logger = (int)fLog.length();
+
+ System.out.println("\n\n\n");
+ }
+
+
+ /**
+ * Aim: Use the optional ':compress' modifier on -Xreweavable. This causes some of the meta-data
+ * for use in reweaving to be compressed. It should succeed and produce class files smaller
+ * than straight -Xreweavable but larger than without specifying -Xreweavable.
+ *
+ * Inputs to the compiler:
+ * ReweavableCompress1.lst
+ * -> CalculatePI.java
+ * -> Logger.aj
+ * -> -Xreweavable:compress
+ * -> -verbose
+ * -> -noExit
+ *
+ * Expected result = Compile successful, the types will be reweavable and the weaver
+ * should report it is running in reweavable mode. The files created should
+ * have a size between the non-reweavable versions and the reweavable (without
+ * compression) versions.
+ */
+ public void testReweavableCompressCompile() {
+ System.out.println("testReweavableCompressCompile: Building with ReweavableCompress1.lst");
+ compilerAdapter = new CompilerAdapter();
+ compilerAdapter.showInfoMessages(true);
+ compilerAdapter.compile((String) openFile("ReweavableCompress1.lst").getAbsolutePath(),new BPM(),false);
+
+ assertTrue("Expected a message about operating in reweavable mode, but didn't get one",
+ checkFor("weaver operating in reweavable mode"));
+
+ File fCalc = openFile("bin/CalculatePI.class");
+ File fLog = openFile("bin/Logger.class");
+ assertTrue("bin/CalculatePI.class should exist?!?",fCalc.exists());
+ assertTrue("bin/Logger.class should exist?!?",fLog.exists());
+ System.out.println("CalculatePI.class is of size: "+fCalc.length());
+ System.out.println("Logger.class is of size: "+fLog.length());
+ assertTrue("Reweavable version should be larger than non-reweavable version of CalculatePI",
+ fCalc.length()>nonreweavesize_CalculatePI);
+ assertTrue("Reweavable version should be larger than non-reweavable version of Logger",
+ fLog.length()>nonreweavesize_Logger);
+
+ assertTrue("Reweavable (with compression) version should be smaller than reweavable (without compression) version of CalculatePI",
+ fCalc.length()<reweavablesize_CalculatePI);
+ assertTrue("Reweavable (with compression) version should be smaller than reweavable (without compression) version of Logger",
+ fLog.length()<reweavablesize_Logger);
+
+ System.out.println("\n\n\n");
+ }
+
+
+ /**
+ * Aim: The tests above have determined that reweaving appears to be behaving in terms of the .class
+ * files it is creating. Now lets actually attempt a reweave. For this, we build two files
+ * as reweavable and then build a single file whilst specifying an inpath that contains the
+ * .class files from the first compile. This should succeed.
+ *
+ * Inputs to the first compile:
+ * Reweavable1.lst
+ * -> CalculatePI.java
+ * -> Logger.aj
+ * -> -Xreweavable
+ * -> -verbose
+ * -> -noExit
+ *
+ * Input to the second compile:
+ * Reweavable2.lst
+ * -> SecondAspect.aj
+ * -> -Xreweavable
+ * -> -verbose
+ * -> -noExit
+ * -inpath bin\.
+ *
+ * Expected result = Both compiles will succeed.
+ */
+ public void testReweavableSimpleCompile() {
+ System.out.println("testReweavableSimpleCompile: Building with Reweavable1.lst");
+ compilerAdapter = new CompilerAdapter();
+ compilerAdapter.showInfoMessages(true);
+ compilerAdapter.compile((String) openFile("Reweavable1.lst").getAbsolutePath(),new BPM(),false);
+
+ assertTrue("Expected a message about operating in reweavable mode, but didn't get one",
+ checkFor("weaver operating in reweavable mode"));
+
+
+ System.out.println("\ntestReweavableSimpleCompile: Building with Reweavable2.lst");
+ Set paths = new HashSet();
+ paths.add(openFile(binDir));
+ ideManager.getProjectProperties().setInpath(paths);
+ compilerAdapter.compile((String) openFile("Reweavable2.lst").getAbsolutePath(),new BPM(),false);
+
+
+ String expMessage ="successfully verified type Logger exists";
+ assertTrue("Expected message '"+expMessage+"' but did not find it",
+ checkFor(expMessage));
+
+ File fCalc = openFile("bin/CalculatePI.class");
+ File fLog = openFile("bin/Logger.class");
+ File fSec = openFile("bin/SecondAspect.class");
+ assertTrue("bin/CalculatePI.class should exist?!?",fCalc.exists());
+ assertTrue("bin/Logger.class should exist?!?",fLog.exists());
+ assertTrue("bin/SecondAspect.class should exist?!?",fSec.exists());
+
+ System.out.println("\n\n\n");
+ }
+
+
+ /**
+ * Aim: Based on the test above, if we delete Logger.class between the first and second compiles
+ * the second compile should fail because there is not enough information to reweave CalculatePI
+ *
+ * Inputs to the first compile:
+ * Reweavable1.lst
+ * -> CalculatePI.java
+ * -> Logger.aj
+ * -> -Xreweavable
+ * -> -verbose
+ * -> -noExit
+ *
+ * Input to the second compile:
+ * Reweavable2.lst
+ * -> SecondAspect.aj
+ * -> -Xreweavable
+ * -> -verbose
+ * -> -noExit
+ * -inpath bin\.
+ *
+ * Expected result = Second compile will fail - reporting that Logger is missing (it 'touched' in the first compile CalculatePI)
+ */
+ public void testForReweavableSimpleErrorCompile() {
+ System.out.println("testForReweavableSimpleErrorCompile: Building with Reweavable2.lst");
+ compilerAdapter = new CompilerAdapter();
+ compilerAdapter.showInfoMessages(true);
+ compilerAdapter.compile((String) openFile("Reweavable1.lst").getAbsolutePath(),new BPM(),false);
+
+ assertTrue("Expected a message about operating in reweavable mode, but didn't get one",
+ checkFor("weaver operating in reweavable mode"));
+
+
+ assertTrue("Could not delete bin/Logger.class??",openFile("bin/Logger.class").delete());
+
+
+ System.out.println("\ntestForReweavableSimpleErrorCompile: Building with Reweavable2.lst");
+ Set paths = new HashSet();
+ paths.add(openFile(binDir));
+ ideManager.getProjectProperties().setInpath(paths);
+ compilerAdapter.compile((String) openFile("Reweavable2.lst").getAbsolutePath(),new BPM(),false);
+
+
+ String expMessage ="type Logger is needed by reweavable type CalculatePI";
+ assertTrue("Expected message '"+expMessage+"' but did not find it",
+ checkFor(expMessage));
+
+ File fCalc = openFile("bin/CalculatePI.class");
+ File fLog = openFile("bin/Logger.class");
+ File fSec = openFile("bin/SecondAspect.class");
+ assertTrue("bin/CalculatePI.class should exist!",fCalc.exists());
+ assertTrue("bin/Logger.class should not exist!",!fLog.exists());
+ assertTrue("bin/SecondAspect.class should not exist!",fSec.exists());
+
+ System.out.println("\n\n\n");
+ }
+
+
+ /**
+ * Aim: Based on the test above, if we delete Logger.class between the first and second compiles
+ * the second compile should fail because there is not enough information to reweave CalculatePI
+ *
+ * Inputs to the first compile:
+ * TJP1.lst
+ * -> tjp/Demo.java
+ * -> tjp/GetInfo.java
+ * -> -Xreweavable
+ * -> -verbose
+ * -> -noExit
+ *
+ * Now, delete bin\tjp\GetInfo.class and do a compile with:
+ * TJP2.lst
+ * -> -Xreweavable
+ * -> -verbose
+ * -> -noExit
+ * -inpath bin\.
+ *
+ * Expected result = Second compile will fail - reporting that tjp.GetInfo is missing (it 'touched' in the first compile tjp.Demo)
+ */
+ public void testErrorScenario2Compile() {
+ System.out.println("testErrorScenario2: Building with TJP1.lst");
+ compilerAdapter = new CompilerAdapter();
+ compilerAdapter.showInfoMessages(true);
+ compilerAdapter.compile((String) openFile("TJP1.lst").getAbsolutePath(),new BPM(),false);
+
+ assertTrue("Expected a message about operating in reweavable mode, but didn't get one",
+ checkFor("weaver operating in reweavable mode"));
+
+
+ assertTrue("Could not delete bin/tjp/GetInfo.class??",openFile("bin/tjp/GetInfo.class").delete());
+
+
+ System.out.println("\ntestErrorScenario2: Building with TJP2.lst");
+ Set paths = new HashSet();
+ paths.add(openFile(binDir));
+ ideManager.getProjectProperties().setInpath(paths);
+ compilerAdapter.compile((String) openFile("TJP2.lst").getAbsolutePath(),new BPM(),false);
+
+
+ String expMessage ="type tjp.GetInfo is needed by reweavable type tjp.Demo";
+ assertTrue("Expected message '"+expMessage+"' but did not find it",
+ checkFor(expMessage));
+
+ File fDemo = openFile("bin/tjp/Demo.class");
+ File fGetInfo = openFile("bin/tjp/GetInfo.class");
+ assertTrue("bin/tjp/Demo.class should exist!",fDemo.exists());
+ assertTrue("bin/tjp/GetInfo.class should not exist!",!fGetInfo.exists());
+
+ System.out.println("\n\n\n");
+ }
+
+ public void testWorkingScenario2Compile() {
+ System.out.println("testWorkingScenario2: Building with TJP1.lst");
+ compilerAdapter = new CompilerAdapter();
+ compilerAdapter.showInfoMessages(true);
+ compilerAdapter.compile((String) openFile("TJP1.lst").getAbsolutePath(),new BPM(),false);
+
+ assertTrue("Expected a message about operating in reweavable mode, but didn't get one",
+ checkFor("weaver operating in reweavable mode"));
+
+
+ System.out.println("\ntestWorkingScenario2: Building with TJP2.lst");
+ Set paths = new HashSet();
+ paths.add(openFile(binDir));
+ ideManager.getProjectProperties().setInpath(paths);
+ compilerAdapter.compile((String) openFile("TJP2.lst").getAbsolutePath(),new BPM(),false);
+
+
+ String expMessage ="successfully verified type tjp.GetInfo exists";
+ assertTrue("Expected message '"+expMessage+"' but did not find it",
+ checkFor(expMessage));
+
+ File fGetInfo = openFile("bin/tjp/GetInfo.class");
+ File fDemo = openFile("bin/tjp/Demo.class");
+ assertTrue("bin/tjp/GetInfo.class should exist!",fGetInfo.exists());
+ assertTrue("bin/tjp/Demo.class should not exist!",fDemo.exists());
+
+ System.out.println("\n\n\n");
+ }
+
+
+ private class BPM implements BuildProgressMonitor {
+ public void start(String configFile) {}
+
+ public void setProgressText(String text) {}
+
+ public void setProgressBarVal(int newVal) { }
+
+ public void incrementProgressBarVal() {}
+
+ public void setProgressBarMax(int maxVal) { }
+
+ public int getProgressBarMax() {
+ return 0;
+ }
+
+ public void finish() {}
+
+ }
+
+
+
+
+ private boolean checkFor(String what) {
+ List ll = ideManager.getCompilationSourceLineTasks();
+ for (Iterator iter = ll.iterator(); iter.hasNext();) {
+ Object element = (Object) iter.next();
+ if (element.toString().indexOf(what)!=-1) return true;
+ }
+ return false;
+ }
+
+
+}