@Test public void justNewLineThrowsNoMoreInput() throws Exception { thrown.expect(NoMoreInputException.class); String inputString = "\n"; InputStream inputStream = new ByteArrayInputStream(inputString.getBytes()); InteractiveShellRunner runner = new InteractiveShellRunner(cmdExecuter, txHandler, databaseManager, logger, new ShellStatementParser(), inputStream, historyFile, userMessagesHandler, connectionConfig); runner.readUntilStatement(); }
@Nonnull public List<String> readUntilStatement() throws IOException, NoMoreInputException { while (true) { String line = reader.readLine(updateAndGetPrompt().renderedString()); if (line == null) { throw new NoMoreInputException(); } if (line.trim().isEmpty() && !statementParser.containsText()) { continue; } statementParser.parseMoreText(line + "\n"); if (statementParser.hasStatements()) { return statementParser.consumeStatements(); } } }
InteractiveShellRunner implements ShellRunner, SignalHandler { @Nonnull public List<String> readUntilStatement() throws IOException, NoMoreInputException { while (true) { String line = reader.readLine(updateAndGetPrompt().renderedString()); if (line == null) { throw new NoMoreInputException(); } if (line.trim().isEmpty() && !statementParser.containsText()) { continue; } statementParser.parseMoreText(line + "\n"); if (statementParser.hasStatements()) { return statementParser.consumeStatements(); } } } }
InteractiveShellRunner implements ShellRunner, SignalHandler { @Nonnull public List<String> readUntilStatement() throws IOException, NoMoreInputException { while (true) { String line = reader.readLine(updateAndGetPrompt().renderedString()); if (line == null) { throw new NoMoreInputException(); } if (line.trim().isEmpty() && !statementParser.containsText()) { continue; } statementParser.parseMoreText(line + "\n"); if (statementParser.hasStatements()) { return statementParser.consumeStatements(); } } } 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 { @Nonnull public List<String> readUntilStatement() throws IOException, NoMoreInputException { while (true) { String line = reader.readLine(updateAndGetPrompt().renderedString()); if (line == null) { throw new NoMoreInputException(); } if (line.trim().isEmpty() && !statementParser.containsText()) { continue; } statementParser.parseMoreText(line + "\n"); if (statementParser.hasStatements()) { return statementParser.consumeStatements(); } } } 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 { @Nonnull public List<String> readUntilStatement() throws IOException, NoMoreInputException { while (true) { String line = reader.readLine(updateAndGetPrompt().renderedString()); if (line == null) { throw new NoMoreInputException(); } if (line.trim().isEmpty() && !statementParser.containsText()) { continue; } statementParser.parseMoreText(line + "\n"); if (statementParser.hasStatements()) { return statementParser.consumeStatements(); } } } 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);  }