Search in sources :

Example 6 with CommandResult

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

the class AccumuloRyaConnectionCommandsIT method connectAccumulo.

@Test
public void connectAccumulo() 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());
    // Execute the connect command.
    final String cmd = RyaConnectionCommands.CONNECT_ACCUMULO_CMD + " " + "--username root " + "--instanceName " + cluster.getInstanceName() + " " + "--zookeepers " + cluster.getZooKeepers();
    final CommandResult connectResult = shell.executeCommand(cmd);
    // Ensure the connection was successful.
    assertTrue(connectResult.isSuccess());
}
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 7 with CommandResult

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

the class AccumuloRyaConnectionCommandsIT method connectAccumulo_wrongCredentials.

@Test
public void connectAccumulo_wrongCredentials() throws IOException {
    final MiniAccumuloCluster cluster = getCluster();
    final Bootstrap bootstrap = getTestBootstrap();
    final JLineShellComponent shell = getTestShell();
    // Mock the user entering the wrong password.
    final ApplicationContext context = bootstrap.getApplicationContext();
    final PasswordPrompt mockPrompt = context.getBean(PasswordPrompt.class);
    when(mockPrompt.getPassword()).thenReturn("asjifo[ijwa".toCharArray());
    // Execute the command
    final String cmd = RyaConnectionCommands.CONNECT_ACCUMULO_CMD + " " + "--username root " + "--instanceName " + cluster.getInstanceName() + " " + "--zookeepers " + cluster.getZooKeepers();
    final CommandResult connectResult = shell.executeCommand(cmd);
    // Ensure the command failed.
    assertFalse(connectResult.isSuccess());
}
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 8 with CommandResult

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

the class AccumuloRyaConnectionCommandsIT method connectToInstance_instanceDoesNotExist.

@Test
public void connectToInstance_instanceDoesNotExist() 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.
    String cmd = RyaConnectionCommands.CONNECT_ACCUMULO_CMD + " " + "--username root " + "--instanceName " + cluster.getInstanceName() + " " + "--zookeepers " + cluster.getZooKeepers();
    shell.executeCommand(cmd);
    // Try to connect to a non-existing instance.
    cmd = RyaConnectionCommands.CONNECT_INSTANCE_CMD + " --instance doesNotExist";
    final CommandResult result = shell.executeCommand(cmd);
    assertFalse(result.isSuccess());
}
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 9 with CommandResult

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

the class MongoRyaShellIT method printConnectionDetails_connectedToMongo_noAuths.

@Test
public void printConnectionDetails_connectedToMongo_noAuths() 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();
    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";
    assertEquals(expected, msg);
}
Also used : JLineShellComponent(org.springframework.shell.core.JLineShellComponent) CommandResult(org.springframework.shell.core.CommandResult) Test(org.junit.Test)

Example 10 with CommandResult

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

the class MongoRyaShellIT method disconnect.

@Test
public void disconnect() 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();
    shell.executeCommand(cmd);
    // Disconnect from it.
    final CommandResult disconnectResult = shell.executeCommand(RyaConnectionCommands.DISCONNECT_COMMAND_NAME_CMD);
    assertTrue(disconnectResult.isSuccess());
}
Also used : JLineShellComponent(org.springframework.shell.core.JLineShellComponent) CommandResult(org.springframework.shell.core.CommandResult) Test(org.junit.Test)

Aggregations

CommandResult (org.springframework.shell.core.CommandResult)22 Test (org.junit.Test)19 JLineShellComponent (org.springframework.shell.core.JLineShellComponent)14 Bootstrap (org.springframework.shell.Bootstrap)11 ApplicationContext (org.springframework.context.ApplicationContext)8 PasswordPrompt (org.apache.rya.shell.util.PasswordPrompt)7 MiniAccumuloCluster (org.apache.accumulo.minicluster.MiniAccumuloCluster)6 LensClient (org.apache.lens.client.LensClient)3 JLineShell (org.springframework.shell.core.JLineShell)3 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 File (java.io.File)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1 InterpreterResult (org.apache.zeppelin.interpreter.InterpreterResult)1