use of org.apache.rya.shell.util.InstallPrompt in project incubator-rya by apache.
the class AccumuloRyaConnectionCommandsIT method connectToInstance.
@Test
public void connectToInstance() 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();
CommandResult result = shell.executeCommand(cmd);
// Install an instance of rya.
final String instanceName = "testInstance";
final InstallConfiguration installConf = InstallConfiguration.builder().build();
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);
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.apache.rya.shell.util.InstallPrompt in project incubator-rya by apache.
the class RyaAdminCommandsTest method install.
@Test
public void install() throws DuplicateInstanceNameException, RyaClientException, IOException {
// Mock the object that performs the install operation.
final Install mockInstall = mock(Install.class);
final RyaClient mockCommands = mock(RyaClient.class);
when(mockCommands.getInstall()).thenReturn(mockInstall);
final SharedShellState state = new SharedShellState();
state.connectedToAccumulo(mock(AccumuloConnectionDetails.class), mockCommands);
// Execute the command.
final String instanceName = "unitTests";
final InstallConfiguration installConfig = InstallConfiguration.builder().setEnableGeoIndex(true).setEnablePcjIndex(true).build();
final InstallPrompt mockInstallPrompt = mock(InstallPrompt.class);
when(mockInstallPrompt.promptInstanceName()).thenReturn(instanceName);
when(mockInstallPrompt.promptInstallConfiguration(instanceName)).thenReturn(installConfig);
when(mockInstallPrompt.promptVerified(eq(instanceName), eq(installConfig))).thenReturn(true);
final RyaAdminCommands commands = new RyaAdminCommands(state, mockInstallPrompt, mock(SparqlPrompt.class), mock(UninstallPrompt.class));
final String message = commands.install();
// Verify the values that were provided to the command were passed through to the Install.
verify(mockInstall).install(eq(instanceName), eq(installConfig));
// Verify a message is returned that indicates the success of the operation.
final String expected = "The Rya instance named 'unitTests' has been installed.";
assertEquals(expected, message);
}
use of org.apache.rya.shell.util.InstallPrompt 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.apache.rya.shell.util.InstallPrompt in project incubator-rya by apache.
the class RyaAdminCommandsTest method installWithMongoParameters.
@Test
public void installWithMongoParameters() throws DuplicateInstanceNameException, RyaClientException, IOException {
// Mock the object that performs the install operation.
final Install mockInstall = mock(Install.class);
final RyaClient mockCommands = mock(RyaClient.class);
when(mockCommands.getInstall()).thenReturn(mockInstall);
final SharedShellState state = new SharedShellState();
state.connectedToMongo(mock(MongoConnectionDetails.class), mockCommands);
final String instanceName = "unitTests";
final boolean enableFreeTextIndex = false;
final boolean enableTemporalIndex = false;
final boolean enablePcjIndex = false;
// Execute the command.
final InstallConfiguration installConfig = InstallConfiguration.builder().setEnableFreeTextIndex(enableFreeTextIndex).setEnableTemporalIndex(enableTemporalIndex).setEnablePcjIndex(enablePcjIndex).build();
final InstallPrompt mockInstallPrompt = mock(InstallPrompt.class);
when(mockInstallPrompt.promptInstanceName()).thenReturn(instanceName);
when(mockInstallPrompt.promptInstallConfiguration(instanceName)).thenReturn(installConfig);
when(mockInstallPrompt.promptVerified(eq(instanceName), eq(installConfig))).thenReturn(true);
final RyaAdminCommands commands = new RyaAdminCommands(state, mockInstallPrompt, mock(SparqlPrompt.class), mock(UninstallPrompt.class));
final String message = commands.installWithMongoParameters(instanceName, enableFreeTextIndex, enableTemporalIndex, enablePcjIndex);
// Verify the values that were provided to the command were passed through to the Install.
verify(mockInstall).install(eq(instanceName), eq(installConfig));
// Verify a message is returned that indicates the success of the operation.
final String expected = "The Rya instance named 'unitTests' has been installed.";
assertEquals(expected, message);
}
use of org.apache.rya.shell.util.InstallPrompt in project incubator-rya by apache.
the class RyaAdminCommandsTest method installWithAccumuloParameters.
@Test
public void installWithAccumuloParameters() throws DuplicateInstanceNameException, RyaClientException, IOException {
// Mock the object that performs the install operation.
final Install mockInstall = mock(Install.class);
final RyaClient mockCommands = mock(RyaClient.class);
when(mockCommands.getInstall()).thenReturn(mockInstall);
final SharedShellState state = new SharedShellState();
state.connectedToAccumulo(mock(AccumuloConnectionDetails.class), mockCommands);
final String instanceName = "unitTests";
final boolean enableTableHashPrefix = false;
final boolean enableEntityCentricIndex = true;
final boolean enableFreeTextIndex = false;
final boolean enableTemporalIndex = false;
final boolean enablePcjIndex = true;
final String fluoPcjAppName = instanceName + "pcj_updater";
// Execute the command.
final InstallConfiguration installConfig = InstallConfiguration.builder().setEnableTableHashPrefix(enableTableHashPrefix).setEnableEntityCentricIndex(enableEntityCentricIndex).setEnableFreeTextIndex(enableFreeTextIndex).setEnableTemporalIndex(enableTemporalIndex).setEnablePcjIndex(enablePcjIndex).setFluoPcjAppName(fluoPcjAppName).build();
final InstallPrompt mockInstallPrompt = mock(InstallPrompt.class);
when(mockInstallPrompt.promptInstanceName()).thenReturn(instanceName);
when(mockInstallPrompt.promptInstallConfiguration(instanceName)).thenReturn(installConfig);
when(mockInstallPrompt.promptVerified(eq(instanceName), eq(installConfig))).thenReturn(true);
final RyaAdminCommands commands = new RyaAdminCommands(state, mockInstallPrompt, mock(SparqlPrompt.class), mock(UninstallPrompt.class));
final String message = commands.installWithAccumuloParameters(instanceName, enableTableHashPrefix, enableEntityCentricIndex, enableFreeTextIndex, enableTemporalIndex, enablePcjIndex, fluoPcjAppName);
// Verify the values that were provided to the command were passed through to the Install.
verify(mockInstall).install(eq(instanceName), eq(installConfig));
// Verify a message is returned that indicates the success of the operation.
final String expected = "The Rya instance named 'unitTests' has been installed.";
assertEquals(expected, message);
}
Aggregations