mirror of https://github.com/apache/nifi.git
NIFI-561: FileBasedClusterNodeFirewallTest should rely on JUnit / Maven norms for test files.
Signed-off-by: Mark Payne <markap14@hotmail.com>
This commit is contained in:
parent
5bf610a11e
commit
73a368f861
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue