@Test public void printsWelcomeAndExitMessage() throws Exception { String inputString = "\nCREATE (n:Person) RETURN n\n;\n"; InputStream inputStream = new ByteArrayInputStream(inputString.getBytes()); InteractiveShellRunner runner = new InteractiveShellRunner(cmdExecuter, txHandler, databaseManager, logger, new ShellStatementParser(), inputStream, historyFile, userMessagesHandler, connectionConfig); runner.runUntilEnd(); verify(logger).printIfVerbose("Welcome to cypher-shell!"); verify(logger).printIfVerbose("Exit message"); }
@Override public int runUntilEnd() { int exitCode = Main.EXIT_SUCCESS; boolean running = true; logger.printIfVerbose(userMessagesHandler.getWelcomeMessage()); while (running) { try { for (String statement : readUntilStatement()) { currentlyExecuting.set(true); executer.execute(statement); currentlyExecuting.set(false); } } catch (ExitException e) { exitCode = e.getCode(); running = false; } catch (NoMoreInputException e) { running = false; } catch (Throwable e) { logger.printError(e); } finally { currentlyExecuting.set(false); } } logger.printIfVerbose(userMessagesHandler.getExitMessage()); return exitCode; }
InteractiveShellRunner implements ShellRunner, SignalHandler { @Override public int runUntilEnd() { int exitCode = Main.EXIT_SUCCESS; boolean running = true; logger.printIfVerbose(userMessagesHandler.getWelcomeMessage()); while (running) { try { for (String statement : readUntilStatement()) { currentlyExecuting.set(true); executer.execute(statement); currentlyExecuting.set(false); } } catch (ExitException e) { exitCode = e.getCode(); running = false; } catch (NoMoreInputException e) { running = false; } catch (Throwable e) { logger.printError(e); } finally { currentlyExecuting.set(false); } } logger.printIfVerbose(userMessagesHandler.getExitMessage()); return exitCode; } }
InteractiveShellRunner implements ShellRunner, SignalHandler { @Override public int runUntilEnd() { int exitCode = Main.EXIT_SUCCESS; boolean running = true; logger.printIfVerbose(userMessagesHandler.getWelcomeMessage()); while (running) { try { for (String statement : readUntilStatement()) { currentlyExecuting.set(true); executer.execute(statement); currentlyExecuting.set(false); } } catch (ExitException e) { exitCode = e.getCode(); running = false; } catch (NoMoreInputException e) { running = false; } catch (Throwable e) { logger.printError(e); } finally { currentlyExecuting.set(false); } } logger.printIfVerbose(userMessagesHandler.getExitMessage()); return exitCode; } InteractiveShellRunner(@Nonnull StatementExecuter executer,
                                  @Nonnull TransactionHandler txHandler,
                                  @Nonnull DatabaseManager databaseManager,
                                  @Nonnull Logger logger,
                                  @Nonnull StatementParser statementParser,
                                  @Nonnull InputStream inputStream,
                                  @Nonnull File historyFile,
                                  @Nonnull UserMessagesHandler userMessagesHandler,
                                  @Nonnull ConnectionConfig connectionConfig); }
InteractiveShellRunner implements ShellRunner, SignalHandler { @Override public int runUntilEnd() { int exitCode = Main.EXIT_SUCCESS; boolean running = true; logger.printIfVerbose(userMessagesHandler.getWelcomeMessage()); while (running) { try { for (String statement : readUntilStatement()) { currentlyExecuting.set(true); executer.execute(statement); currentlyExecuting.set(false); } } catch (ExitException e) { exitCode = e.getCode(); running = false; } catch (NoMoreInputException e) { running = false; } catch (Throwable e) { logger.printError(e); } finally { currentlyExecuting.set(false); } } logger.printIfVerbose(userMessagesHandler.getExitMessage()); return exitCode; } InteractiveShellRunner(@Nonnull StatementExecuter executer,
                                  @Nonnull TransactionHandler txHandler,
                                  @Nonnull DatabaseManager databaseManager,
                                  @Nonnull Logger logger,
                                  @Nonnull StatementParser statementParser,
                                  @Nonnull InputStream inputStream,
                                  @Nonnull File historyFile,
                                  @Nonnull UserMessagesHandler userMessagesHandler,
                                  @Nonnull ConnectionConfig connectionConfig); @Override int runUntilEnd(); @Nonnull @Override Historian getHistorian(); @Nonnull List<String> readUntilStatement(); @Override void handle(final Signal signal); }
InteractiveShellRunner implements ShellRunner, SignalHandler { @Override public int runUntilEnd() { int exitCode = Main.EXIT_SUCCESS; boolean running = true; logger.printIfVerbose(userMessagesHandler.getWelcomeMessage()); while (running) { try { for (String statement : readUntilStatement()) { currentlyExecuting.set(true); executer.execute(statement); currentlyExecuting.set(false); } } catch (ExitException e) { exitCode = e.getCode(); running = false; } catch (NoMoreInputException e) { running = false; } catch (Throwable e) { logger.printError(e); } finally { currentlyExecuting.set(false); } } logger.printIfVerbose(userMessagesHandler.getExitMessage()); return exitCode; } InteractiveShellRunner(@Nonnull StatementExecuter executer,
                                  @Nonnull TransactionHandler txHandler,
                                  @Nonnull DatabaseManager databaseManager,
                                  @Nonnull Logger logger,
                                  @Nonnull StatementParser statementParser,
                                  @Nonnull InputStream inputStream,
                                  @Nonnull File historyFile,
                                  @Nonnull UserMessagesHandler userMessagesHandler,
                                  @Nonnull ConnectionConfig connectionConfig); @Override int runUntilEnd(); @Nonnull @Override Historian getHistorian(); @Nonnull List<String> readUntilStatement(); @Override void handle(final Signal signal);  }