Search in sources :

Example 1 with CliArgs

use of org.neo4j.shell.cli.CliArgs 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;
}
Also used : PrettyConfig(org.neo4j.shell.prettyprint.PrettyConfig) CommandHelper(org.neo4j.shell.commands.CommandHelper) CliArgs(org.neo4j.shell.cli.CliArgs)

Example 2 with CliArgs

use of org.neo4j.shell.cli.CliArgs in project neo4j by neo4j.

the class MainIntegrationTest method ensureDefaultDatabaseStarted.

private void ensureDefaultDatabaseStarted() throws Exception {
    CliArgs cliArgs = new CliArgs();
    cliArgs.setUsername("neo4j", "");
    cliArgs.setPassword("neo", "");
    cliArgs.setDatabase("system");
    ShellAndConnection sac = getShell(cliArgs);
    main.connectMaybeInteractively(sac.shell, sac.connectionConfig, true, false, true);
    sac.shell.execute("START DATABASE " + DatabaseManager.DEFAULT_DEFAULT_DB_NAME);
}
Also used : CliArgs(org.neo4j.shell.cli.CliArgs)

Example 3 with CliArgs

use of org.neo4j.shell.cli.CliArgs in project neo4j by neo4j.

the class MainIntegrationTest method setup.

@Before
public void setup() {
    // given
    inputBuffer = ByteBuffer.allocate(256);
    inputBuffer.put(inputString.getBytes());
    inputStream = new ByteArrayInputStream(inputBuffer.array());
    baos = new ByteArrayOutputStream();
    printStream = new PrintStream(baos);
    main = new Main(inputStream, printStream);
    cliArgs = new CliArgs();
    cliArgs.setUsername("", "");
    cliArgs.setPassword("", "");
    ShellAndConnection sac = getShell(cliArgs);
    shell = sac.shell;
    connectionConfig = sac.connectionConfig;
}
Also used : PrintStream(java.io.PrintStream) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) CliArgs(org.neo4j.shell.cli.CliArgs) Before(org.junit.Before)

Example 4 with CliArgs

use of org.neo4j.shell.cli.CliArgs in project neo4j by neo4j.

the class MainIntegrationTest method wrongPortWithBolt.

@Test
public void wrongPortWithBolt() {
    // given
    CliArgs cliArgs = new CliArgs();
    cliArgs.setScheme("bolt", "");
    cliArgs.setPort(1234);
    ShellAndConnection sac = getShell(cliArgs);
    CypherShell shell = sac.shell;
    ConnectionConfig connectionConfig = sac.connectionConfig;
    var exception = assertThrows(ServiceUnavailableException.class, () -> main.connectMaybeInteractively(shell, connectionConfig, true, true, true));
    var expectedMesssage = "Unable to connect to localhost:1234, ensure the database is running and that there is a working network connection to it";
    assertThat(exception.getMessage(), containsString(expectedMesssage));
}
Also used : CliArgs(org.neo4j.shell.cli.CliArgs) Test(org.junit.Test)

Example 5 with CliArgs

use of org.neo4j.shell.cli.CliArgs in project neo4j by neo4j.

the class MainIntegrationTest method wrongPortWithNeo4j.

@Test
public void wrongPortWithNeo4j() {
    // given
    CliArgs cliArgs = new CliArgs();
    cliArgs.setScheme("neo4j", "");
    cliArgs.setPort(1234);
    ShellAndConnection sac = getShell(cliArgs);
    CypherShell shell = sac.shell;
    ConnectionConfig connectionConfig = sac.connectionConfig;
    // The error message here may be subject to change and is not stable across versions so let us not assert on it
    assertThrows(ServiceUnavailableException.class, () -> main.connectMaybeInteractively(shell, connectionConfig, true, true, true));
}
Also used : CliArgs(org.neo4j.shell.cli.CliArgs) Test(org.junit.Test)

Aggregations

CliArgs (org.neo4j.shell.cli.CliArgs)14 Test (org.junit.Test)8 PrintStream (java.io.PrintStream)3 CommandHelper (org.neo4j.shell.commands.CommandHelper)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1 Before (org.junit.Before)1 ShellRunner.getShellRunner (org.neo4j.shell.ShellRunner.getShellRunner)1 NonInteractiveShellRunner (org.neo4j.shell.cli.NonInteractiveShellRunner)1 Logger (org.neo4j.shell.log.Logger)1 PrettyConfig (org.neo4j.shell.prettyprint.PrettyConfig)1