harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From odea...@apache.org
Subject svn commit: r810008 - /harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileTest.java
Date Tue, 01 Sep 2009 12:42:06 GMT
Author: odeakin
Date: Tue Sep  1 12:42:05 2009
New Revision: 810008

URL: http://svn.apache.org/viewvc?rev=810008&view=rev
Log:
Improve test cleanup a little so this test only cleans up the resources it created itself,
and does not fall over on zOS because of the missing trailing slash on the temp dir path.

Modified:
    harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileTest.java

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileTest.java?rev=810008&r1=810007&r2=810008&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileTest.java
Tue Sep  1 12:42:05 2009
@@ -45,31 +45,17 @@
     
     private static void deleteTempFolder(File dir) {
         String files[] = dir.list();
-        for (int i = 0; i < files.length; i++) {
-            File f = new File(dir, files[i]);
-            if (f.isDirectory()) {
-                deleteTempFolder(f);
-            } else {
-                f.delete();
-            }
-        }
-        dir.delete();
-    }
-    
-    private static void cleanupTempFiles() {
-        // Delete all old temporary files
-        File tempDir = new File(System.getProperty("java.io.tmpdir"));
-        File[] files = tempDir.listFiles();
         if (files != null) {
-            for (File file : files) {
-                if (file.getName().startsWith("harmony-test")) {
-                    if (file.isDirectory()) {
-                        deleteTempFolder(file);
-                    }
-                    file.delete();
+            for (int i = 0; i < files.length; i++) {
+                File f = new File(dir, files[i]);
+                if (f.isDirectory()) {
+                    deleteTempFolder(f);
+                } else {
+                    f.delete();
                 }
             }
         }
+        dir.delete();
     }
     
     private static String addTrailingSlash(String path) {
@@ -91,8 +77,10 @@
     }
 
     protected void tearDown() {
-        tempDirectory = null;
-        cleanupTempFiles();
+        if (tempDirectory != null) {
+            deleteTempFolder(tempDirectory);
+            tempDirectory = null;
+        }
     }
 
     /**



Mime
View raw message