commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pascalschumac...@apache.org
Subject commons-io git commit: FileAlterationMonitorTestCase and FileAlterationObserverTestCase: use TemporaryFolder rule, so that tests are independent
Date Sun, 01 Oct 2017 12:49:38 GMT
Repository: commons-io
Updated Branches:
  refs/heads/master 5f2c10915 -> 5e223a403


FileAlterationMonitorTestCase and FileAlterationObserverTestCase: use TemporaryFolder rule,
so that tests are independent


Project: http://git-wip-us.apache.org/repos/asf/commons-io/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-io/commit/5e223a40
Tree: http://git-wip-us.apache.org/repos/asf/commons-io/tree/5e223a40
Diff: http://git-wip-us.apache.org/repos/asf/commons-io/diff/5e223a40

Branch: refs/heads/master
Commit: 5e223a403e65992d2d18b1b8cab5da2c6c1aa37d
Parents: 5f2c109
Author: pascalschumacher <pascalschumacher@gmx.net>
Authored: Sun Oct 1 14:49:28 2017 +0200
Committer: pascalschumacher <pascalschumacher@gmx.net>
Committed: Sun Oct 1 14:49:28 2017 +0200

----------------------------------------------------------------------
 .../io/monitor/AbstractMonitorTestCase.java        | 17 +++++++----------
 .../io/monitor/FileAlterationMonitorTestCase.java  |  1 -
 .../io/monitor/FileAlterationObserverTestCase.java |  1 -
 3 files changed, 7 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-io/blob/5e223a40/src/test/java/org/apache/commons/io/monitor/AbstractMonitorTestCase.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/io/monitor/AbstractMonitorTestCase.java b/src/test/java/org/apache/commons/io/monitor/AbstractMonitorTestCase.java
index f10e286..aaedaaf 100644
--- a/src/test/java/org/apache/commons/io/monitor/AbstractMonitorTestCase.java
+++ b/src/test/java/org/apache/commons/io/monitor/AbstractMonitorTestCase.java
@@ -28,11 +28,16 @@ import org.apache.commons.io.filefilter.FileFilterUtils;
 import org.apache.commons.io.filefilter.HiddenFileFilter;
 import org.apache.commons.io.filefilter.IOFileFilter;
 import org.junit.Before;
+import org.junit.Rule;
+import org.junit.rules.TemporaryFolder;
 
 /**
  * {@link FileAlterationObserver} Test Case.
  */
-public abstract class AbstractMonitorTestCase  {
+public abstract class AbstractMonitorTestCase {
+
+    @Rule
+    public TemporaryFolder temporaryFolder = new TemporaryFolder();
 
     /** File observer */
     protected FileAlterationObserver observer;
@@ -40,9 +45,6 @@ public abstract class AbstractMonitorTestCase  {
     /** Listener which collects file changes */
     protected CollectionFileListener listener;
 
-    /** Test directory name */
-    protected String testDirName = null;
-
     /** Directory for test files */
     protected File testDir;
 
@@ -51,12 +53,7 @@ public abstract class AbstractMonitorTestCase  {
 
     @Before
     public void setUp() throws Exception {
-        testDir = new File(new File("."), testDirName);
-        if (testDir.exists()) {
-            FileUtils.cleanDirectory(testDir);
-        } else {
-            testDir.mkdir();
-        }
+        testDir = temporaryFolder.getRoot();
 
         final IOFileFilter files = FileFilterUtils.fileFileFilter();
         final IOFileFilter javaSuffix = FileFilterUtils.suffixFileFilter(".java");

http://git-wip-us.apache.org/repos/asf/commons-io/blob/5e223a40/src/test/java/org/apache/commons/io/monitor/FileAlterationMonitorTestCase.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/io/monitor/FileAlterationMonitorTestCase.java
b/src/test/java/org/apache/commons/io/monitor/FileAlterationMonitorTestCase.java
index 6cfabe4..200f858 100644
--- a/src/test/java/org/apache/commons/io/monitor/FileAlterationMonitorTestCase.java
+++ b/src/test/java/org/apache/commons/io/monitor/FileAlterationMonitorTestCase.java
@@ -39,7 +39,6 @@ public class FileAlterationMonitorTestCase extends AbstractMonitorTestCase
{
      *
      */
     public FileAlterationMonitorTestCase() {
-        testDirName = "test-monitor";
         listener = new CollectionFileListener(false);
     }
 

http://git-wip-us.apache.org/repos/asf/commons-io/blob/5e223a40/src/test/java/org/apache/commons/io/monitor/FileAlterationObserverTestCase.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/io/monitor/FileAlterationObserverTestCase.java
b/src/test/java/org/apache/commons/io/monitor/FileAlterationObserverTestCase.java
index cef9c18..e911bae 100644
--- a/src/test/java/org/apache/commons/io/monitor/FileAlterationObserverTestCase.java
+++ b/src/test/java/org/apache/commons/io/monitor/FileAlterationObserverTestCase.java
@@ -39,7 +39,6 @@ public class FileAlterationObserverTestCase extends AbstractMonitorTestCase
{
      *
      */
     public FileAlterationObserverTestCase() {
-        testDirName = "test-observer";
         listener = new CollectionFileListener(true);
     }
 


Mime
View raw message