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:11 UTC
[03/10] jena git commit: Check .delete() in beforeTest
Check .delete() in beforeTest
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/10441d7f
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/10441d7f
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/10441d7f
Branch: refs/heads/master
Commit: 10441d7f819f9dc9b4ed5191e28821e04a1e0cb1
Parents: e68daea
Author: Andy Seaborne <an...@apache.org>
Authored: Thu Oct 26 13:15:10 2017 +0100
Committer: Andy Seaborne <an...@apache.org>
Committed: Thu Oct 26 13:15:46 2017 +0100
----------------------------------------------------------------------
.../jena/dboe/base/file/TestProcessFileLock.java | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jena/blob/10441d7f/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..d434a89 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,17 +18,18 @@
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.RuntimeIOException;
+import org.apache.jena.atlas.io.IO;
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.dboe.sys.Names;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -40,7 +41,6 @@ public class TestProcessFileLock {
private static final String DIR = "target/locktest";
private static final String lockfile = DIR+"/"+Names.TDB_LOCK_FILE;
-
@BeforeClass public static void beforeClass() {
FileOps.ensureDir(DIR);
}
@@ -48,12 +48,14 @@ public class TestProcessFileLock {
@Before public void beforeTest() {
File f = new File(lockfile);
try {
- f.delete();
+ if ( FileOps.exists(lockfile) ) {
+ boolean b = f.delete();
+ if ( !b )
+ throw new RuntimeIOException("Failed to delete "+lockfile);
+ }
f.createNewFile();
}
- catch (IOException e) {
- e.printStackTrace();
- }
+ catch (IOException e) { IO.exception(e); }
}
@Test public void process_lock_1() {