use of org.springframework.shell.core.CommandResult 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());
}
use of org.springframework.shell.core.CommandResult in project tutorials by eugenp.
the class SimpleCLIIntegrationTest method givenCommandConfig_whenExecutingWebSaveCommand_thenCorrectResult.
@Test
public void givenCommandConfig_whenExecutingWebSaveCommand_thenCorrectResult() {
shell.executeCommand("admin-enable");
final CommandResult result = shell.executeCommand("web-save --url https://www.google.com --out contents.txt");
Assert.assertArrayEquals(new boolean[] { result.isSuccess(), new File("contents.txt").exists() }, new boolean[] { true, true });
}
use of org.springframework.shell.core.CommandResult in project tutorials by eugenp.
the class SimpleCLIIntegrationTest method givenCommandConfig_whenExecutingWebGetCommandWithDefaultArgument_thenCorrectResult.
@Test
public void givenCommandConfig_whenExecutingWebGetCommandWithDefaultArgument_thenCorrectResult() {
final CommandResult result = shell.executeCommand("web-get https://www.google.com");
Assert.assertEquals(result.isSuccess(), true);
}
use of org.springframework.shell.core.CommandResult in project tutorials by eugenp.
the class SimpleCLIIntegrationTest method givenCommandConfig_whenWebSaveCommandExecutedNoOutArgument_thenError.
@Test
public void givenCommandConfig_whenWebSaveCommandExecutedNoOutArgument_thenError() {
shell.executeCommand("admin-enable");
final CommandResult resultWebSave = shell.executeCommand("web-save --url https://www.google.com");
Assert.assertEquals(resultWebSave.isSuccess(), false);
}
use of org.springframework.shell.core.CommandResult 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());
}
Aggregations