import org.aspectj.bridge.IMessage;
import org.aspectj.bridge.MessageHandler;
import org.aspectj.bridge.MessageWriter;
+import org.aspectj.testing.util.TestUtil;
import org.aspectj.tools.ajc.Ajc;
import junit.framework.AssertionFailedError;
BuildArgParser parser = new BuildArgParser(messageWriter);
String javaClassPath = System.getProperty("java.class.path");
System.out.println(javaClassPath);
- String sandboxName = Ajc.createEmptySandbox().getAbsolutePath();
+ String sandboxName = TestUtil.createEmptySandbox().getAbsolutePath();
AjBuildConfig buildConfig = parser.genBuildConfig(new String[] { "-d", sandboxName, "-1.4", "-classpath", javaClassPath,
Constants.TESTDATA_PATH + "/src1/A.java",
// EajcModuleTests.TESTDATA_PATH + "/src1/Hello.java",
import org.aspectj.bridge.MessageHandler;
import org.aspectj.bridge.IMessage.Kind;
import org.aspectj.bridge.context.CompilationAndWeavingContext;
+import org.aspectj.testing.util.TestUtil;
import org.aspectj.util.FileUtil;
/**
*/
public class Ajc {
- private static final String SANDBOX_NAME = "ajcSandbox";
-
private static final String BUILD_OUTPUT_FOLDER = "target";
public static final String outputFolder(String module) {
return File.pathSeparator + ".." +File.separator + module + File.separator + "target" + File.separator + "classes";
}
+
+ public static final String outputFolders(String... modules) {
+ StringBuilder s = new StringBuilder();
+ for (String module: modules) {
+ s.append(File.pathSeparator + ".." +File.separator + module + File.separator + "target" + File.separator + "classes");
+ }
+ return s.toString();
+ }
// ALSO SEE ANTSPEC AND AJCTESTCASE
private static final String TESTER_PATH = outputFolder("testing-client") + outputFolder("runtime") + outputFolder("bcel-builder")
try {
if (!isIncremental && shouldEmptySandbox) {
- sandbox = createEmptySandbox();
+ sandbox = TestUtil.createEmptySandbox();
}
args = adjustToSandbox(args, !isIncremental);
MessageHandler holder = new MessageHandler();
*/
public File getSandboxDirectory() {
if (sandbox == null) {
- sandbox = createEmptySandbox();
+ sandbox = TestUtil.createEmptySandbox();
}
return sandbox;
}
return false;
}
- public static File createEmptySandbox() {
- File sandbox;
-
- String os = System.getProperty("os.name");
- File tempDir = null;
- // AMC - I did this rather than use the JDK default as I hate having to go look
- // in c:\documents and settings\......... for the results of a failed test.
- if (os.startsWith("Windows")) {
- tempDir = new File("N:\\temp");
- if (!tempDir.exists()) {
- tempDir = new File("C:\\temp");
- if (!tempDir.exists()) {
- tempDir.mkdir();
- }
- }
- } else {
- tempDir = new File("/tmp");
- }
- File sandboxRoot = new File(tempDir, SANDBOX_NAME);
- if (!sandboxRoot.exists()) {
- sandboxRoot.mkdir();
- }
-
- try {
- File workspace = new File(".." + File.separator);
- String workspaceName = workspace.getCanonicalPath();
- int index = workspaceName.lastIndexOf(File.separator);
- workspaceName = workspaceName.substring(index + 1);
-
- File workspaceRoot = new File(sandboxRoot, workspaceName);
- if (!workspaceRoot.exists()) {
- workspaceRoot.mkdir();
- }
-
- FileUtil.deleteContents(workspaceRoot);
-
- sandbox = File.createTempFile("ajcTest", ".tmp", workspaceRoot);
- sandbox.delete();
- sandbox.mkdir();
-
- } catch (IOException ioEx) {
- throw new AssertionFailedError("Unable to create sandbox directory for test");
- }
-
- return sandbox;
- }
-
/**
* Make every relative file name and dir be absolute under sandbox Add TESTER_PATH to classpath
*/
protected Ajc ajc;
// see Ajc and AntSpec
- public static final String DEFAULT_CLASSPATH_ENTRIES = File.pathSeparator + ".." + File.separator + "bridge" + File.separator
- + "bin" + File.pathSeparator + ".." + File.separator + "util" + File.separator + "bin" + File.pathSeparator + ".."
- + File.separator + "loadtime" + File.separator + "bin" + File.pathSeparator + ".." + File.separator + "weaver"
- + File.separator + "bin" + File.pathSeparator + ".." + File.separator + "weaver5" + File.separator + "bin"
- + File.pathSeparator + ".." + File.separator + "asm" + File.separator + "bin" + File.pathSeparator + ".."
- + File.separator + "testing-client" + File.separator + "bin" + File.pathSeparator + ".." + File.separator + "runtime"
- + File.separator + "bin" + File.pathSeparator + ".." + File.separator + "aspectj5rt" + File.separator + "bin"
- + File.pathSeparator + ".." + File.separator + "org.aspectj.matcher" + File.separator + "bin" + File.pathSeparator
+ public static final String DEFAULT_CLASSPATH_ENTRIES =
+ Ajc.outputFolders("bridge","util","loadtime","weaver","asm","testing-client","runtime","org.aspectj.matcher")
+// File.pathSeparator + ".." + File.separator + "bridge" + File.separator
+// + "bin" + File.pathSeparator + ".." + File.separator + "util" + File.separator + "bin" + File.pathSeparator + ".."
+// + File.separator + "loadtime" + File.separator + "bin" + File.pathSeparator + ".." + File.separator + "weaver"
+// + File.separator + "bin" + File.pathSeparator + ".." + File.separator + "weaver5" + File.separator + "bin"
+// + File.pathSeparator + ".." + File.separator + "asm" + File.separator + "bin" + File.pathSeparator + ".."
+// + File.separator + "testing-client" + File.separator + "bin" + File.pathSeparator + ".." + File.separator + "runtime"
+// + File.separator + "bin" + File.pathSeparator + ".." + File.separator + "aspectj5rt" + File.separator + "bin"
+// + File.pathSeparator + ".." + File.separator + "org.aspectj.matcher" + File.separator + "bin"
+ + File.pathSeparator
+ ".." + File.separator + "lib" + File.separator + "junit" + File.separator
+ "junit.jar"
+ File.pathSeparator