use of org.neo4j.shell.cli.CliArgs in project neo4j by neo4j.
the class MainIntegrationTest method executeFileNonInteractively.
private String executeFileNonInteractively(String filename, Logger logger) {
CliArgs cliArgs = new CliArgs();
cliArgs.setUsername(USER, "");
cliArgs.setPassword(PASSWORD, "");
cliArgs.setInputFilename(filename);
return executeNonInteractively(cliArgs, logger);
}
use of org.neo4j.shell.cli.CliArgs in project neo4j by neo4j.
the class MainIntegrationTest method startsAgainstSystemDatabaseWhenDefaultDatabaseUnavailableIfInteractive.
@Test
public void startsAgainstSystemDatabaseWhenDefaultDatabaseUnavailableIfInteractive() throws Exception {
shell.setCommandHelper(new CommandHelper(mock(Logger.class), Historian.empty, shell));
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();
// Connect to system database
CliArgs cliArgs = new CliArgs();
cliArgs.setUsername("neo4j", "");
cliArgs.setPassword("neo", "");
cliArgs.setDatabase("system");
ShellAndConnection sac = getShell(cliArgs);
// Use the new shell and connection config from here on
shell = sac.shell;
connectionConfig = sac.connectionConfig;
main.connectMaybeInteractively(shell, connectionConfig, true, false, true);
// then
assertTrue(shell.isConnected());
} finally {
// Start the default database again
ensureDefaultDatabaseStarted();
}
}
use of org.neo4j.shell.cli.CliArgs in project neo4j by neo4j.
the class MainIntegrationTest method args.
private CliArgs args(String db, String user, String pass, String cypher) {
CliArgs cliArgs = new CliArgs();
cliArgs.setUsername(user, "");
cliArgs.setPassword(pass, "");
cliArgs.setDatabase(db);
cliArgs.setCypher(cypher);
return cliArgs;
}
use of org.neo4j.shell.cli.CliArgs in project neo4j by neo4j.
the class MainIntegrationTest method shouldAskForCredentialsWhenConnectingWithAFile.
@Test
public void shouldAskForCredentialsWhenConnectingWithAFile() throws Exception {
// given
assertEquals("", connectionConfig.username());
assertEquals("", connectionConfig.password());
// when
CliArgs cliArgs = new CliArgs();
cliArgs.setInputFilename(fileFromResource("single.cypher"));
ShellAndConnection sac = getShell(cliArgs);
CypherShell shell = sac.shell;
ConnectionConfig connectionConfig = sac.connectionConfig;
main.connectMaybeInteractively(shell, connectionConfig, true, true, true);
// then we should have prompted and set the username and password
assertEquals(format("username: neo4j%npassword: ***%n"), baos.toString());
assertEquals("neo4j", connectionConfig.username());
assertEquals("neo", connectionConfig.password());
}
Aggregations