use of org.neo4j.shell.commands.CommandHelper in project neo4j by neo4j.
the class MainIntegrationTest method switchingToUnavailableDatabaseIfInteractive.
@Test
public void switchingToUnavailableDatabaseIfInteractive() throws Exception {
shell.setCommandHelper(new CommandHelper(mock(Logger.class), Historian.empty, shell));
inputBuffer.put(String.format("neo4j%nneo%n").getBytes());
assertEquals("", connectionConfig.username());
assertEquals("", connectionConfig.password());
// when
main.connectMaybeInteractively(shell, connectionConfig, true, true, true);
// Multiple databases are only available from 4.0
assumeTrue(majorVersion(shell.getServerVersion()) >= 4);
// then
// should be connected
assertTrue(shell.isConnected());
// should have prompted and set the username and password
String expectedLoginOutput = format("username: neo4j%npassword: ***%n");
assertEquals(expectedLoginOutput, baos.toString());
assertEquals("neo4j", connectionConfig.username());
assertEquals("neo", connectionConfig.password());
// Stop the default database
shell.execute(":use " + SYSTEM_DB_NAME);
shell.execute("STOP DATABASE " + DatabaseManager.DEFAULT_DEFAULT_DB_NAME);
try {
// Should get exception that database is unavailable when trying to connect
shell.execute(":use " + DatabaseManager.DEFAULT_DEFAULT_DB_NAME);
fail("No exception thrown");
} catch (TransientException | ServiceUnavailableException e) {
expectDatabaseUnavailable(e, "neo4j");
} finally {
// Start the default database again
ensureDefaultDatabaseStarted();
}
}
use of org.neo4j.shell.commands.CommandHelper in project neo4j by neo4j.
the class MainIntegrationTest method interactiveShell.
private CypherShell interactiveShell(LinePrinter linePrinter) throws Exception {
PrettyConfig prettyConfig = new PrettyConfig(new CliArgs());
CypherShell shell = new CypherShell(linePrinter, prettyConfig, true, new ShellParameterMap());
main.connectMaybeInteractively(shell, connectionConfig, true, true, true);
shell.setCommandHelper(new CommandHelper(mock(Logger.class), Historian.empty, shell));
return shell;
}
use of org.neo4j.shell.commands.CommandHelper in project neo4j by neo4j.
the class MainIntegrationTest method doesNotStartWhenDefaultDatabaseUnavailableIfInteractive.
@Test
public void doesNotStartWhenDefaultDatabaseUnavailableIfInteractive() throws Exception {
shell.setCommandHelper(new CommandHelper(mock(Logger.class), Historian.empty, shell));
inputBuffer.put(String.format("neo4j%nneo%n").getBytes());
assertEquals("", connectionConfig.username());
assertEquals("", connectionConfig.password());
// when
main.connectMaybeInteractively(shell, connectionConfig, true, true, true);
// Multiple databases are only available from 4.0
assumeTrue(majorVersion(shell.getServerVersion()) >= 4);
// then
// should be connected
assertTrue(shell.isConnected());
// should have prompted and set the username and password
String expectedLoginOutput = format("username: neo4j%npassword: ***%n");
assertEquals(expectedLoginOutput, baos.toString());
assertEquals("neo4j", connectionConfig.username());
assertEquals("neo", connectionConfig.password());
// Stop the default database
shell.execute(":use " + SYSTEM_DB_NAME);
shell.execute("STOP DATABASE " + DatabaseManager.DEFAULT_DEFAULT_DB_NAME);
try {
shell.disconnect();
// Should get exception that database is unavailable when trying to connect
main.connectMaybeInteractively(shell, connectionConfig, true, true, true);
fail("No exception thrown");
} catch (TransientException | ServiceUnavailableException e) {
expectDatabaseUnavailable(e, "neo4j");
} finally {
// Start the default database again
ensureDefaultDatabaseStarted();
}
}
use of org.neo4j.shell.commands.CommandHelper in project neo4j by neo4j.
the class MainIntegrationTest method getVersionAndCreateUserWithPasswordChangeRequired.
private int getVersionAndCreateUserWithPasswordChangeRequired() throws Exception {
shell.setCommandHelper(new CommandHelper(mock(Logger.class), Historian.empty, shell));
main.connectMaybeInteractively(shell, connectionConfig, true, true, true);
String expectedLoginOutput = format("username: neo4j%npassword: ***%n");
assertEquals(expectedLoginOutput, baos.toString());
ensureUser();
int majorVersion = majorVersion(shell.getServerVersion());
shell.disconnect();
return majorVersion;
}
use of org.neo4j.shell.commands.CommandHelper 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);
}
Aggregations