]> source.dussan.org Git - aspectj.git/commitdiff
Fix build: move createEmptySandbox() from FileUtil back to Ajc to avoid JUnit depende...
authormwebster <mwebster>
Thu, 15 Jun 2006 12:58:38 +0000 (12:58 +0000)
committermwebster <mwebster>
Thu, 15 Jun 2006 12:58:38 +0000 (12:58 +0000)
ajdoc/testsrc/org/aspectj/tools/ajdoc/AjdocTestCase.java
org.aspectj.ajdt.core/testsrc/org/aspectj/tools/ajc/Ajc.java
tests/src/org/aspectj/systemtest/incremental/tools/AjdeInteractionTestbed.java
util/src/org/aspectj/util/FileUtil.java
util/testsrc/org/aspectj/util/FileUtilTest.java

index 5216046450ba5cc8746563073f079aef7e84078f..27979b925a44cf34098ebb482c277fe4551b3185 100644 (file)
@@ -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());
        }
index aa2e70861b08bac3d7605018aa0e930612ac5286..6114bef57fa1c8bfd6d95625ae1c4eb0d08642b6 100644 (file)
@@ -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
index 673763fe2a61ef45fce5011ec6792022783aa449..4d0cb5ac708d54b315a8b56ffb8d38f68da7b641 100644 (file)
@@ -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 {
index 3e5b9ee4cddb47f376b2054790cf845257f5ddc9..d7892f6eba194a9ac5d2c87718ba4dd37a4dbd1b 100644 (file)
 
 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;
-       }
-
 }
index 1879abef728bb7a705e8b5a39f99a38f2b87a8d7..23ac0e31f435078b13932360230a4c978e28ed0c 100644 (file)
@@ -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());
-    }
 
 }