You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by an...@apache.org on 2011/09/17 18:57:50 UTC
svn commit: r1172018 - in /incubator/jena/Experimental/TxTDB/trunk/src:
main/java/com/hp/hpl/jena/tdb/sys/SystemTDB.java
test/java/com/hp/hpl/jena/tdb/store/TestDatasetTDBPersist.java
Author: andy
Date: Sat Sep 17 16:57:49 2011
New Revision: 1172018
URL: http://svn.apache.org/viewvc?rev=1172018&view=rev
Log:
Detect windows; make tests not reuse directories if on windows.
Modified:
incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/sys/SystemTDB.java
incubator/jena/Experimental/TxTDB/trunk/src/test/java/com/hp/hpl/jena/tdb/store/TestDatasetTDBPersist.java
Modified: incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/sys/SystemTDB.java
URL: http://svn.apache.org/viewvc/incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/sys/SystemTDB.java?rev=1172018&r1=1172017&r2=1172018&view=diff
==============================================================================
--- incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/sys/SystemTDB.java (original)
+++ incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/sys/SystemTDB.java Sat Sep 17 16:57:49 2011
@@ -272,8 +272,20 @@ public class SystemTDB
// --------
- // Tie to location but that means one instance per graph
+ public static final boolean isWindows = determineIfWindows() ; // Memory mapped files behave differently.
+
+ //Or look in File.listRoots.
+ //Alternative method:
+ // http://stackoverflow.com/questions/1293533/name-of-the-operating-system-in-java-not-os-name
+
+ private static boolean determineIfWindows() {
+ String s = System.getProperty("os.name") ;
+ if ( s == null )
+ return false ;
+ return s.startsWith("Windows ") ;
+ }
+
public static final boolean is64bitSystem = determineIf64Bit() ;
private static boolean determineIf64Bit()
@@ -298,7 +310,8 @@ public class SystemTDB
return b ;
}
- // Not in use yet.
+
+ // Not in use yet.
private static void determineJVMSize()
{
Runtime runtime = Runtime.getRuntime() ;
Modified: incubator/jena/Experimental/TxTDB/trunk/src/test/java/com/hp/hpl/jena/tdb/store/TestDatasetTDBPersist.java
URL: http://svn.apache.org/viewvc/incubator/jena/Experimental/TxTDB/trunk/src/test/java/com/hp/hpl/jena/tdb/store/TestDatasetTDBPersist.java?rev=1172018&r1=1172017&r2=1172018&view=diff
==============================================================================
--- incubator/jena/Experimental/TxTDB/trunk/src/test/java/com/hp/hpl/jena/tdb/store/TestDatasetTDBPersist.java (original)
+++ incubator/jena/Experimental/TxTDB/trunk/src/test/java/com/hp/hpl/jena/tdb/store/TestDatasetTDBPersist.java Sat Sep 17 16:57:49 2011
@@ -18,6 +18,7 @@ import org.junit.BeforeClass ;
import org.junit.Test ;
import org.openjena.atlas.iterator.Iter ;
import org.openjena.atlas.junit.BaseTest ;
+import org.openjena.atlas.lib.FileOps;
import com.hp.hpl.jena.graph.Graph ;
import com.hp.hpl.jena.graph.Node ;
@@ -28,6 +29,7 @@ import com.hp.hpl.jena.sparql.util.NodeF
import com.hp.hpl.jena.tdb.ConfigTest ;
import com.hp.hpl.jena.tdb.base.file.Location ;
import com.hp.hpl.jena.tdb.junit.GraphLocation ;
+import com.hp.hpl.jena.tdb.sys.SystemTDB;
import com.hp.hpl.jena.tdb.sys.TDBMaker ;
/** Testing persistence */
@@ -36,31 +38,42 @@ public class TestDatasetTDBPersist exten
static Node n0 = NodeFactory.parseNode("<http://example/n0>") ;
static Node n1 = NodeFactory.parseNode("<http://example/n1>") ;
static Node n2 = NodeFactory.parseNode("<http://example/n2>") ;
-
+ static boolean nonDeleteableMMapFiles = SystemTDB.isWindows ;
+ static String dirBaseName = ConfigTest.getTestingDirDB() ;
static GraphLocation graphLocation = null ;
@BeforeClass public static void beforeClass()
{
- graphLocation = new GraphLocation(new Location(ConfigTest.getTestingDirDB())) ;
+ if ( ! nonDeleteableMMapFiles )
+ graphLocation = new GraphLocation(new Location(ConfigTest.getTestingDirDB())) ;
}
@AfterClass public static void afterClass()
- {
- graphLocation.release() ;
- graphLocation.clearDirectory() ;
+ {
+ if ( graphLocation != null )
+ {
+ graphLocation.release() ;
+ graphLocation.clearDirectory() ;
+ }
}
+ // To avoid the problems on MS Windows whereby memeory mapped files
+ // can't be deleted from a running JVM, we use a different, cleaned
+ // directory each time.
+ static int count = 0 ;
+ String dirName = null ;
+
@Before public void before()
{
- // Windows/memory mapped does not allow deleting memory mapped files.
- if ( false )
- {
- if ( graphLocation.getDataset() == null )
- graphLocation.createDataset() ;
- else
- graphLocation.getDataset().asDatasetGraph().deleteAny(null, null, null, null) ;
- }
- else
+ if ( nonDeleteableMMapFiles )
+ {
+ dirName = dirBaseName+"-"+(++count) ;
+ FileOps.ensureDir(dirName) ;
+ FileOps.clearDirectory(dirName) ;
+ graphLocation = new GraphLocation(new Location(dirName)) ;
+ graphLocation.createDataset() ;
+ }
+ else
{
graphLocation.clearDirectory() ;
graphLocation.createDataset() ;
@@ -68,9 +81,13 @@ public class TestDatasetTDBPersist exten
}
@After public void after()
- {
- graphLocation.release() ;
- TDBMaker.clearDatasetCache() ;
+ {
+ TDBMaker.clearDatasetCache() ;
+ if ( graphLocation != null )
+ graphLocation.release() ;
+
+// if ( nonDeleteableMMapFiles )
+// FileOps.clearDirectory(dirName) ;
}
@Test public void dataset1()