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
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());
}
import java.util.List;
import java.util.StringTokenizer;
+import junit.framework.AssertionFailedError;
+
import org.aspectj.bridge.AbortException;
import org.aspectj.bridge.ICommand;
*/
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"
try {
if (!isIncremental && shouldEmptySandbox) {
- sandbox = FileUtil.createEmptySandbox();
+ sandbox = createEmptySandbox();
}
args = adjustToSandbox(args,!isIncremental);
MessageHandler holder = new MessageHandler();
* Get the sandbox directory used for the compilation.
*/
public File getSandboxDirectory() {
- if (sandbox == null) {sandbox = FileUtil.createEmptySandbox();}
+ if (sandbox == null) {sandbox = 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("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
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.
MyProjectPropertiesAdapter.reset();
// Create a sandbox in which to work
- sandboxDir = FileUtil.createEmptySandbox();
+ sandboxDir = Ajc.createEmptySandbox();
}
protected void tearDown() throws Exception {
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.*;
/**
}
}
- private static final String SANDBOX_NAME = "ajcSandbox";
-
private FileUtil() { throw new Error("utility class"); }
public static List makeClasspath(URL[] urls) {
}
}
- 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;
- }
-
}
assertTrue("written: " + pipe.totalWritten(), false);
}
}
-
- public void testCreateEmptySandbox () {
- File sandbox = FileUtil.createEmptySandbox();
- assertTrue("Sandbox does not exist",sandbox.exists());
- }
}