Search in sources :

Example 6 with CliArgs

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

the class MainIntegrationTest method shouldNotBePromptedIfRunningWithExplicitNonInteractiveCypherThatDoesntUpdatePassword.

@Test
public void shouldNotBePromptedIfRunningWithExplicitNonInteractiveCypherThatDoesntUpdatePassword() throws Exception {
    // given a user that require a password change
    int majorVersion = getVersionAndCreateUserWithPasswordChangeRequired();
    // when
    assumeTrue(majorVersion >= 4);
    // when interactively asked for a password use this
    inputBuffer.put(String.format("pass2%n").getBytes());
    baos.reset();
    CliArgs args = args(DEFAULT_DEFAULT_DB_NAME, "foo", "pass", "MATCH (n) RETURN n");
    args.setNonInteractive(true);
    assertEquals(EXIT_FAILURE, main.runShell(args, shell, mock(Logger.class)));
}
Also used : CliArgs(org.neo4j.shell.cli.CliArgs) Test(org.junit.Test)

Example 7 with CliArgs

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

the class ShellRunnerTest method inputIsNonInteractiveIfForced.

@Test
public void inputIsNonInteractiveIfForced() throws Exception {
    CliArgs args = new CliArgs();
    args.setNonInteractive(true);
    ShellRunner runner = getShellRunner(args, mock(CypherShell.class), mock(Logger.class), connectionConfig);
    assertTrue("Should be non-interactive shell runner when forced", runner instanceof NonInteractiveShellRunner);
}
Also used : Logger(org.neo4j.shell.log.Logger) ShellRunner.getShellRunner(org.neo4j.shell.ShellRunner.getShellRunner) NonInteractiveShellRunner(org.neo4j.shell.cli.NonInteractiveShellRunner) NonInteractiveShellRunner(org.neo4j.shell.cli.NonInteractiveShellRunner) CliArgs(org.neo4j.shell.cli.CliArgs) Test(org.junit.Test)

Example 8 with CliArgs

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

the class Main method main.

public static void main(String[] args) {
    CliArgs cliArgs = CliArgHelper.parse(args);
    // CliArgs has already printed errors.
    if (cliArgs == null) {
        System.exit(1);
    }
    Main main = new Main();
    main.startShell(cliArgs);
}
Also used : CliArgs(org.neo4j.shell.cli.CliArgs)

Example 9 with CliArgs

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

the class MainTest method printsVersionAndExits.

@Test
public void printsVersionAndExits() {
    CliArgs args = new CliArgs();
    args.setVersion(true);
    PrintStream printStream = mock(PrintStream.class);
    Main main = new Main(System.in, printStream);
    main.startShell(args);
    ArgumentCaptor<String> argument = ArgumentCaptor.forClass(String.class);
    verify(printStream).println(argument.capture());
    assertTrue(argument.getValue().matches("Cypher-Shell \\d+\\.\\d+\\.\\d+.*"));
}
Also used : PrintStream(java.io.PrintStream) CliArgs(org.neo4j.shell.cli.CliArgs) Test(org.junit.Test)

Example 10 with CliArgs

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

the class MainTest method printsDriverVersionAndExits.

@Test
public void printsDriverVersionAndExits() {
    CliArgs args = new CliArgs();
    args.setDriverVersion(true);
    PrintStream printStream = mock(PrintStream.class);
    Main main = new Main(System.in, printStream);
    main.startShell(args);
    ArgumentCaptor<String> argument = ArgumentCaptor.forClass(String.class);
    verify(printStream).println(argument.capture());
    assertTrue(argument.getValue().matches("Neo4j Driver \\d+\\.\\d+\\.\\d+.*"));
}
Also used : PrintStream(java.io.PrintStream) 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