List args = new ArrayList();
args.add("-d");
- args.add("out");
+ args.add(getSandboxName());
args.add("-classpath");
args.add(getRuntimeClasspath() + File.pathSeparator +\r "../lib/junit/junit.jar;../testing-client/bin");
List args = new ArrayList();
args.add("-d");
- args.add("out");
+ args.add(getSandboxName());
args.add("-classpath");
args.add(getRuntimeClasspath() + File.pathSeparator +\r "../lib/junit/junit.jar;../testing-client/bin;not_found_anywhere.jar");
List args = new ArrayList();
args.add("-d");
- args.add("out");
+ args.add(getSandboxName());
args.add("-classpath");
args.add("../lib/junit/junit.jar;../testing-client/bin");
}
public void testSizeChanges() {
- File f1 = new File("out/SizeIssues.class");
+ File f1 = new File(getSandboxName(),"SizeIssues.class");
List args = new ArrayList();
args.add("-d");
- args.add("out");
+ args.add(getSandboxName());
args.add("-classpath");
args.add(getRuntimeClasspath() + File.pathSeparator +
public void testJar1() throws IOException {
+ String library = getSandboxName() + "/lib.jar";
+
List args = new ArrayList();
args.add("-outjar");
- args.add("out/lib.jar");
+ args.add(library);
args.add("-classpath");
args.add(AjcTests.aspectjrtClasspath());
args.add("-d");
- args.add("out");
+ args.add(getSandboxName());
args.add("-XnotReweavable");
args.add(AjdtAjcTests.TESTDATA_PATH + "/src1/binary/lib/ConcreteA.aj");
args = new ArrayList();
args.add("-aspectpath");
- args.add("out/lib.jar");
+ args.add(library);
args.add("-classpath");
args.add(AjcTests.aspectjrtClasspath());
args.add("-d");
- args.add("out");
+ args.add(getSandboxName());
args.add("-XnotReweavable");
args.add(AjdtAjcTests.TESTDATA_PATH + "/src1/binary/client/Client.java");
CommandTestCase.runCompiler(args, CommandTestCase.NO_ERRORS);
- TestUtil.runMain("out" + File.pathSeparator + "out/lib.jar", "client.Client");
- TestUtil.runMain("out" + File.pathSeparator + "out/lib.jar", "client.Client1");
+ TestUtil.runMain(getSandboxName() + File.pathSeparator + library, "client.Client");
+ TestUtil.runMain(getSandboxName() + File.pathSeparator + library, "client.Client1");
args = new ArrayList();
args.add("-aspectpath");
- args.add("out/lib.jar");
+ args.add(library);
args.add("-classpath");
args.add(AjcTests.aspectjrtClasspath());
args.add("-XnotReweavable");
args.add("-d");
- args.add("out");
+ args.add(getSandboxName());
args.add(AjdtAjcTests.TESTDATA_PATH + "/src1/binary/client/MyAspect.aj");
args.add(AjdtAjcTests.TESTDATA_PATH + "/src1/binary/client/Client1.java");
CommandTestCase.runCompiler(args, CommandTestCase.NO_ERRORS);
- TestUtil.runMain("out" + File.pathSeparator + "out/lib.jar", "client.Client1");
+ TestUtil.runMain(getSandboxName() + File.pathSeparator + library, "client.Client1");
args = new ArrayList();
args.add("-aspectpath");
- args.add("out/lib.jar");
+ args.add(library);
args.add("-classpath");
args.add(AjcTests.aspectjrtClasspath());
args.add("-d");
- args.add("out");
+ args.add(getSandboxName());
args.add("-XnotReweavable");
args.add(AjdtAjcTests.TESTDATA_PATH + "/src1/binary/client/MyAspect1.aj");
args = new ArrayList();
args.add("-classpath");
- args.add("out/lib.jar" + File.pathSeparator + AjcTests.aspectjrtClasspath());
+ args.add(library + File.pathSeparator + AjcTests.aspectjrtClasspath());
args.add("-d");
- args.add("out");
+ args.add(getSandboxName());
args.add("-XnotReweavable");
args.add(AjdtAjcTests.TESTDATA_PATH + "/src1/binary/client/Client1.java");
args = new ArrayList();
args.add("-classpath");
- args.add(AjcTests.aspectjrtClasspath() + File.pathSeparator + "out/lib.jar");
+ args.add(AjcTests.aspectjrtClasspath() + File.pathSeparator + library);
args.add("-Xlint:error");
args.add("-d");
- args.add("out");
+ args.add(getSandboxName());
args.add(AjdtAjcTests.TESTDATA_PATH + "/src1/binary/client/MyAspect.aj");
args.add(AjdtAjcTests.TESTDATA_PATH + "/src1/binary/client/Client1.java");
package org.aspectj.ajdt.internal.compiler.batch;
-import org.aspectj.ajdt.ajc.*;
-import org.aspectj.ajdt.ajc.AjdtCommand;
-import org.aspectj.bridge.ICommand;
-import org.aspectj.bridge.IMessage;
-import org.aspectj.bridge.IMessageHandler;
-import org.aspectj.bridge.IMessageHolder;
-import org.aspectj.bridge.MessageHandler;
-import org.aspectj.tools.ajc.AjcTests;
-import org.aspectj.weaver.bcel.LazyClassGen;
-
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import junit.framework.TestCase;
+import org.aspectj.ajdt.ajc.AjdtAjcTests;
+import org.aspectj.ajdt.ajc.AjdtCommand;
+import org.aspectj.bridge.ICommand;
+import org.aspectj.bridge.IMessage;
+import org.aspectj.bridge.IMessageHandler;
+import org.aspectj.bridge.IMessageHolder;
+import org.aspectj.bridge.MessageHandler;
+import org.aspectj.testing.util.TestUtil;
+import org.aspectj.tools.ajc.Ajc;
+import org.aspectj.tools.ajc.AjcTests;
+import org.aspectj.weaver.bcel.LazyClassGen;
+
public abstract class CommandTestCase extends TestCase {
/**
public static final int[] NO_ERRORS = new int[0];
public static final int[] TOP_ERROR = new int[0];
+ private File sandbox;
- public static void checkCompile(String source, int[] expectedErrors) {
- checkCompile(source, new String[0], expectedErrors);
+ public void checkCompile(String source, int[] expectedErrors) {
+ checkCompile(source, new String[0], expectedErrors, getSandboxName());
}
- public static void checkCompile(String source, String[] extraArgs, int[] expectedErrors) {
+ protected void runMain(String className) {
+ TestUtil.runMain(getSandboxName(), className);
+ }
+
+ public static void checkCompile(String source, String[] extraArgs, int[] expectedErrors, String sandboxName) {
List args = new ArrayList();
args.add("-verbose");
args.add("-d");
- args.add("out");
+ args.add(sandboxName);
args.add("-classpath");
args.add("-verbose");
args.add("-d");
- args.add("out");
+ args.add(getSandboxName());
args.add("-classpath");
args.add(getRuntimeClasspath());
return AjcTests.aspectjrtClasspath();
}
+ protected String getSandboxName () {
+ return sandbox.getAbsolutePath();
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ sandbox = Ajc.createEmptySandbox();
+ }
+
}
import java.io.IOException;
-import org.aspectj.testing.util.TestUtil;
-
public class CompileAndRunTestCase extends CommandTestCase {
public void testAround() throws IOException {
checkCompile("src1/AroundA.java", NO_ERRORS);
- TestUtil.runMain("out", "AroundAMain");
+ runMain("AroundAMain");
}
public void testInterType() throws IOException {
checkCompile("src1/InterType.java", NO_ERRORS);
- TestUtil.runMain("out", "InterType");
+ runMain("InterType");
}
public void testInterTypeMethods() throws IOException {
checkCompile("src1/InterTypeMethods.java", NO_ERRORS);
- TestUtil.runMain("out", "InterTypeMethods");
+ runMain("InterTypeMethods");
}
public void testIf() throws IOException {
- CommandTestCase.checkCompile("src1/IfPcd.java", CommandTestCase.NO_ERRORS);
- TestUtil.runMain("out", "IfPcd");
+ checkCompile("src1/IfPcd.java", CommandTestCase.NO_ERRORS);
+ runMain("IfPcd");
}
public void testDeclareParentsFail() throws IOException {
- CommandTestCase.checkCompile("src1/ParentsFail.java", new int[] {3, 11, 19});
+ checkCompile("src1/ParentsFail.java", new int[] {3, 11, 19});
}
public void testDeclareParents() throws IOException {
- CommandTestCase.checkCompile("src1/Parents.java", CommandTestCase.NO_ERRORS);
- TestUtil.runMain("out", "Parents");
+ checkCompile("src1/Parents.java", CommandTestCase.NO_ERRORS);
+ runMain("Parents");
}
public void testPerCflow() throws IOException {
- CommandTestCase.checkCompile("src1/PerCflow.java", CommandTestCase.NO_ERRORS);
- TestUtil.runMain("out", "PerCflow");
+ checkCompile("src1/PerCflow.java", CommandTestCase.NO_ERRORS);
+ runMain("PerCflow");
}
public void testPerObject() throws IOException {
- CommandTestCase.checkCompile("src1/PerObject.java", CommandTestCase.NO_ERRORS);
- TestUtil.runMain("out", "PerObject");
+ checkCompile("src1/PerObject.java", CommandTestCase.NO_ERRORS);
+ runMain("PerObject");
}
public void testDeclareSoft() throws IOException {
- CommandTestCase.checkCompile("src1/DeclareSoft.java", CommandTestCase.NO_ERRORS);
- TestUtil.runMain("out", "DeclareSoft");
+ checkCompile("src1/DeclareSoft.java", CommandTestCase.NO_ERRORS);
+ runMain("DeclareSoft");
}
public void testPrivileged() throws IOException {
- CommandTestCase.checkCompile("src1/Privileged.java", CommandTestCase.NO_ERRORS);
- TestUtil.runMain("out", "Privileged");
+ checkCompile("src1/Privileged.java", CommandTestCase.NO_ERRORS);
+ runMain("Privileged");
}
public void testHandler() throws IOException {
- CommandTestCase.checkCompile("src1/Handler.java", CommandTestCase.NO_ERRORS);
- TestUtil.runMain("out", "Handler");
+ checkCompile("src1/Handler.java", CommandTestCase.NO_ERRORS);
+ runMain("Handler");
}
public void testInterConstructors() throws IOException {
- CommandTestCase.checkCompile("src1/InterTypeConstructors.java", CommandTestCase.NO_ERRORS);
- TestUtil.runMain("out", "InterTypeConstructors");
+ checkCompile("src1/InterTypeConstructors.java", CommandTestCase.NO_ERRORS);
+ runMain("InterTypeConstructors");
}
public void testAroundA1() throws IOException {
- CommandTestCase.checkCompile("src1/AroundA1.java", CommandTestCase.NO_ERRORS);
- TestUtil.runMain("out", "AroundA1");
+ checkCompile("src1/AroundA1.java", CommandTestCase.NO_ERRORS);
+ runMain("AroundA1");
}
}
import java.io.IOException;
-import org.aspectj.testing.util.TestUtil;
-
public class PerformanceTestCase extends CommandTestCase {
public void xxx_testLazyTjpOff() throws IOException {
checkCompile("src1/LazyTjp.aj", NO_ERRORS);
try {
- TestUtil.runMain("out", "LazyTjp");
+ runMain("LazyTjp");
fail("expected an exception when running without -XlazyTjp");
} catch (IllegalStateException e) {
// expected exception thrown when no -XlazyTjp
// joinpoint method-execution(int LazyTjp.doit3(int)) because around advice is used [Xlint:canNotImplementLazyTjp]'
// into an error so that we can use checkCompiles() ability to check errors occur.
// Pass -proceedOnError to ensure even though we get that message, we still get the class file on disk
- checkCompile("src1/LazyTjp.aj", new String[] {"-Xlint:error","-proceedOnError"}, new int[] {96});
- TestUtil.runMain("out", "LazyTjp");
+ String sandboxName = getSandboxName();
+ checkCompile("src1/LazyTjp.aj", new String[] {"-Xlint:error","-proceedOnError"}, new int[] {96}, sandboxName);
+ runMain("LazyTjp");
}
}
*/
public void testNoProceedOnError() throws IOException {
checkCompile("src1/C1.java", NO_ERRORS);
- File f =new File("out"+File.separator+"C.class");
+ File f =new File(getSandboxName(),"C.class");
long oldmodtime = f.lastModified();
pause(2);
checkCompile("src1/C2.java", new int[]{1});
- f =new File("out"+File.separator+"C.class");
+ f =new File(getSandboxName(),"C.class");
long newmodtime = f.lastModified();
// Without -proceedOnError supplied, we should *not* change the time stamp on the .class file
assertTrue("The .class file should not have been modified as '-proceedOnError' was not supplied (old="+
public void testProceedOnError() throws IOException {
checkCompile("src1/C1.java", NO_ERRORS);
- File f =new File("out"+File.separator+"C.class");
+ File f =new File(getSandboxName(),"C.class");
long oldmodtime = f.lastModified();
pause(2);
- checkCompile("src1/C2.java",new String[]{"-proceedOnError"}, new int[]{1});
- f =new File("out"+File.separator+"C.class");
+ String sandboxName = getSandboxName();
+ checkCompile("src1/C2.java",new String[]{"-proceedOnError"}, new int[]{1}, sandboxName);
+ f =new File(sandboxName,"C.class");
long newmodtime = f.lastModified();
// Without -proceedOnError supplied, we should *not* change the time stamp on the .class file
assertTrue("The .class file should have been modified as '-proceedOnError' *was* supplied (old="+
import junit.framework.TestCase;
import org.aspectj.ajdt.ajc.*;
-import org.aspectj.ajdt.ajc.BuildArgParser;
import org.aspectj.asm.AsmManager;
import org.aspectj.bridge.IMessage;
import org.aspectj.bridge.MessageHandler;
import org.aspectj.bridge.MessageWriter;
+import org.aspectj.tools.ajc.Ajc;
import org.aspectj.util.StreamPrintWriter;
//import org.eclipse.core.runtime.CoreException;
AjBuildManager manager = new AjBuildManager(messageWriter);
BuildArgParser parser = new BuildArgParser(messageWriter);
String javaClassPath = System.getProperty("java.class.path");
+ String sandboxName = Ajc.createEmptySandbox().getAbsolutePath();
AjBuildConfig buildConfig =
parser.genBuildConfig(new String[] {
- "-d", "out",
+ "-d", sandboxName,
"-classpath",
javaClassPath,
AjdtAjcTests.TESTDATA_PATH