From 3070c95f8c61802fda781c8eb21b333ee5fc2c19 Mon Sep 17 00:00:00 2001 From: Andy Clement Date: Thu, 31 Jan 2019 12:00:55 -0800 Subject: [PATCH] various polish to previously mavenized projects to support newer ones --- .../compiler/batch/CommandTestCase.java | 2 +- .../core/builder/AjBuildManagerTest.java | 3 +- .../test/java/org/aspectj/tools/ajc/Ajc.java | 62 ++++--------------- .../org/aspectj/tools/ajc/AjcTestCase.java | 19 +++--- 4 files changed, 25 insertions(+), 61 deletions(-) diff --git a/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/compiler/batch/CommandTestCase.java b/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/compiler/batch/CommandTestCase.java index 8331eb3f4..bcc4ad172 100644 --- a/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/compiler/batch/CommandTestCase.java +++ b/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/compiler/batch/CommandTestCase.java @@ -190,7 +190,7 @@ public abstract class CommandTestCase extends TestCase { protected void setUp() throws Exception { super.setUp(); - sandbox = Ajc.createEmptySandbox(); + sandbox = TestUtil.createEmptySandbox(); } } diff --git a/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/core/builder/AjBuildManagerTest.java b/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/core/builder/AjBuildManagerTest.java index d8d1621de..a60c9d9f7 100644 --- a/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/core/builder/AjBuildManagerTest.java +++ b/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/core/builder/AjBuildManagerTest.java @@ -22,6 +22,7 @@ import org.aspectj.ajdt.ajc.Constants; 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; @@ -61,7 +62,7 @@ public class AjBuildManagerTest extends TestCase { 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", diff --git a/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/Ajc.java b/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/Ajc.java index f43875541..facab0e7e 100644 --- a/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/Ajc.java +++ b/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/Ajc.java @@ -35,6 +35,7 @@ import org.aspectj.bridge.IMessageHandler; 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; /** @@ -49,13 +50,19 @@ 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") @@ -210,7 +217,7 @@ public class Ajc { try { if (!isIncremental && shouldEmptySandbox) { - sandbox = createEmptySandbox(); + sandbox = TestUtil.createEmptySandbox(); } args = adjustToSandbox(args, !isIncremental); MessageHandler holder = new MessageHandler(); @@ -291,7 +298,7 @@ public class Ajc { */ public File getSandboxDirectory() { if (sandbox == null) { - sandbox = createEmptySandbox(); + sandbox = TestUtil.createEmptySandbox(); } return sandbox; } @@ -319,53 +326,6 @@ public class Ajc { 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 */ diff --git a/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjcTestCase.java b/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjcTestCase.java index 24214cf17..9ca39ab9d 100644 --- a/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjcTestCase.java +++ b/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjcTestCase.java @@ -64,14 +64,17 @@ public class AjcTestCase extends TestCase { 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 -- 2.39.5