diff options
author | Andy Clement <aclement@pivotal.io> | 2019-01-31 12:01:34 -0800 |
---|---|---|
committer | Andy Clement <aclement@pivotal.io> | 2019-01-31 12:01:34 -0800 |
commit | 762b9c287285fd447dfeb17eda6ab65e0143b39e (patch) | |
tree | fc504857ad5d55771217431f027146c795c67378 /testing-util/src/main | |
parent | 8fb9480558a7490563dc1acb7c4507f697ed92c0 (diff) | |
download | aspectj-762b9c287285fd447dfeb17eda6ab65e0143b39e.tar.gz aspectj-762b9c287285fd447dfeb17eda6ab65e0143b39e.zip |
various polish to previously mavenized projects to support newer ones
Diffstat (limited to 'testing-util/src/main')
-rw-r--r-- | testing-util/src/main/java/org/aspectj/testing/util/TestUtil.java | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/testing-util/src/main/java/org/aspectj/testing/util/TestUtil.java b/testing-util/src/main/java/org/aspectj/testing/util/TestUtil.java index 1dbc0115c..a152d8cc9 100644 --- a/testing-util/src/main/java/org/aspectj/testing/util/TestUtil.java +++ b/testing-util/src/main/java/org/aspectj/testing/util/TestUtil.java @@ -45,6 +45,7 @@ import jdiff.text.FileLine; import jdiff.util.Diff; import jdiff.util.DiffNormalOutput; import junit.framework.Assert; +import junit.framework.AssertionFailedError; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestResult; @@ -62,6 +63,7 @@ import org.aspectj.util.Reflection; * not required to resolve this class. Also, the bytecode weaver is required to compare class files, but not to compare other files. */ public final class TestUtil { + private static final String SANDBOX_NAME = "ajcSandbox"; private static final boolean JAVA_5_VM; private static final String ASPECTJRT_KEY = "aspectjrt"; private static final String TESTING_CLIENT_KEY = "testing-client"; @@ -203,6 +205,10 @@ public final class TestUtil { return path.toString(); } + public static String aspectjrtClasspath() { + return TestUtil.aspectjrtPath().getPath(); + } + /** * @param input the String to parse for [on|off|true|false] * @throws IllegalArgumentException if input is bad @@ -896,6 +902,54 @@ public final class TestUtil { } } } + + + 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; + } /** * Capture PrintStream output to String[] (delimiting component String on println()), also showing any missed text. |