use of org.neo4j.shell.log.Logger in project neo4j by neo4j.
the class InteractiveShellRunnerTest method setupInteractiveTestShellRunner.
private TestInteractiveShellRunner setupInteractiveTestShellRunner(String input) throws Exception {
// NOTE: Tests using this will test a bit more of the stack using OfflineTestShell
ByteArrayOutputStream output = new ByteArrayOutputStream();
ByteArrayOutputStream error = new ByteArrayOutputStream();
BoltStateHandler mockedBoltStateHandler = mock(BoltStateHandler.class);
when(mockedBoltStateHandler.getProtocolVersion()).thenReturn("");
final PrettyPrinter mockedPrettyPrinter = mock(PrettyPrinter.class);
Logger logger = new AnsiLogger(false, Format.VERBOSE, new PrintStream(output), new PrintStream(error));
OfflineTestShell offlineTestShell = new OfflineTestShell(logger, mockedBoltStateHandler, mockedPrettyPrinter);
CommandHelper commandHelper = new CommandHelper(logger, Historian.empty, offlineTestShell);
offlineTestShell.setCommandHelper(commandHelper);
InputStream inputStream = new ByteArrayInputStream(input.getBytes());
InteractiveShellRunner runner = new InteractiveShellRunner(offlineTestShell, offlineTestShell, offlineTestShell, logger, new ShellStatementParser(), inputStream, historyFile, userMessagesHandler, connectionConfig);
return new TestInteractiveShellRunner(runner, output, error, mockedBoltStateHandler);
}
use of org.neo4j.shell.log.Logger in project neo4j by neo4j.
the class Main method startShell.
void startShell(@Nonnull CliArgs cliArgs) {
if (cliArgs.getVersion()) {
out.println("Cypher-Shell " + Build.version());
}
if (cliArgs.getDriverVersion()) {
out.println("Neo4j Driver " + Build.driverVersion());
}
if (cliArgs.getVersion() || cliArgs.getDriverVersion()) {
return;
}
Logger logger = new AnsiLogger(cliArgs.getDebugMode());
PrettyConfig prettyConfig = new PrettyConfig(cliArgs);
CypherShell shell = new CypherShell(logger, prettyConfig, ShellRunner.shouldBeInteractive(cliArgs), cliArgs.getParameters());
int exitCode = runShell(cliArgs, shell, logger);
System.exit(exitCode);
}
use of org.neo4j.shell.log.Logger in project neo4j by neo4j.
the class InteractiveShellRunnerTest method setup.
@Before
public void setup() throws Exception {
statementParser = new ShellStatementParser();
logger = mock(Logger.class);
cmdExecuter = mock(StatementExecuter.class);
txHandler = mock(TransactionHandler.class);
databaseManager = mock(DatabaseManager.class);
connectionConfig = mock(ConnectionConfig.class);
historyFile = temp.newFile();
badLineError = new ClientException("Found a bad line");
userMessagesHandler = mock(UserMessagesHandler.class);
when(databaseManager.getActualDatabaseAsReportedByServer()).thenReturn("mydb");
when(userMessagesHandler.getWelcomeMessage()).thenReturn("Welcome to cypher-shell!");
when(userMessagesHandler.getExitMessage()).thenReturn("Exit message");
when(connectionConfig.username()).thenReturn("myusername");
doThrow(badLineError).when(cmdExecuter).execute(contains("bad"));
doReturn(System.out).when(logger).getOutputStream();
}
use of org.neo4j.shell.log.Logger in project neo4j by neo4j.
the class ParamsTest method setup.
@Before
public void setup() throws CommandException {
vars = new HashMap<>();
logger = mock(Logger.class);
ParameterMap shell = mock(ParameterMap.class);
when(shell.getAllAsUserInput()).thenReturn(vars);
cmd = new Params(logger, shell);
}
use of org.neo4j.shell.log.Logger in project neo4j by neo4j.
the class MainIntegrationTest method shouldHandleInvalidCypherFromFile.
@Test
public void shouldHandleInvalidCypherFromFile() {
// given
Logger logger = mock(Logger.class);
// when
String actual = executeFileNonInteractively(fileFromResource("invalid.cypher"), logger);
// then we print the first valid row
assertEquals(format("result%n42%n"), actual);
// and print errors to the error log
verify(logger).printError(any(ClientException.class));
}
Aggregations