Package org.springframework.shell.core

Examples of org.springframework.shell.core.CommandResult


  protected Table listJobExecutions() {
    return (Table) getShell().executeCommand("job execution list").getResult();
  }

  protected String displayJobExecution(String id) {
    final CommandResult commandResult = getShell().executeCommand("job execution display " + id);
    if (!commandResult.isSuccess()) {
      throw new IllegalStateException("Expected a successful command execution.", commandResult.getException());
    }
    return (String) commandResult.getResult();
  }
View Full Code Here


  protected String getJobExecutionStatus(String jobName) {
    return getJobExecutionStatus(getJobExecutionRow(jobName));
  }

  protected Table listStepExecutions(String id) {
    final CommandResult commandResult = getShell().executeCommand("job execution step list " + id);
    if (!commandResult.isSuccess()) {
      throw new IllegalStateException("Expected a successful command execution.", commandResult.getException());
    }
    return (Table) commandResult.getResult();
  }
View Full Code Here

    }
    return (Table) commandResult.getResult();
  }

  protected Table getStepExecutionProgress(String jobExecutionId, String stepExecutionId) {
    final CommandResult commandResult = getShell().executeCommand(
        "job execution step progress " + stepExecutionId + " --jobExecutionId " + jobExecutionId);
    if (!commandResult.isSuccess()) {
      throw new IllegalStateException("Expected a successful command execution.", commandResult.getException());
    }
    return (Table) commandResult.getResult();
  }
View Full Code Here

    }
    return (Table) commandResult.getResult();
  }

  protected Table getDisplayStepExecution(String jobExecutionId, String stepExecutionId) {
    final CommandResult commandResult = getShell().executeCommand(
        "job execution step display " + stepExecutionId + " --jobExecutionId " + jobExecutionId);
    if (!commandResult.isSuccess()) {
      throw new IllegalStateException("Expected a successful command execution.", commandResult.getException());
    }
    return (Table) commandResult.getResult();
  }
View Full Code Here

   * Remembers created modules, in the form <type>:<name>.
   */
  private List<String> modules = new ArrayList<>();

  public String newModule(String name, String definition) {
    CommandResult result = shell.executeCommand(String.format("module compose %s --definition \"%s\"", name,
        definition));
    assertNotNull("Module composition apparently failed. Exception is: " + result.getException(),
        result.getResult());
    Matcher matcher = COMPOSE_SUCCESS_PATTERN.matcher((CharSequence) result.getResult());
    assertTrue("Module composition apparently failed: " + result.getResult(), matcher.matches());
    String key = matcher.group(2) + ":" + matcher.group(1);
    modules.add(key);
    return key;
  }
View Full Code Here

    modules.add(key);
    return key;
  }

  public boolean delete(String name, ModuleType type) {
    CommandResult result = shell.executeCommand(String.format("module delete %s:%s", type, name));
    return result.isSuccess();
  }
View Full Code Here

public class DateCommandTests extends AbstractShellIntegrationTest {

  @Test
  public void testDate() throws ParseException {

    CommandResult cr = getShell().executeCommand("date");

    assertTrue("Date command completed correctly", cr.isSuccess());
    DateFormat df = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL, Locale.getDefault());
    Date result = df.parse(cr.getResult().toString());
    Date now = new Date();
    MatcherAssert.assertThat(now, DateMatchers.within(5, TimeUnit.SECONDS, result));
  }
View Full Code Here

  /**
   * Execute a command and verify the command result.
   */
  protected CommandResult executeCommand(String command) {
    CommandResult cr = getShell().executeCommand(command);
    if (cr.getException() != null) {
      cr.getException().printStackTrace();
    }
    assertTrue("Failure.  CommandResult = " + cr.toString(), cr.isSuccess());
    return cr;
  }
View Full Code Here

    assertTrue("Failure.  CommandResult = " + cr.toString(), cr.isSuccess());
    return cr;
  }

  protected CommandResult executeCommandExpectingFailure(String command) {
    CommandResult cr = getShell().executeCommand(command);
    assertFalse("Expected command to fail.  CommandResult = " + cr.toString(), cr.isSuccess());
    return cr;
  }
View Full Code Here

  @Test
  public void testShellWithCredentials() throws Exception {
    Bootstrap bootstrap = new Bootstrap();
    JLineShellComponent shell = bootstrap.getJLineShellComponent();
    CommandResult commandResult = shell.executeCommand("admin config server --uri http://localhost:" + adminPort + " --username admin --password whosThere");
    assertThat(commandResult.isSuccess(), is(true));
    commandResult = shell.executeCommand("module list");
    assertThat(commandResult.isSuccess(), is(true));
    assertThat(commandResult.getResult(), instanceOf(Table.class));
    assertThat(((Table) commandResult.getResult()).getHeaders().size(), greaterThan(0));
  }
View Full Code Here

TOP

Related Classes of org.springframework.shell.core.CommandResult

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.