Repository: nifi
Updated Branches:
  refs/heads/master b0122c6a7 -> 2fd39676a


http://git-wip-us.apache.org/repos/asf/nifi/blob/2fd39676/nifi-toolkit/nifi-toolkit-tls/src/test/java/org/apache/nifi/toolkit/tls/standalone/TlsToolkitStandaloneCommandLineTest.java
----------------------------------------------------------------------
diff --git 
a/nifi-toolkit/nifi-toolkit-tls/src/test/java/org/apache/nifi/toolkit/tls/standalone/TlsToolkitStandaloneCommandLineTest.java
 
b/nifi-toolkit/nifi-toolkit-tls/src/test/java/org/apache/nifi/toolkit/tls/standalone/TlsToolkitStandaloneCommandLineTest.java
index 82c67d9..a284318 100644
--- 
a/nifi-toolkit/nifi-toolkit-tls/src/test/java/org/apache/nifi/toolkit/tls/standalone/TlsToolkitStandaloneCommandLineTest.java
+++ 
b/nifi-toolkit/nifi-toolkit-tls/src/test/java/org/apache/nifi/toolkit/tls/standalone/TlsToolkitStandaloneCommandLineTest.java
@@ -19,6 +19,8 @@ package org.apache.nifi.toolkit.tls.standalone;
 
 import org.apache.nifi.toolkit.tls.commandLine.CommandLineParseException;
 import org.apache.nifi.toolkit.tls.commandLine.ExitCode;
+import org.apache.nifi.toolkit.tls.configuration.InstanceDefinition;
+import org.apache.nifi.toolkit.tls.configuration.InstanceIdentifier;
 import org.apache.nifi.toolkit.tls.configuration.StandaloneConfig;
 import org.apache.nifi.toolkit.tls.configuration.TlsConfig;
 import org.apache.nifi.toolkit.tls.properties.NiFiPropertiesWriter;
@@ -35,11 +37,15 @@ import java.io.IOException;
 import java.security.SecureRandom;
 import java.util.Collections;
 import java.util.List;
+import java.util.Map;
 import java.util.Properties;
 import java.util.Random;
+import java.util.function.Function;
+import java.util.stream.Collectors;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.fail;
 import static org.mockito.Matchers.any;
@@ -145,17 +151,10 @@ public class TlsToolkitStandaloneCommandLineTest {
 
         tlsToolkitStandaloneCommandLine.parse("-n", nifi1 + " , " + nifi2);
 
-        List<String> hostnames = 
tlsToolkitStandaloneCommandLine.createConfig().getHostnames();
-        assertEquals(2, hostnames.size());
-        assertEquals(nifi1, hostnames.get(0));
-        assertEquals(nifi2, hostnames.get(1));
-    }
-
-    @Test
-    public void testHttpsPort() throws CommandLineParseException {
-        int testPort = 8998;
-        tlsToolkitStandaloneCommandLine.parse("-p", 
Integer.toString(testPort));
-        assertEquals(testPort, 
tlsToolkitStandaloneCommandLine.createConfig().getHttpsPort());
+        List<InstanceDefinition> instanceDefinitions = 
tlsToolkitStandaloneCommandLine.createConfig().getInstanceDefinitions();
+        assertEquals(2, instanceDefinitions.size());
+        assertEquals(nifi1, instanceDefinitions.get(0).getHostname());
+        assertEquals(nifi2, instanceDefinitions.get(1).getHostname());
     }
 
     @Test
