Search in sources :

Example 6 with JLineShellComponent

use of org.springframework.shell.core.JLineShellComponent 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 7 with JLineShellComponent

use of org.springframework.shell.core.JLineShellComponent 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)

Example 8 with JLineShellComponent

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

the class MongoRyaShellIT method connectToInstance_noAuths.

@Test
public void connectToInstance_noAuths() throws IOException {
    final Bootstrap bootstrap = getTestBootstrap();
    final JLineShellComponent shell = getTestShell();
    // Connect to the Mongo instance.
    String cmd = RyaConnectionCommands.CONNECT_MONGO_CMD + " " + "--hostname " + super.conf.getMongoHostname() + " " + "--port " + super.conf.getMongoPort();
    shell.executeCommand(cmd);
    // Install an instance of rya.
    final String instanceName = "testInstance";
    final InstallConfiguration installConf = InstallConfiguration.builder().build();
    final ApplicationContext context = bootstrap.getApplicationContext();
    final InstallPrompt installPrompt = context.getBean(InstallPrompt.class);
    when(installPrompt.promptInstanceName()).thenReturn("testInstance");
    when(installPrompt.promptInstallConfiguration("testInstance")).thenReturn(installConf);
    when(installPrompt.promptVerified(instanceName, installConf)).thenReturn(true);
    CommandResult result = shell.executeCommand(RyaAdminCommands.INSTALL_CMD);
    assertTrue(result.isSuccess());
    // Connect to the instance that was just installed.
    cmd = RyaConnectionCommands.CONNECT_INSTANCE_CMD + " --instance " + instanceName;
    result = shell.executeCommand(cmd);
    assertTrue(result.isSuccess());
    // Verify the shell state indicates it is connected to an instance.
    final SharedShellState sharedState = context.getBean(SharedShellState.class);
    final ShellState state = sharedState.getShellState();
    assertEquals(ConnectionState.CONNECTED_TO_INSTANCE, state.getConnectionState());
}
Also used : JLineShellComponent(org.springframework.shell.core.JLineShellComponent) ApplicationContext(org.springframework.context.ApplicationContext) ShellState(org.apache.rya.shell.SharedShellState.ShellState) Bootstrap(org.springframework.shell.Bootstrap) InstallConfiguration(org.apache.rya.api.client.Install.InstallConfiguration) InstallPrompt(org.apache.rya.shell.util.InstallPrompt) CommandResult(org.springframework.shell.core.CommandResult) Test(org.junit.Test)

Example 9 with JLineShellComponent

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

the class MongoRyaShellIT method connectToInstance_instanceDoesNotExist.

@Test
public void connectToInstance_instanceDoesNotExist() throws IOException {
    final JLineShellComponent shell = getTestShell();
    // Connect to the Mongo instance.
    String cmd = RyaConnectionCommands.CONNECT_MONGO_CMD + " " + "--hostname " + super.conf.getMongoHostname() + " " + "--port " + super.conf.getMongoPort();
    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) CommandResult(org.springframework.shell.core.CommandResult) Test(org.junit.Test)

Example 10 with JLineShellComponent

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

the class MongoRyaShellIT 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