You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2015/08/21 21:17:42 UTC

svn commit: r1697045 - /commons/proper/bcel/trunk/src/test/java/org/apache/commons/bcel6/AbstractTestCase.java

Author: sebb
Date: Fri Aug 21 19:17:42 2015
New Revision: 1697045

URL: http://svn.apache.org/r1697045
Log:
Directory was not being deleted because the wrong name was used - target instead of target/testdata

Modified:
    commons/proper/bcel/trunk/src/test/java/org/apache/commons/bcel6/AbstractTestCase.java

Modified: commons/proper/bcel/trunk/src/test/java/org/apache/commons/bcel6/AbstractTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/test/java/org/apache/commons/bcel6/AbstractTestCase.java?rev=1697045&r1=1697044&r2=1697045&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/test/java/org/apache/commons/bcel6/AbstractTestCase.java (original)
+++ commons/proper/bcel/trunk/src/test/java/org/apache/commons/bcel6/AbstractTestCase.java Fri Aug 21 19:17:42 2015
@@ -43,13 +43,19 @@ public abstract class AbstractTestCase e
 
     protected static final String PACKAGE_BASE_NAME = AbstractTestCase.class.getPackage().getName();
 
+    // Location of test data
+    protected static final File TESTDATA = new File("target", "testdata");
+
     // package base name in signature format, i.e. with '/' separators instead of '.'
     protected static final String PACKAGE_BASE_SIG = PACKAGE_BASE_NAME.replace('.', '/');
 
+    /**
+     * @param name
+     * @return Path to file under the TESTDATA directory
+     */
     protected File createTestdataFile(String name)
     {
-        return new File("target" + File.separator + "testdata" + File.separator
-                + name);
+        return new File(TESTDATA, name);
     }
 
     protected JavaClass getTestClass(String name) throws ClassNotFoundException
@@ -69,19 +75,35 @@ public abstract class AbstractTestCase e
         return null;
     }
 
+    /**
+     * Delete a file under the TESTDATA directory
+     * @param name
+     * @return
+     */
     protected boolean wipe(String name)
     {
-        return new File("target" + File.separator + "testdata" + File.separator
-                + name).delete();
+        return new File(TESTDATA, name).delete();
     }
 
+    /**
+     * Delete a directory and file under the TESTDATA directory
+     * @param dir
+     * @param name
+     * @return true if the file was deleted
+     */
     protected boolean wipe(String dir, String name)
     {
+        // The parameter is relative to the TESTDATA dir
         boolean b = wipe(dir + File.separator + name);
-        String[] files = new File(dir).list();
+        final File testDir = new File(TESTDATA, dir);
+        String[] files = testDir.list();
         if (files == null || files.length == 0)
         {
-            new File(dir).delete(); // Why does this not succeed? stupid thing
+            if (!testDir.delete()){
+                System.err.println("Failed to remove: " + testDir);
+            }
+        } else {
+            System.err.println("Non-empty directory: " + testDir);
         }
         return b;
     }