Search in sources :

Example 11 with JLineShellComponent

use of org.springframework.shell.core.JLineShellComponent in project incubator-rya by apache.

the class MongoRyaShellIT method connectMongo_noAuth.

@Test
public void connectMongo_noAuth() throws IOException {
    final JLineShellComponent shell = getTestShell();
    // Connect to the Mongo instance.
    final String cmd = RyaConnectionCommands.CONNECT_MONGO_CMD + " " + "--hostname " + super.conf.getMongoHostname() + " " + "--port " + super.conf.getMongoPort();
    final CommandResult connectResult = shell.executeCommand(cmd);
    // Ensure the connection was successful.
    assertTrue(connectResult.isSuccess());
}
Also used : JLineShellComponent(org.springframework.shell.core.JLineShellComponent) CommandResult(org.springframework.shell.core.CommandResult) Test(org.junit.Test)

Example 12 with JLineShellComponent

use of org.springframework.shell.core.JLineShellComponent in project incubator-rya by apache.

the class MongoRyaShellIT method printConnectionDetails_connectedToMongo_auths.

@Test
public void printConnectionDetails_connectedToMongo_auths() throws IOException {
    final Bootstrap bootstrap = getTestBootstrap();
    final JLineShellComponent shell = getTestShell();
    // Mock the user entering the correct password.
    final ApplicationContext context = bootstrap.getApplicationContext();
    final PasswordPrompt mockPrompt = context.getBean(PasswordPrompt.class);
    when(mockPrompt.getPassword()).thenReturn("password".toCharArray());
    // Connect to the Mongo instance.
    final String cmd = RyaConnectionCommands.CONNECT_MONGO_CMD + " " + "--hostname " + super.conf.getMongoHostname() + " " + "--port " + super.conf.getMongoPort() + " " + "--username bob";
    shell.executeCommand(cmd);
    // Run the print connection details command.
    final CommandResult printResult = shell.executeCommand(RyaConnectionCommands.PRINT_CONNECTION_DETAILS_CMD);
    final String msg = (String) printResult.getResult();
    final String expected = "The shell is connected to an instance of MongoDB using the following parameters:\n" + "    Hostname: " + super.conf.getMongoHostname() + "\n" + "    Port: " + super.conf.getMongoPort() + "\n" + "    Username: bob\n";
    assertEquals(expected, msg);
}
Also used : JLineShellComponent(org.springframework.shell.core.JLineShellComponent) ApplicationContext(org.springframework.context.ApplicationContext) Bootstrap(org.springframework.shell.Bootstrap) PasswordPrompt(org.apache.rya.shell.util.PasswordPrompt) CommandResult(org.springframework.shell.core.CommandResult) Test(org.junit.Test)

Example 13 with JLineShellComponent

use of org.springframework.shell.core.JLineShellComponent in project incubator-rya by apache.

the class AccumuloRyaConnectionCommandsIT method printConnectionDetails_connectedToAccumulo.

@Test
public void printConnectionDetails_connectedToAccumulo() throws IOException {
    final MiniAccumuloCluster cluster = getCluster();
    final Bootstrap bootstrap = getTestBootstrap();
    final JLineShellComponent shell = getTestShell();
    // Mock the user entering the correct password.
    final ApplicationContext context = bootstrap.getApplicationContext();
    final PasswordPrompt mockPrompt = context.getBean(PasswordPrompt.class);
    when(mockPrompt.getPassword()).thenReturn("password".toCharArray());
    // Connect to the mini accumulo instance.
    final String cmd = RyaConnectionCommands.CONNECT_ACCUMULO_CMD + " " + "--username root " + "--instanceName " + cluster.getInstanceName() + " " + "--zookeepers " + cluster.getZooKeepers();
    shell.executeCommand(cmd);
    // Run the print connection details command.
    final CommandResult printResult = shell.executeCommand(RyaConnectionCommands.PRINT_CONNECTION_DETAILS_CMD);
    final String msg = (String) printResult.getResult();
    final String expected = "The shell is connected to an instance of Accumulo using the following parameters:\n" + "    Username: root\n" + "    Instance Name: " + cluster.getInstanceName() + "\n" + "    Zookeepers: " + cluster.getZooKeepers();
    assertEquals(expected, msg);
}
Also used : JLineShellComponent(org.springframework.shell.core.JLineShellComponent) ApplicationContext(org.springframework.context.ApplicationContext) MiniAccumuloCluster(org.apache.accumulo.minicluster.MiniAccumuloCluster) Bootstrap(org.springframework.shell.Bootstrap) PasswordPrompt(org.apache.rya.shell.util.PasswordPrompt) CommandResult(org.springframework.shell.core.CommandResult) Test(org.junit.Test)

Example 14 with JLineShellComponent

use of org.springframework.shell.core.JLineShellComponent in project incubator-rya by apache.

the class AccumuloRyaConnectionCommandsIT method printConnectionDetails_notConnected.

@Test
public void printConnectionDetails_notConnected() {
    final JLineShellComponent shell = getTestShell();
    // Run the print connection details command.
    final CommandResult printResult = shell.executeCommand(RyaConnectionCommands.PRINT_CONNECTION_DETAILS_CMD);
    final String msg = (String) printResult.getResult();
    final String expected = "The shell is not connected to anything.";
    assertEquals(expected, msg);
}
Also used : JLineShellComponent(org.springframework.shell.core.JLineShellComponent) CommandResult(org.springframework.shell.core.CommandResult) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)14 CommandResult (org.springframework.shell.core.CommandResult)14 JLineShellComponent (org.springframework.shell.core.JLineShellComponent)14 ApplicationContext (org.springframework.context.ApplicationContext)8 Bootstrap (org.springframework.shell.Bootstrap)8 PasswordPrompt (org.apache.rya.shell.util.PasswordPrompt)7 MiniAccumuloCluster (org.apache.accumulo.minicluster.MiniAccumuloCluster)6 InstallConfiguration (org.apache.rya.api.client.Install.InstallConfiguration)2 ShellState (org.apache.rya.shell.SharedShellState.ShellState)2 InstallPrompt (org.apache.rya.shell.util.InstallPrompt)2