@Test public void promptsHandlesBang() throws Exception { doThrow(authException).doNothing().when(shell).connect(connectionConfig, null); String inputString = "bo!b\nsec!ret\n"; InputStream inputStream = new ByteArrayInputStream(inputString.getBytes()); ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream ps = new PrintStream(baos); Main main = new Main(inputStream, ps); main.connectMaybeInteractively(shell, connectionConfig, true, true, true); String out = new String(baos.toByteArray(), StandardCharsets.UTF_8); assertEquals(String.format("username: bo!b%npassword: *******%n"), out); verify(connectionConfig).setUsername("bo!b"); verify(connectionConfig).setPassword("sec!ret"); verify(shell, times(2)).connect(connectionConfig, null); }
void connectMaybeInteractively(@Nonnull CypherShell shell, @Nonnull ConnectionConfig connectionConfig, boolean inputInteractive, boolean outputInteractive, boolean shouldPromptForPassword) throws Exception { connectMaybeInteractively( shell, connectionConfig, inputInteractive, outputInteractive, shouldPromptForPassword, null ); }
Main { void connectMaybeInteractively(@Nonnull CypherShell shell, @Nonnull ConnectionConfig connectionConfig, boolean inputInteractive, boolean outputInteractive, boolean shouldPromptForPassword) throws Exception { connectMaybeInteractively( shell, connectionConfig, inputInteractive, outputInteractive, shouldPromptForPassword, null ); } }
Main { void connectMaybeInteractively(@Nonnull CypherShell shell, @Nonnull ConnectionConfig connectionConfig, boolean inputInteractive, boolean outputInteractive, boolean shouldPromptForPassword) throws Exception { connectMaybeInteractively( shell, connectionConfig, inputInteractive, outputInteractive, shouldPromptForPassword, null ); } Main();   Main(final InputStream in, final PrintStream out); private  Main(final InputStream in, final PrintStream out, final boolean hasSpecialInteractiveOutputStream ); }
Main { void connectMaybeInteractively(@Nonnull CypherShell shell, @Nonnull ConnectionConfig connectionConfig, boolean inputInteractive, boolean outputInteractive, boolean shouldPromptForPassword) throws Exception { connectMaybeInteractively( shell, connectionConfig, inputInteractive, outputInteractive, shouldPromptForPassword, null ); } Main();   Main(final InputStream in, final PrintStream out); private  Main(final InputStream in, final PrintStream out, final boolean hasSpecialInteractiveOutputStream ); static void main(String[] args); }
Main { void connectMaybeInteractively(@Nonnull CypherShell shell, @Nonnull ConnectionConfig connectionConfig, boolean inputInteractive, boolean outputInteractive, boolean shouldPromptForPassword) throws Exception { connectMaybeInteractively( shell, connectionConfig, inputInteractive, outputInteractive, shouldPromptForPassword, null ); } Main();   Main(final InputStream in, final PrintStream out); private  Main(final InputStream in, final PrintStream out, final boolean hasSpecialInteractiveOutputStream ); static void main(String[] args); static final int EXIT_FAILURE; static final int EXIT_SUCCESS; }