directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r1164371 - in /directory/apacheds/trunk/jdbm: src/test/java/jdbm/btree/SnapshotBTree.java src/test/java/jdbm/btree/StreamCorrupted.java src/test/java/jdbm/btree/TestBTreeBrowser.java test.db
Date Fri, 02 Sep 2011 07:08:19 GMT
Author: seelmann
Date: Fri Sep  2 07:08:19 2011
New Revision: 1164371

URL: http://svn.apache.org/viewvc?rev=1164371&view=rev
Log:
Use JUnit temporary folder rule to get rid of *.db files

Modified:
    directory/apacheds/trunk/jdbm/src/test/java/jdbm/btree/SnapshotBTree.java
    directory/apacheds/trunk/jdbm/src/test/java/jdbm/btree/StreamCorrupted.java
    directory/apacheds/trunk/jdbm/src/test/java/jdbm/btree/TestBTreeBrowser.java
    directory/apacheds/trunk/jdbm/test.db

Modified: directory/apacheds/trunk/jdbm/src/test/java/jdbm/btree/SnapshotBTree.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm/src/test/java/jdbm/btree/SnapshotBTree.java?rev=1164371&r1=1164370&r2=1164371&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm/src/test/java/jdbm/btree/SnapshotBTree.java (original)
+++ directory/apacheds/trunk/jdbm/src/test/java/jdbm/btree/SnapshotBTree.java Fri Sep  2 07:08:19
2011
@@ -33,6 +33,7 @@ import jdbm.helper.Tuple;
 import jdbm.helper.TupleBrowser;
 import jdbm.recman.SnapshotRecordManager;
 
+import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.TemporaryFolder;
 import org.junit.runner.RunWith;
@@ -50,6 +51,7 @@ import com.mycila.junit.concurrent.Concu
 @Concurrency()
 public class SnapshotBTree
 {
+    @Rule
     public TemporaryFolder folder = new TemporaryFolder();
     
     private static class IntWrapper implements Serializable

Modified: directory/apacheds/trunk/jdbm/src/test/java/jdbm/btree/StreamCorrupted.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm/src/test/java/jdbm/btree/StreamCorrupted.java?rev=1164371&r1=1164370&r2=1164371&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm/src/test/java/jdbm/btree/StreamCorrupted.java (original)
+++ directory/apacheds/trunk/jdbm/src/test/java/jdbm/btree/StreamCorrupted.java Fri Sep  2
07:08:19 2011
@@ -46,14 +46,15 @@
 package jdbm.btree;
 
 
-import java.io.File;
 import java.io.IOException;
 
 import jdbm.RecordManager;
 import jdbm.RecordManagerFactory;
 import jdbm.helper.StringComparator;
 
+import org.junit.Rule;
 import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
 
 /**
  * Contributed test case for BTree by Christof Dallermassl (cdaller@iicm.edu):
@@ -90,36 +91,14 @@ import org.junit.Test;
  */
 public class StreamCorrupted
 {
-    public final static String testFileName = "test";
+    @Rule
+    public TemporaryFolder folder = new TemporaryFolder();
 
-    public static void deleteFile( String filename )
-    {
-        File file = new File( filename );
-
-        if ( file.exists() ) {
-            try 
-            {
-                file.delete();
-            } 
-            catch ( Exception except ) 
-            {
-                except.printStackTrace();
-            }
-            
-            if ( file.exists() ) 
-            {
-                System.out.println( "WARNING:  Cannot delete file: " + file );
-            }
-        }
-    }
 
-    
-    public static void deleteTestFile()
+    private String getTemporaryFile( String name ) throws IOException
     {
-        System.gc();
-        deleteFile( testFileName);
-        deleteFile( testFileName + ".db" );
-        deleteFile( testFileName + ".lg" );
+        String file = folder.newFile( name ).getAbsolutePath();
+        return file;
     }
 
 
@@ -136,7 +115,7 @@ public class StreamCorrupted
         iterations = 100; // 23 works :-(((((
 
         // open database
-        recman = RecordManagerFactory.createRecordManager( testFileName );
+        recman = RecordManagerFactory.createRecordManager( getTemporaryFile( "test" ) );
 
         // create a new B+Tree data structure
         btree = new BTree<String, Integer>( recman, new StringComparator() );

Modified: directory/apacheds/trunk/jdbm/src/test/java/jdbm/btree/TestBTreeBrowser.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm/src/test/java/jdbm/btree/TestBTreeBrowser.java?rev=1164371&r1=1164370&r2=1164371&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm/src/test/java/jdbm/btree/TestBTreeBrowser.java (original)
+++ directory/apacheds/trunk/jdbm/src/test/java/jdbm/btree/TestBTreeBrowser.java Fri Sep 
2 07:08:19 2011
@@ -72,7 +72,7 @@ public class TestBTreeBrowser
     public void setup() throws IOException
     {
         tuple = new Tuple<String, String>();
-        recordManager = RecordManagerFactory.createRecordManager( getTemporaryFile( "testInsertMany"
) );
+        recordManager = RecordManagerFactory.createRecordManager( getTemporaryFile( "testBrowser"
) );
         snapshotRecman = new SnapshotRecordManager( recordManager, 1 << 12 );
         tree = new BTree<String, String>( snapshotRecman, new StringComparator() );
         tree.setPageSize( 4 );



Mime
View raw message