NIFI-603 Providing a consistent "bad host" to use throughout the 
FileBasedClusterNodeFirewall in skipping troublesome tests where DNS may 
incorrectly return an address for a nonexistent host

Signed-off-by: Mark Payne <marka...@hotmail.com>


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

Branch: refs/heads/master
Commit: c4d1666a26c86a89ced186caf638ecf6c4437a38
Parents: 1dce27f
Author: Aldrin Piri <ald...@apache.org>
Authored: Sat May 9 11:07:50 2015 -0400
Committer: Mark Payne <marka...@hotmail.com>
Committed: Mon May 11 13:37:30 2015 -0400

----------------------------------------------------------------------
 .../impl/FileBasedClusterNodeFirewallTest.java  | 28 +++++++++++---------
 1 file changed, 15 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/c4d1666a/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 5259f4f..b5f76fb 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
@@ -44,6 +44,8 @@ public class FileBasedClusterNodeFirewallTest {
     @Rule
     public final TemporaryFolder temp = new TemporaryFolder();
 
+    private static final String NONEXISTENT_HOSTNAME = "abc";
+
     private static boolean badHostsDoNotResolve = false;
 
     /**
@@ -55,7 +57,7 @@ public class FileBasedClusterNodeFirewallTest {
     public static void ensureBadHostsDoNotWork() {
         final InetAddress ip;
         try {
-            ip = InetAddress.getByName("I typed a search term and my browser 
expected a host.");
+            ip = InetAddress.getByName(NONEXISTENT_HOSTNAME);
         } catch (final UnknownHostException uhe) {
             badHostsDoNotResolve = true;
         }
@@ -80,13 +82,13 @@ public class FileBasedClusterNodeFirewallTest {
     public void ensureBadDataWasIgnored() {
         assumeTrue(badHostsDoNotResolve);
         assertFalse("firewall treated our malformed data as a host. If " +
-            "`host \"bad data should be skipped\"` works locally, this test 
should have been " +
-            "skipped.",
-            ipsFirewall.isPermissible("bad data should be skipped"));
+                        "`host \"bad data should be skipped\"` works locally, 
this test should have been " +
+                        "skipped.",
+                ipsFirewall.isPermissible("bad data should be skipped"));
         assertFalse("firewall treated our malformed data as a host. If " +
-            "`host \"more bad data\"` works locally, this test should have 
been " +
-            "skipped.",
-            ipsFirewall.isPermissible("more bad data"));
+                        "`host \"more bad data\"` works locally, this test 
should have been " +
+                        "skipped.",
+                ipsFirewall.isPermissible("more bad data"));
     }
 
     @Test
@@ -112,9 +114,9 @@ public class FileBasedClusterNodeFirewallTest {
     @Test
     public void testIsPermissibleWithMalformedData() {
         assumeTrue(badHostsDoNotResolve);
-        assertFalse("firewall allowed host 'abc' rather than rejecting as 
malformed. If `host abc` "
-            + "works locally, this test should have been skipped.",
-            ipsFirewall.isPermissible("abc"));
+        assertFalse("firewall allowed host '" + NONEXISTENT_HOSTNAME + "' 
rather than rejecting as malformed. If `host " + NONEXISTENT_HOSTNAME + "` "
+                        + "works locally, this test should have been skipped.",
+                ipsFirewall.isPermissible(NONEXISTENT_HOSTNAME));
     }
 
     @Test
@@ -125,9 +127,9 @@ public class FileBasedClusterNodeFirewallTest {
     @Test
     public void testIsPermissibleWithEmptyConfigWithMalformedData() {
         assumeTrue(badHostsDoNotResolve);
-        assertTrue("firewall did not allow malformed host 'abc' under 
permissive configs. If " +
-            "`host abc` works locally, this test should have been skipped.",
-            acceptAllFirewall.isPermissible("abc"));
+        assertTrue("firewall did not allow malformed host '" + 
NONEXISTENT_HOSTNAME + "' under permissive configs. If " +
+                        "`host " + NONEXISTENT_HOSTNAME + "` works locally, 
this test should have been skipped.",
+                acceptAllFirewall.isPermissible(NONEXISTENT_HOSTNAME));
     }
 
 }

Reply via email to