use of org.apache.geode.management.internal.cli.result.CommandResult in project geode by apache.
the class ClusterConfigurationDUnitTest method executeAndVerifyCommand.
private CommandResult executeAndVerifyCommand(String commandString) {
CommandResult cmdResult = executeCommand(commandString);
org.apache.geode.test.dunit.LogWriterUtils.getLogWriter().info("Command : " + commandString);
org.apache.geode.test.dunit.LogWriterUtils.getLogWriter().info("Command Result : " + commandResultToString(cmdResult));
assertEquals(Status.OK, cmdResult.getStatus());
assertFalse(cmdResult.failedToPersist());
return cmdResult;
}
use of org.apache.geode.management.internal.cli.result.CommandResult in project geode by apache.
the class ClusterConfigurationIndexWithFromClauseDUnitTest method verifyIndexRecreated.
private void verifyIndexRecreated(String indexName) throws Exception {
CommandStringBuilder csb = new CommandStringBuilder(CliStrings.LIST_INDEX);
CommandResult commandResult = gfshShellConnectionRule.executeAndVerifyCommand(csb.toString());
String resultAsString = commandResultToString(commandResult);
assertEquals(Result.Status.OK, commandResult.getStatus());
assertTrue(resultAsString.contains(indexName));
}
use of org.apache.geode.management.internal.cli.result.CommandResult in project geode by apache.
the class ConnectCommandWithHttpAndSSLDUnitTest method connect.
@Override
protected void connect(final String host, final int jmxPort, final int httpPort, final HeadlessGfsh shell) {
assertNotNull(host);
assertNotNull(shell);
final CommandStringBuilder command = new CommandStringBuilder(CONNECT);
String endpoint;
// This is for testing purpose only. If we remove this piece of code we will
// get a java.security.cert.CertificateException
// as matching hostname can not be obtained in all test environment.
HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() {
@Override
public boolean verify(String string, SSLSession ssls) {
return true;
}
});
endpoint = "https://" + host + ":" + httpPort + urlContext + "/v1";
command.addOption(CONNECT__USE_HTTP, Boolean.TRUE.toString());
command.addOption(CONNECT__URL, endpoint);
command.addOption(CONNECT__USE_SSL, Boolean.TRUE.toString());
if (sslInfoHolder.get().getProperty(CONNECT__KEY_STORE) != null) {
command.addOption(CONNECT__KEY_STORE, sslInfoHolder.get().getProperty(CONNECT__KEY_STORE));
}
if (sslInfoHolder.get().getProperty(CONNECT__KEY_STORE_PASSWORD) != null) {
command.addOption(CONNECT__KEY_STORE_PASSWORD, sslInfoHolder.get().getProperty(CONNECT__KEY_STORE_PASSWORD));
}
if (sslInfoHolder.get().getProperty(CONNECT__TRUST_STORE) != null) {
command.addOption(CONNECT__TRUST_STORE, sslInfoHolder.get().getProperty(CONNECT__TRUST_STORE));
}
if (sslInfoHolder.get().getProperty(CONNECT__TRUST_STORE_PASSWORD) != null) {
command.addOption(CONNECT__TRUST_STORE_PASSWORD, sslInfoHolder.get().getProperty(CONNECT__TRUST_STORE_PASSWORD));
}
if (sslInfoHolder.get().getProperty(CONNECT__SSL_PROTOCOLS) != null) {
command.addOption(CONNECT__SSL_PROTOCOLS, sslInfoHolder.get().getProperty(CONNECT__SSL_PROTOCOLS));
}
if (sslInfoHolder.get().getProperty(CONNECT__SSL_CIPHERS) != null) {
command.addOption(CONNECT__SSL_CIPHERS, sslInfoHolder.get().getProperty(CONNECT__SSL_CIPHERS));
}
CommandResult result = executeCommand(shell, command.toString());
if (!shell.isConnectedAndReady()) {
fail("Connect command failed to connect to manager " + endpoint + " result=" + commandResultToString(result));
}
info("Successfully connected to managing node using HTTPS");
assertEquals(true, shell.isConnectedAndReady());
}
use of org.apache.geode.management.internal.cli.result.CommandResult in project geode by apache.
the class CliCommandTestBase method executeCommandWithoutClear.
/**
* Execute a command in the provided shell. Useful for getting additional information from the
* shell after the command has been executed (using getDefaultShell().???). Caller is responsible
* for calling getDefaultShell().clearEvents() when done.
*
* @param shell Shell in which to execute the command.
* @param command Command to execute
* @return The result of the command execution
*/
protected CommandResult executeCommandWithoutClear(HeadlessGfsh shell, String command) {
assert (shell != null);
assert (command != null);
shell.executeCommand(command);
if (shell.hasError()) {
error("executeCommand completed with error : " + shell.getError());
}
CommandResult result = null;
try {
// TODO: this can result in ClassCastException if
result = (CommandResult) shell.getResult();
// command resulted in error
} catch (InterruptedException ex) {
error("shell received InterruptedException");
}
if (result != null) {
result.resetToFirstLine();
}
return result;
}
use of org.apache.geode.management.internal.cli.result.CommandResult in project geode by apache.
the class CliCommandTestBase method connect.
protected void connect(final String host, final int jmxPort, final int httpPort, HeadlessGfsh shell, String username, String password) {
final CommandStringBuilder command = new CommandStringBuilder(CliStrings.CONNECT);
String endpoint;
if (useHttpOnConnect) {
endpoint = "http://" + host + ":" + httpPort + "/gemfire/v1";
command.addOption(CliStrings.CONNECT__USE_HTTP, Boolean.TRUE.toString());
command.addOption(CliStrings.CONNECT__URL, endpoint);
} else {
endpoint = host + "[" + jmxPort + "]";
command.addOption(CliStrings.CONNECT__JMX_MANAGER, endpoint);
}
if (username != null) {
command.addOption(CliStrings.CONNECT__USERNAME, username);
}
if (password != null) {
command.addOption(CliStrings.CONNECT__PASSWORD, password);
}
System.out.println(getClass().getSimpleName() + " using endpoint: " + endpoint);
CommandResult result = executeCommand(shell, command.toString());
if (!shell.isConnectedAndReady()) {
throw new AssertionError("Connect command failed to connect to manager " + endpoint + " result=" + commandResultToString(result));
}
info("Successfully connected to managing node using " + (useHttpOnConnect ? "HTTP" : "JMX"));
assertEquals(true, shell.isConnectedAndReady());
}
Aggregations