db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r599897 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting: functionTests/tests/derbynet/ClientSideSystemPropertiesTest.java junit/BaseTestCase.java junit/DropDatabaseSetup.java
Date Fri, 30 Nov 2007 18:34:11 GMT
Author: djd
Date: Fri Nov 30 10:34:09 2007
New Revision: 599897

URL: http://svn.apache.org/viewvc?rev=599897&view=rev
Log:
Add utility methods to BaseTestCase to remove a directory.

Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/ClientSideSystemPropertiesTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/DropDatabaseSetup.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/ClientSideSystemPropertiesTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/ClientSideSystemPropertiesTest.java?rev=599897&r1=599896&r2=599897&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/ClientSideSystemPropertiesTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/ClientSideSystemPropertiesTest.java
Fri Nov 30 10:34:09 2007
@@ -89,33 +89,8 @@
     protected void tearDown() throws Exception
     {
         super.tearDown();
-        //Making ClientSideSystemPropertiesTest class implement 
-        //java.security.PrivilegedExceptionAction didn't work because compiler
-        //kept getting confused between the run method in
-        //java.security.PrivilegedExceptionAction and the run method in
-        //junit.framework.TestCase
-        //To get around this, I have created an inline class which implements
-        //java.security.PrivilegedAction and implements the run method 
-        //to delete the traceDirector and all the files under it.
-    	AccessController.doPrivileged
-	    (new java.security.PrivilegedAction(){
-		    public Object run(){
-		        File dir = new File(getSystemProperty("derby.client.traceDirectory"));
-	    		int fileCounter = 0;
-	            File[] list = dir.listFiles();
-	            File tempFile;
-	            //delete all the files under trace Directory
-	            for (;fileCounter<list.length; fileCounter++)
-	            {
-	            	tempFile = list[fileCounter];
-	            	tempFile.delete();
-	            }
-	            //now delete the trace Directory
-				dir.delete();
-	            return null;
-		    }
-		}	 
-	    );
+        
+        removeDirectory(getSystemProperty("derby.client.traceDirectory"));
     }
     
     /* ------------------- end helper methods  -------------------------- */

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java?rev=599897&r1=599896&r2=599897&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java Fri Nov
30 10:34:09 2007
@@ -394,4 +394,21 @@
         	}
         });
 	}
+    
+    /**
+     * Remove the directory and its contents.
+     * @param path Path of the directory
+     */
+    public static void removeDirectory(String path)
+    {
+        DropDatabaseSetup.removeDirectory(path);
+    }
+    /**
+     * Remove the directory and its contents.
+     * @param fir File of the directory
+     */
+    public static void removeDirectory(File dir)
+    {
+        DropDatabaseSetup.removeDirectory(dir);
+    }
 } // End class BaseTestCase

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/DropDatabaseSetup.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/DropDatabaseSetup.java?rev=599897&r1=599896&r2=599897&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/DropDatabaseSetup.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/DropDatabaseSetup.java
Fri Nov 30 10:34:09 2007
@@ -98,6 +98,10 @@
     static void removeDirectory(String path)
     {
         final File dir = new File(path);
+        removeDirectory(dir);
+    }
+    
+    static void removeDirectory(final File dir) {
         AccessController.doPrivileged(new java.security.PrivilegedAction() {
 
             public Object run() {



Mime
View raw message