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 2017/10/27 19:42:13 UTC

[05/10] jena git commit: Isolate tests after observed problems on MSWindows.

Isolate tests after observed problems on MSWindows.

Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/fc2a7457
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/fc2a7457
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/fc2a7457

Branch: refs/heads/master
Commit: fc2a7457f5c22a7a271c605f92d6fa315f3a9d98
Parents: 057ed90
Author: Andy Seaborne <an...@apache.org>
Authored: Fri Oct 27 12:59:17 2017 +0100
Committer: Andy Seaborne <an...@apache.org>
Committed: Fri Oct 27 13:35:49 2017 +0100

----------------------------------------------------------------------
 .../dboe/base/file/TestProcessFileLock.java     | 30 +++++++++-----------
 1 file changed, 13 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/fc2a7457/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/TestProcessFileLock.java
----------------------------------------------------------------------
diff --git a/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/TestProcessFileLock.java b/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/TestProcessFileLock.java
index 9c72c71..0f9e24b 100644
--- a/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/TestProcessFileLock.java
+++ b/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/TestProcessFileLock.java
@@ -18,44 +18,40 @@
 
 package org.apache.jena.dboe.base.file;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotSame;
 import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
 
 import java.io.File;
 import java.io.IOException;
 
-import org.apache.jena.atlas.lib.FileOps;
-import org.apache.jena.dboe.base.file.AlreadyLocked;
-import org.apache.jena.dboe.base.file.ProcessFileLock;
+import org.apache.jena.atlas.io.IO;
 import org.apache.jena.dboe.sys.Names;
 import org.junit.Before;
-import org.junit.BeforeClass;
+import org.junit.Rule;
 import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
 
 public class TestProcessFileLock {
-    // TestLocationLockStoreConnection
     
-    private static final String DIR  = "target/locktest";
-    private static final String lockfile = DIR+"/"+Names.TDB_LOCK_FILE;
+    private String lockfile;
     
-    
-    @BeforeClass public static void beforeClass() {
-        FileOps.ensureDir(DIR);
-    }
+    //Using a per-test rule is "doubly-safe" because we clear the process state.
+    @Rule
+    public TemporaryFolder tempFolder = new TemporaryFolder();
     
     @Before public void beforeTest() {
-        File f = new File(lockfile);
         try {
-            f.delete();
-            f.createNewFile();
+            File f = tempFolder.newFile(Names.TDB_LOCK_FILE);
+            lockfile = f.getCanonicalPath();
         }
         catch (IOException e) {
-            e.printStackTrace();
+            IO.exception(e);
         }
     }
-
+    
     @Test public void process_lock_1() {
         ProcessFileLock lock = ProcessFileLock.create(lockfile);
         String fn = new File(lockfile).getAbsolutePath();