use of org.neo4j.shell.log.AnsiLogger in project neo4j by neo4j.
the class CommandHelperTest method shouldIgnoreCaseForCommands.
@Test
public void shouldIgnoreCaseForCommands() {
// Given
AnsiLogger logger = new AnsiLogger(false);
CommandHelper commandHelper = new CommandHelper(logger, Historian.empty, new CypherShell(logger, PrettyConfig.DEFAULT, false, new ShellParameterMap()));
// When
Command begin = commandHelper.getCommand(":BEGIN");
// Then
assertTrue(begin instanceof Begin);
}
use of org.neo4j.shell.log.AnsiLogger 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.AnsiLogger 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.AnsiLogger in project neo4j by neo4j.
the class MainIntegrationTest method expectDatabaseUnavailable.
private void expectDatabaseUnavailable(Throwable e, String dbName) {
String msg = new AnsiLogger(false).getFormattedMessage(e);
assertThat(msg, anyOf(containsString("Database '" + dbName + "' is unavailable"), containsString("Database '" + dbName + "' unavailable"), containsString("Unable to get a routing table for database '" + dbName + "' because this database is unavailable")));
}
use of org.neo4j.shell.log.AnsiLogger in project neo4j by neo4j.
the class MainIntegrationTest method shouldFailIfInputFileDoesntExist.
@Test
public void shouldFailIfInputFileDoesntExist() {
// given
ByteArrayOutputStream out = new ByteArrayOutputStream();
Logger logger = new AnsiLogger(false, Format.VERBOSE, new PrintStream(out), new PrintStream(out));
// when
executeFileNonInteractively("what.cypher", logger);
// then
assertThat(out.toString(), containsString(format("what.cypher (No such file or directory)%n")));
}
Aggregations