NIFI-561: FileBasedClusterNodeFirewallTest should rely on JUnit / Maven norms 
for test files.

Signed-off-by: Mark Payne <[email protected]>


Project: http://git-wip-us.apache.org/repos/asf/incubator-nifi/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-nifi/commit/73a368f8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-nifi/tree/73a368f8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-nifi/diff/73a368f8

Branch: refs/heads/develop
Commit: 73a368f861de76638daac6787eea310cd1010ba6
Parents: 5bf610a
Author: Sean Busbey <[email protected]>
Authored: Wed Apr 29 22:42:44 2015 -0500
Committer: Mark Payne <[email protected]>
Committed: Fri May 1 10:48:23 2015 -0400

----------------------------------------------------------------------
 .../impl/FileBasedClusterNodeFirewallTest.java  | 26 ++++++--------------
 1 file changed, 8 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/73a368f8/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/firewall/impl/FileBasedClusterNodeFirewallTest.java
----------------------------------------------------------------------
diff --git 
a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/firewall/impl/FileBasedClusterNodeFirewallTest.java
 
b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/firewall/impl/FileBasedClusterNodeFirewallTest.java
index 8e92de8..5259f4f 100644
--- 
a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/firewall/impl/FileBasedClusterNodeFirewallTest.java
+++ 
b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/firewall/impl/FileBasedClusterNodeFirewallTest.java
@@ -17,18 +17,17 @@
 package org.apache.nifi.cluster.firewall.impl;
 
 import java.io.File;
-import java.io.IOException;
 import java.net.InetAddress;
 import java.net.UnknownHostException;
-import org.apache.nifi.util.file.FileUtils;
-import org.junit.After;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assume.assumeTrue;
 import org.junit.Before;
 import org.junit.BeforeClass;
+import org.junit.Rule;
 import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
 
 public class FileBasedClusterNodeFirewallTest {
 
@@ -42,6 +41,9 @@ public class FileBasedClusterNodeFirewallTest {
 
     private File restoreDirectory;
 
+    @Rule
+    public final TemporaryFolder temp = new TemporaryFolder();
+
     private static boolean badHostsDoNotResolve = false;
 
     /**
@@ -62,20 +64,15 @@ public class FileBasedClusterNodeFirewallTest {
     @Before
     public void setup() throws Exception {
 
-        ipsConfig = new 
File("src/test/resources/org/apache/nifi/cluster/firewall/impl/ips.txt");
-        emptyConfig = new 
File("src/test/resources/org/apache/nifi/cluster/firewall/impl/empty.txt");
+        ipsConfig = new 
File(getClass().getResource("/org/apache/nifi/cluster/firewall/impl/ips.txt").toURI());
+        emptyConfig = new 
File(getClass().getResource("/org/apache/nifi/cluster/firewall/impl/empty.txt").toURI());
 
-        restoreDirectory = new File(System.getProperty("java.io.tmpdir") + 
"/firewall_restore");
+        restoreDirectory = temp.newFolder("firewall_restore");
 
         ipsFirewall = new FileBasedClusterNodeFirewall(ipsConfig, 
restoreDirectory);
         acceptAllFirewall = new FileBasedClusterNodeFirewall(emptyConfig);
     }
 
-    @After
-    public void teardown() throws IOException {
-        deleteFile(restoreDirectory);
-    }
-
     /**
      * We have two garbage lines in our test config file, ensure they didn't 
get turned into hosts.
      */
@@ -133,11 +130,4 @@ public class FileBasedClusterNodeFirewallTest {
             acceptAllFirewall.isPermissible("abc"));
     }
 
-    private boolean deleteFile(final File file) {
-        if (file.isDirectory()) {
-            FileUtils.deleteFilesInDir(file, null, null, true, true);
-        }
-        return FileUtils.deleteFile(file, null, 10);
-    }
-
 }

Reply via email to