@@ -183,52 +182,46 @@ public class TlsToolkitStandaloneCommandLineTest {
     @Test
     public void testNotSameKeyAndKeystorePassword() throws 
CommandLineParseException {
         tlsToolkitStandaloneCommandLine.parse("-g", "-n", 
TlsConfig.DEFAULT_HOSTNAME);
-        List<String> keyStorePasswords = 
tlsToolkitStandaloneCommandLine.createConfig().getKeyStorePasswords();
-        List<String> keyPasswords = 
tlsToolkitStandaloneCommandLine.createConfig().getKeyPasswords();
-        assertEquals(1, 
tlsToolkitStandaloneCommandLine.createConfig().getHostnames().size());
-        assertEquals(1, keyStorePasswords.size());
-        assertEquals(1, keyPasswords.size());
-        assertNotEquals(keyStorePasswords.get(0), keyPasswords.get(0));
+        List<InstanceDefinition> instanceDefinitions = 
tlsToolkitStandaloneCommandLine.createConfig().getInstanceDefinitions();
+        assertEquals(1, instanceDefinitions.size());
+        assertNotEquals(instanceDefinitions.get(0).getKeyStorePassword(), 
instanceDefinitions.get(0).getKeyPassword());
     }
 
     @Test
     public void testSameKeyAndKeystorePassword() throws 
CommandLineParseException {
         tlsToolkitStandaloneCommandLine.parse("-n", 
TlsConfig.DEFAULT_HOSTNAME);
-        List<String> keyStorePasswords = 
tlsToolkitStandaloneCommandLine.createConfig().getKeyStorePasswords();
-        List<String> keyPasswords = 
tlsToolkitStandaloneCommandLine.createConfig().getKeyPasswords();
-        assertEquals(1, 
tlsToolkitStandaloneCommandLine.createConfig().getHostnames().size());
-        assertEquals(1, keyStorePasswords.size());
-        assertEquals(1, keyPasswords.size());
-        assertEquals(keyStorePasswords.get(0), keyPasswords.get(0));
+        List<InstanceDefinition> instanceDefinitions = 
tlsToolkitStandaloneCommandLine.createConfig().getInstanceDefinitions();
+        assertEquals(1, instanceDefinitions.size());
+        assertEquals(instanceDefinitions.get(0).getKeyStorePassword(), 
instanceDefinitions.get(0).getKeyPassword());
     }
 
     @Test
     public void testSameKeyAndKeystorePasswordWithKeystorePasswordSpecified() 
throws CommandLineParseException {
         String testPassword = "testPassword";
         tlsToolkitStandaloneCommandLine.parse("-S", testPassword, "-n", 
TlsConfig.DEFAULT_HOSTNAME);
-        List<String> keyStorePasswords = 
tlsToolkitStandaloneCommandLine.createConfig().getKeyStorePasswords();
-        assertEquals(1, keyStorePasswords.size());
-        assertEquals(testPassword, keyStorePasswords.get(0));
-        assertEquals(keyStorePasswords, 
tlsToolkitStandaloneCommandLine.createConfig().getKeyPasswords());
+        List<InstanceDefinition> instanceDefinitions = 
tlsToolkitStandaloneCommandLine.createConfig().getInstanceDefinitions();
+        assertEquals(1, instanceDefinitions.size());
+        assertEquals(testPassword, 
instanceDefinitions.get(0).getKeyStorePassword());
+        assertEquals(testPassword, 
instanceDefinitions.get(0).getKeyPassword());
     }
 
     @Test
     public void testSameKeyAndKeystorePasswordWithKeyPasswordSpecified() 
throws CommandLineParseException {
         String testPassword = "testPassword";
         tlsToolkitStandaloneCommandLine.parse("-K", testPassword, "-n", 
TlsConfig.DEFAULT_HOSTNAME);
-        List<String> keyPasswords = 
tlsToolkitStandaloneCommandLine.createConfig().getKeyPasswords();
-        
assertNotEquals(tlsToolkitStandaloneCommandLine.createConfig().getKeyStorePasswords(),
 keyPasswords);
-        assertEquals(1, keyPasswords.size());
-        assertEquals(testPassword, keyPasswords.get(0));
+        List<InstanceDefinition> instanceDefinitions = 
tlsToolkitStandaloneCommandLine.createConfig().getInstanceDefinitions();
+        assertNotEquals(instanceDefinitions.get(0).getKeyStorePassword(), 
instanceDefinitions.get(0).getKeyPassword());
+        assertEquals(1, instanceDefinitions.size());
+        assertEquals(testPassword, 
instanceDefinitions.get(0).getKeyPassword());
     }
 
     @Test
     public void testKeyStorePasswordArg() throws CommandLineParseException {
         String testPassword = "testPassword";
         tlsToolkitStandaloneCommandLine.parse("-S", testPassword, "-n", 
TlsConfig.DEFAULT_HOSTNAME);
-        List<String> keyStorePasswords = 
tlsToolkitStandaloneCommandLine.createConfig().getKeyStorePasswords();
-        assertEquals(1, keyStorePasswords.size());
-        assertEquals(testPassword, keyStorePasswords.get(0));
+        List<InstanceDefinition> instanceDefinitions = 
tlsToolkitStandaloneCommandLine.createConfig().getInstanceDefinitions();
+        assertEquals(1, instanceDefinitions.size());
+        assertEquals(testPassword, 
instanceDefinitions.get(0).getKeyStorePassword());
     }
 
     @Test
@@ -236,31 +229,19 @@ public class TlsToolkitStandaloneCommandLineTest {
         String testPassword1 = "testPassword1";
         String testPassword2 = "testPassword2";
         tlsToolkitStandaloneCommandLine.parse("-n", "nifi1,nifi2", "-S", 
testPassword1, "-S", testPassword2);
-        List<String> keyStorePasswords = 
tlsToolkitStandaloneCommandLine.createConfig().getKeyStorePasswords();
-        assertEquals(2, keyStorePasswords.size());
-        assertEquals(testPassword1, keyStorePasswords.get(0));
-        assertEquals(testPassword2, keyStorePasswords.get(1));
-    }
-
-    @Test
-    public void testMultipleKeystorePasswordArgSingleHost() {
-        String testPassword1 = "testPassword1";
-        String testPassword2 = "testPassword2";
-        try {
-            tlsToolkitStandaloneCommandLine.parse("-S", testPassword1, "-S", 
testPassword2);
-            fail("Expected error with mismatch keystore password number");
-        } catch (CommandLineParseException e) {
-            
assertEquals(ExitCode.ERROR_INCORRECT_NUMBER_OF_PASSWORDS.ordinal(), 
e.getExitCode());
-        }
+        List<InstanceDefinition> instanceDefinitions = 
tlsToolkitStandaloneCommandLine.createConfig().getInstanceDefinitions();
+        assertEquals(2, instanceDefinitions.size());
+        assertEquals(testPassword1, 
instanceDefinitions.get(0).getKeyStorePassword());
+        assertEquals(testPassword2, 
instanceDefinitions.get(1).getKeyStorePassword());
     }
 
     @Test
     public void testKeyPasswordArg() throws CommandLineParseException {
         String testPassword = "testPassword";
         tlsToolkitStandaloneCommandLine.parse("-K", testPassword, "-n", 
TlsConfig.DEFAULT_HOSTNAME);
-        List<String> keyPasswords = 
tlsToolkitStandaloneCommandLine.createConfig().getKeyPasswords();
-        assertEquals(1, keyPasswords.size());
-        assertEquals(testPassword, keyPasswords.get(0));
+        List<InstanceDefinition> instanceDefinitions = 
tlsToolkitStandaloneCommandLine.createConfig().getInstanceDefinitions();
+        assertEquals(1, instanceDefinitions.size());
+        assertEquals(testPassword, 
instanceDefinitions.get(0).getKeyPassword());
     }
 
     @Test
@@ -268,31 +249,19 @@ public class TlsToolkitStandaloneCommandLineTest {
         String testPassword1 = "testPassword1";
         String testPassword2 = "testPassword2";
         tlsToolkitStandaloneCommandLine.parse("-n", "nifi1,nifi2", "-K", 
testPassword1, "-K", testPassword2);
-        List<String> keyPasswords = 
tlsToolkitStandaloneCommandLine.createConfig().getKeyPasswords();
-        assertEquals(2, keyPasswords.size());
-        assertEquals(testPassword1, keyPasswords.get(0));
-        assertEquals(testPassword2, keyPasswords.get(1));
-    }
-
-    @Test
-    public void testMultipleKeyPasswordArgSingleHost() {
-        String testPassword1 = "testPassword1";
-        String testPassword2 = "testPassword2";
-        try {
-            tlsToolkitStandaloneCommandLine.parse("-K", testPassword1, "-K", 
testPassword2);
-            fail("Expected error with mismatch keystore password number");
-        } catch (CommandLineParseException e) {
-            
assertEquals(ExitCode.ERROR_INCORRECT_NUMBER_OF_PASSWORDS.ordinal(), 
e.getExitCode());
-        }
+        List<InstanceDefinition> instanceDefinitions = 
tlsToolkitStandaloneCommandLine.createConfig().getInstanceDefinitions();
+        assertEquals(2, instanceDefinitions.size());
+        assertEquals(testPassword1, 
instanceDefinitions.get(0).getKeyPassword());
+        assertEquals(testPassword2, 
instanceDefinitions.get(1).getKeyPassword());
     }
 
     @Test
     public void testTruststorePasswordArg() throws CommandLineParseException {
         String testPassword = "testPassword";
         tlsToolkitStandaloneCommandLine.parse("-P", testPassword, "-n", 
TlsConfig.DEFAULT_HOSTNAME);
-        List<String> trustStorePasswords = 
tlsToolkitStandaloneCommandLine.createConfig().getTrustStorePasswords();
-        assertEquals(1, trustStorePasswords.size());
-        assertEquals(testPassword, trustStorePasswords.get(0));
+        List<InstanceDefinition> instanceDefinitions = 
tlsToolkitStandaloneCommandLine.createConfig().getInstanceDefinitions();
+        assertEquals(1, instanceDefinitions.size());
+        assertEquals(testPassword, 
instanceDefinitions.get(0).getTrustStorePassword());
     }
 
     @Test
@@ -300,22 +269,10 @@ public class TlsToolkitStandaloneCommandLineTest {
         String testPassword1 = "testPassword1";
         String testPassword2 = "testPassword2";
         tlsToolkitStandaloneCommandLine.parse("-n", "nifi1,nifi2", "-P", 
testPassword1, "-P", testPassword2);
-        List<String> trustStorePasswords = 
tlsToolkitStandaloneCommandLine.createConfig().getTrustStorePasswords();
-        assertEquals(2, trustStorePasswords.size());
-        assertEquals(testPassword1, trustStorePasswords.get(0));
-        assertEquals(testPassword2, trustStorePasswords.get(1));
-    }
-
-    @Test
-    public void testMultipleTruststorePasswordArgSingleHost() {
-        String testPassword1 = "testPassword1";
-        String testPassword2 = "testPassword2";
-        try {
-            tlsToolkitStandaloneCommandLine.parse("-P", testPassword1, "-P", 
testPassword2);
-            fail("Expected error with mismatch keystore password number");
-        } catch (CommandLineParseException e) {
-            
assertEquals(ExitCode.ERROR_INCORRECT_NUMBER_OF_PASSWORDS.ordinal(), 
e.getExitCode());
-        }
+        List<InstanceDefinition> instanceDefinitions = 
tlsToolkitStandaloneCommandLine.createConfig().getInstanceDefinitions();
+        assertEquals(2, instanceDefinitions.size());
+        assertEquals(testPassword1, 
instanceDefinitions.get(0).getTrustStorePassword());
+        assertEquals(testPassword2, 
instanceDefinitions.get(1).getTrustStorePassword());
     }
 
     @Test
@@ -364,6 +321,83 @@ public class TlsToolkitStandaloneCommandLineTest {
         assertEquals(testPass2, clientPasswords.get(1));
     }
 
+    @Test
+    public void testNoGlobalOrder() throws CommandLineParseException {
+        String hostname1 = "other0[4-6]";
+        String hostname2 = "nifi3(2)";
+        tlsToolkitStandaloneCommandLine.parse("-n", hostname1, "-n", 
hostname2);
+        Map<InstanceIdentifier, InstanceDefinition> definitionMap = 
tlsToolkitStandaloneCommandLine.createConfig().getInstanceDefinitions().stream()
+                
.collect(Collectors.toMap(InstanceDefinition::getInstanceIdentifier, 
Function.identity()));
+        assertEquals(5, definitionMap.size());
+
+        InstanceDefinition nifi3_1 = definitionMap.get(new 
InstanceIdentifier("nifi3", 1));
+        assertNotNull(nifi3_1);
+        assertEquals(1, nifi3_1.getInstanceIdentifier().getNumber());
+        assertEquals(1, nifi3_1.getNumber());
+
+        InstanceDefinition nifi3_2 = definitionMap.get(new 
InstanceIdentifier("nifi3", 2));
+        assertNotNull(nifi3_2);
+        assertEquals(2, nifi3_2.getInstanceIdentifier().getNumber());
+        assertEquals(2, nifi3_2.getNumber());
+
+        InstanceDefinition other04 = definitionMap.get(new 
InstanceIdentifier("other04", 1));
+        assertNotNull(other04);
+        assertEquals(1, other04.getInstanceIdentifier().getNumber());
+        assertEquals(1, other04.getNumber());
+
+        InstanceDefinition other05 = definitionMap.get(new 
InstanceIdentifier("other05", 1));
+        assertNotNull(other05);
+        assertEquals(1, other05.getInstanceIdentifier().getNumber());
+        assertEquals(1, other05.getNumber());
+
+        InstanceDefinition other06 = definitionMap.get(new 
InstanceIdentifier("other06", 1));
+        assertNotNull(other06);
+        assertEquals(1, other06.getInstanceIdentifier().getNumber());
+        assertEquals(1, other06.getNumber());
+    }
+
+    @Test
+    public void testGlobalOrder() throws CommandLineParseException {
+        String hostname1 = "other0[4-6]";
+        String hostname2 = "nifi3(2)";
+        String globalOrder1 = "nifi[1-5](2),other[01-4]";
+        String globalOrder2 = "other[05-10]";
+        tlsToolkitStandaloneCommandLine.parse("-n", hostname1, "-n", 
hostname2, "-G", globalOrder1, "-G", globalOrder2);
+        Map<InstanceIdentifier, InstanceDefinition> definitionMap = 
tlsToolkitStandaloneCommandLine.createConfig().getInstanceDefinitions().stream()
+                
.collect(Collectors.toMap(InstanceDefinition::getInstanceIdentifier, 
Function.identity()));
+        assertEquals(5, definitionMap.size());
+
+        InstanceDefinition nifi3_1 = definitionMap.get(new 
InstanceIdentifier("nifi3", 1));
+        assertNotNull(nifi3_1);
+        assertEquals(1, nifi3_1.getInstanceIdentifier().getNumber());
+        assertEquals(5, nifi3_1.getNumber());
+
+        InstanceDefinition nifi3_2 = definitionMap.get(new 
InstanceIdentifier("nifi3", 2));
+        assertNotNull(nifi3_2);
+        assertEquals(2, nifi3_2.getInstanceIdentifier().getNumber());
+        assertEquals(6, nifi3_2.getNumber());
+
+        InstanceDefinition other04 = definitionMap.get(new 
InstanceIdentifier("other04", 1));
+        assertNotNull(other04);
+        assertEquals(1, other04.getInstanceIdentifier().getNumber());
+        assertEquals(14, other04.getNumber());
+
+        InstanceDefinition other05 = definitionMap.get(new 
InstanceIdentifier("other05", 1));
+        assertNotNull(other05);
+        assertEquals(1, other05.getInstanceIdentifier().getNumber());
+        assertEquals(15, other05.getNumber());
+
+        InstanceDefinition other06 = definitionMap.get(new 
InstanceIdentifier("other06", 1));
+        assertNotNull(other06);
+        assertEquals(1, other06.getInstanceIdentifier().getNumber());
+        assertEquals(16, other06.getNumber());
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    public void testBadGlobalOrder() throws CommandLineParseException {
+        tlsToolkitStandaloneCommandLine.parse("-n", "notInGlobalOrder", "-G", 
"nifi[1-3]");
+    }
+
     private Properties getProperties() throws IOException {
         NiFiPropertiesWriter niFiPropertiesWriter = 
tlsToolkitStandaloneCommandLine.createConfig().getNiFiPropertiesWriterFactory().create();
         ByteArrayOutputStream byteArrayOutputStream = new 
ByteArrayOutputStream();

http://git-wip-us.apache.org/repos/asf/nifi/blob/2fd39676/nifi-toolkit/nifi-toolkit-tls/src/test/java/org/apache/nifi/toolkit/tls/standalone/TlsToolkitStandaloneTest.java
----------------------------------------------------------------------
diff --git 
a/nifi-toolkit/nifi-toolkit-tls/src/test/java/org/apache/nifi/toolkit/tls/standalone/TlsToolkitStandaloneTest.java
 
b/nifi-toolkit/nifi-toolkit-tls/src/test/java/org/apache/nifi/toolkit/tls/standalone/TlsToolkitStandaloneTest.java
index af81eae..a8cf7a5 100644
--- 
a/nifi-toolkit/nifi-toolkit-tls/src/test/java/org/apache/nifi/toolkit/tls/standalone/TlsToolkitStandaloneTest.java
+++ 
b/nifi-toolkit/nifi-toolkit-tls/src/test/java/org/apache/nifi/toolkit/tls/standalone/TlsToolkitStandaloneTest.java
@@ -20,6 +20,7 @@ package org.apache.nifi.toolkit.tls.standalone;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.IOUtils;
 import org.apache.nifi.security.util.CertificateUtils;
+import org.apache.nifi.toolkit.tls.SystemExitCapturer;
 import org.apache.nifi.toolkit.tls.commandLine.BaseCommandLine;
 import org.apache.nifi.toolkit.tls.commandLine.ExitCode;
 import org.apache.nifi.toolkit.tls.configuration.TlsConfig;
@@ -40,7 +41,6 @@ import java.io.InputStream;
 import java.security.KeyPair;
 import java.security.KeyStore;
 import java.security.NoSuchAlgorithmException;
-import java.security.Permission;
 import java.security.PrivateKey;
 import java.security.PublicKey;
 import java.security.cert.Certificate;
@@ -54,13 +54,12 @@ import java.util.UUID;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotEquals;
 import static org.junit.Assert.assertNull;
-import static org.junit.Assert.fail;
 
 public class TlsToolkitStandaloneTest {
     public static final String NIFI_FAKE_PROPERTY = "nifi.fake.property";
     public static final String FAKE_VALUE = "fake value";
     public static final String TEST_NIFI_PROPERTIES = 
"src/test/resources/localhost/nifi.properties";
-    private SecurityManager originalSecurityManager;
+    private SystemExitCapturer systemExitCapturer;
 
     private File tempDir;
 
@@ -74,31 +73,12 @@ public class TlsToolkitStandaloneTest {
         if (!tempDir.mkdirs()) {
             throw new IOException("Couldn't make directory " + tempDir);
         }
-
-        originalSecurityManager = System.getSecurityManager();
-        // [see 
http://stackoverflow.com/questions/309396/java-how-to-test-methods-that-call-system-exit#answer-309427]
-        System.setSecurityManager(new SecurityManager() {
-            @Override
-            public void checkPermission(Permission perm) {
-                // Noop
-            }
-
-            @Override
-            public void checkPermission(Permission perm, Object context) {
-                // Noop
-            }
-
-            @Override
-            public void checkExit(int status) {
-                super.checkExit(status);
-                throw new ExitException(status);
-            }
-        });
+        systemExitCapturer = new SystemExitCapturer();
     }
 
     @After
     public void teardown() throws IOException {
-        System.setSecurityManager(originalSecurityManager);
+        systemExitCapturer.close();
         FileUtils.deleteDirectory(tempDir);
     }
 
@@ -248,13 +228,16 @@ public class TlsToolkitStandaloneTest {
             trustStore.load(inputStream, 
nifiProperties.getProperty(NiFiProperties.SECURITY_TRUSTSTORE_PASSWD).toCharArray());
         }
 
+        String trustStoreFilename = BaseCommandLine.KEYSTORE + trustStoreType;
+        assertEquals("./conf/" + trustStoreFilename, 
nifiProperties.getProperty(NiFiProperties.SECURITY_KEYSTORE));
+
         Certificate certificate = 
trustStore.getCertificate(TlsToolkitStandalone.NIFI_CERT);
         assertEquals(rootCert, certificate);
 
         String keyStoreType = 
nifiProperties.getProperty(NiFiProperties.SECURITY_KEYSTORE_TYPE);
         String keyStoreFilename = BaseCommandLine.KEYSTORE + keyStoreType;
         File keyStoreFile = new File(hostDir, keyStoreFilename);
-        assertEquals(keyStoreFilename, 
nifiProperties.getProperty(NiFiProperties.SECURITY_KEYSTORE));
+        assertEquals("./conf/" + keyStoreFilename, 
nifiProperties.getProperty(NiFiProperties.SECURITY_KEYSTORE));
 
         KeyStore keyStore = KeyStore.getInstance(keyStoreType);
         try (InputStream inputStream = new FileInputStream(keyStoreFile)) {
@@ -303,23 +286,6 @@ public class TlsToolkitStandaloneTest {
     }
 
     private void runAndAssertExitCode(ExitCode exitCode, String... args) {
-        try {
-            TlsToolkitStandaloneCommandLine.main(args);
-            fail("Expecting exit code: " + exitCode);
-        } catch (ExitException e) {
-            assertEquals(exitCode, ExitCode.values()[e.getExitCode()]);
-        }
-    }
-
-    private static class ExitException extends SecurityException {
-        private final int exitCode;
-
-        public ExitException(int exitCode) {
-            this.exitCode = exitCode;
-        }
-
-        public int getExitCode() {
-            return exitCode;
-        }
+        systemExitCapturer.runAndAssertExitCode(() -> 
TlsToolkitStandaloneCommandLine.main(args), exitCode);
     }
 }

http://git-wip-us.apache.org/repos/asf/nifi/blob/2fd39676/nifi-toolkit/nifi-toolkit-tls/src/test/java/org/apache/nifi/toolkit/tls/util/PasswordUtilTest.java
----------------------------------------------------------------------
diff --git 
a/nifi-toolkit/nifi-toolkit-tls/src/test/java/org/apache/nifi/toolkit/tls/util/PasswordUtilTest.java
 
b/nifi-toolkit/nifi-toolkit-tls/src/test/java/org/apache/nifi/toolkit/tls/util/PasswordUtilTest.java
index e79815a..f08c32c 100644
--- 
a/nifi-toolkit/nifi-toolkit-tls/src/test/java/org/apache/nifi/toolkit/tls/util/PasswordUtilTest.java
+++ 
b/nifi-toolkit/nifi-toolkit-tls/src/test/java/org/apache/nifi/toolkit/tls/util/PasswordUtilTest.java
@@ -24,6 +24,7 @@ import java.nio.ByteBuffer;
 import java.security.SecureRandom;
 import java.util.Arrays;
 import java.util.Base64;
+import java.util.function.Supplier;
 
 import static org.junit.Assert.assertEquals;
 import static org.mockito.Matchers.any;
@@ -48,4 +49,12 @@ public class PasswordUtilTest {
         String actual = passwordUtil.generatePassword();
         assertEquals(expected, actual);
     }
+
+    @Test(expected = PasswordsExhaustedException.class)
+    public void testPasswordExhausted() {
+        Supplier<String> supplier = PasswordUtil.passwordSupplier("exhausted", 
new String[]{"a", "b"});
+        supplier.get();
+        supplier.get();
+        supplier.get();
+    }
 }

http://git-wip-us.apache.org/repos/asf/nifi/blob/2fd39676/nifi-toolkit/nifi-toolkit-tls/src/test/resources/overlay.properties
----------------------------------------------------------------------
diff --git 
a/nifi-toolkit/nifi-toolkit-tls/src/test/resources/overlay.properties 
b/nifi-toolkit/nifi-toolkit-tls/src/test/resources/overlay.properties
new file mode 100644
index 0000000..c4d02c2
--- /dev/null
+++ b/nifi-toolkit/nifi-toolkit-tls/src/test/resources/overlay.properties
@@ -0,0 +1,23 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# Comma separated list of properties to put the hostname into
+hostname.properties=nifi.remote.input.host,nifi.web.https.host,nifi.cluster.node.address
+
+nifi.web.https.port=9443
+nifi.remote.input.socket.port=10443
+nifi.cluster.node.protocol.port=11443
\ No newline at end of file

Reply via email to