summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ajdoc/testsrc/org/aspectj/tools/ajdoc/AjdocTestCase.java6
-rw-r--r--org.aspectj.ajdt.core/testsrc/org/aspectj/tools/ajc/Ajc.java51
-rw-r--r--tests/src/org/aspectj/systemtest/incremental/tools/AjdeInteractionTestbed.java4
-rw-r--r--util/src/org/aspectj/util/FileUtil.java83
-rw-r--r--util/testsrc/org/aspectj/util/FileUtilTest.java5
5 files changed, 58 insertions, 91 deletions
diff --git a/ajdoc/testsrc/org/aspectj/tools/ajdoc/AjdocTestCase.java b/ajdoc/testsrc/org/aspectj/tools/ajdoc/AjdocTestCase.java
index 521604645..27979b925 100644
--- a/ajdoc/testsrc/org/aspectj/tools/ajdoc/AjdocTestCase.java
+++ b/ajdoc/testsrc/org/aspectj/tools/ajdoc/AjdocTestCase.java
@@ -13,11 +13,11 @@ package org.aspectj.tools.ajdoc;
import java.io.File;
import java.io.IOException;
-import org.aspectj.util.FileUtil;
-
import junit.framework.AssertionFailedError;
import junit.framework.TestCase;
+import org.aspectj.tools.ajc.Ajc;
+
/**
* This class is the super class of all Ajdoc tests. It creates
* a sandbox directory and provides utility methods for
@@ -35,7 +35,7 @@ public class AjdocTestCase extends TestCase{
docOutdir = null;
projectDir = null;
// Create a sandbox in which to work
- sandboxDir = FileUtil.createEmptySandbox();
+ sandboxDir = Ajc.createEmptySandbox();
// create the ajdocworkdingdir in the sandbox
Main.setOutputWorkingDir(getWorkingDir().getAbsolutePath());
}
diff --git a/org.aspectj.ajdt.core/testsrc/org/aspectj/tools/ajc/Ajc.java b/org.aspectj.ajdt.core/testsrc/org/aspectj/tools/ajc/Ajc.java
index aa2e70861..6114bef57 100644
--- a/org.aspectj.ajdt.core/testsrc/org/aspectj/tools/ajc/Ajc.java
+++ b/org.aspectj.ajdt.core/testsrc/org/aspectj/tools/ajc/Ajc.java
@@ -20,6 +20,8 @@ import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
+import junit.framework.AssertionFailedError;
+
import org.aspectj.bridge.AbortException;
import org.aspectj.bridge.ICommand;
@@ -44,6 +46,8 @@ import org.aspectj.util.FileUtil;
*/
public class Ajc {
+ private static final String SANDBOX_NAME = "ajcSandbox";
+
private static final String TESTER_PATH =
".."+File.separator+"testing-client"+File.separator+"bin"
+ File.pathSeparator+".."+File.separator+"runtime" +File.separator+"bin"
@@ -180,7 +184,7 @@ public class Ajc {
try {
if (!isIncremental && shouldEmptySandbox) {
- sandbox = FileUtil.createEmptySandbox();
+ sandbox = createEmptySandbox();
}
args = adjustToSandbox(args,!isIncremental);
MessageHandler holder = new MessageHandler();
@@ -253,7 +257,7 @@ public class Ajc {
* Get the sandbox directory used for the compilation.
*/
public File getSandboxDirectory() {
- if (sandbox == null) {sandbox = FileUtil.createEmptySandbox();}
+ if (sandbox == null) {sandbox = createEmptySandbox();}
return sandbox;
}
@@ -278,7 +282,50 @@ 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("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/tests/src/org/aspectj/systemtest/incremental/tools/AjdeInteractionTestbed.java b/tests/src/org/aspectj/systemtest/incremental/tools/AjdeInteractionTestbed.java
index 673763fe2..4d0cb5ac7 100644
--- a/tests/src/org/aspectj/systemtest/incremental/tools/AjdeInteractionTestbed.java
+++ b/tests/src/org/aspectj/systemtest/incremental/tools/AjdeInteractionTestbed.java
@@ -35,7 +35,7 @@ import org.aspectj.asm.AsmManager;
import org.aspectj.bridge.IMessage;
import org.aspectj.bridge.ISourceLocation;
import org.aspectj.bridge.IMessage.Kind;
-import org.aspectj.util.FileUtil;
+import org.aspectj.tools.ajc.Ajc;
/**
* This class uses Ajde in the same way that an IDE (e.g. AJDT) does.
@@ -94,7 +94,7 @@ public class AjdeInteractionTestbed extends TestCase {
MyProjectPropertiesAdapter.reset();
// Create a sandbox in which to work
- sandboxDir = FileUtil.createEmptySandbox();
+ sandboxDir = Ajc.createEmptySandbox();
}
protected void tearDown() throws Exception {
diff --git a/util/src/org/aspectj/util/FileUtil.java b/util/src/org/aspectj/util/FileUtil.java
index 3e5b9ee4c..d7892f6eb 100644
--- a/util/src/org/aspectj/util/FileUtil.java
+++ b/util/src/org/aspectj/util/FileUtil.java
@@ -13,40 +13,10 @@
package org.aspectj.util;
-import java.io.BufferedOutputStream;
-import java.io.BufferedReader;
-import java.io.ByteArrayOutputStream;
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import java.io.File;
-import java.io.FileFilter;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.FileReader;
-import java.io.FileWriter;
-import java.io.FilenameFilter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.io.PrintStream;
-import java.io.Reader;
-import java.io.StringReader;
-import java.io.Writer;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipFile;
-import java.util.zip.ZipInputStream;
-
-import junit.framework.AssertionFailedError;
+import java.io.*;
+import java.net.*;
+import java.util.*;
+import java.util.zip.*;
/**
@@ -1356,8 +1326,6 @@ public class FileUtil {
}
}
- private static final String SANDBOX_NAME = "ajcSandbox";
-
private FileUtil() { throw new Error("utility class"); }
public static List makeClasspath(URL[] urls) {
@@ -1541,47 +1509,4 @@ public class FileUtil {
}
}
- 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("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();
- }
-
- 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;
- }
-
}
diff --git a/util/testsrc/org/aspectj/util/FileUtilTest.java b/util/testsrc/org/aspectj/util/FileUtilTest.java
index 1879abef7..23ac0e31f 100644
--- a/util/testsrc/org/aspectj/util/FileUtilTest.java
+++ b/util/testsrc/org/aspectj/util/FileUtilTest.java
@@ -706,10 +706,5 @@ public class FileUtilTest extends TestCase {
assertTrue("written: " + pipe.totalWritten(), false);
}
}
-
- public void testCreateEmptySandbox () {
- File sandbox = FileUtil.createEmptySandbox();
- assertTrue("Sandbox does not exist",sandbox.exists());
- }
}