Package org.springframework.shell.core

Examples of org.springframework.shell.core.CommandResult


   * @param streamName name of stream for which to obtain runtime modules
   * @return list of table rows containing runtime module information
   *         for the requested stream
   */
  private List<TableRow> getRuntimeModulesForStream(String streamName) {
    CommandResult cmdResult = executeCommand("runtime modules");
    Table table = (Table) cmdResult.getResult();
    List<TableRow> modules = new ArrayList<TableRow>();
    for (TableRow row : table.getRows()) {
      if (row.getValue(1).contains(streamName)) {
        modules.add(row);
      }
View Full Code Here


  @Test
  public void testCollidingModuleComposeWithOtherComposite() {
    compose().newModule("compositesource", "time | splitter");

    CommandResult result = getShell().executeCommand(
        "module compose compositesource --definition \"time | transform\"");
    assertEquals("There is already a module named 'compositesource' with type 'source'\n",
        result.getException().getMessage());

  }
View Full Code Here

  }

  @Test
  public void testCollidingModuleComposeWithRegularModule() {
    CommandResult result = getShell().executeCommand(
        "module compose tcp --definition \"time | transform\"");
    assertEquals("There is already a module named 'tcp' with type 'source'\n", result.getException().getMessage());

  }
View Full Code Here

  private void doCreate(String streamname, String streamdefinition, boolean deploy, Object... values) {
    String actualDefinition = String.format(streamdefinition, values);
    // Shell parser expects quotes to be escaped by \
    String wholeCommand = String.format("stream create %s --definition \"%s\" --deploy %s", streamname,
        actualDefinition.replaceAll("\"", "\\\\\""), deploy);
    CommandResult cr = executeCommand(wholeCommand);
    if (deploy) {
      stateVerifier.waitForDeploy(streamname);
    }
    else {
      stateVerifier.waitForCreate(streamname);
    }
    // add the stream name to the streams list before assertion
    streams.add(streamname);
    String deployMsg = "Created";
    if (deploy) {
      deployMsg = "Created and deployed";
    }
    assertEquals(deployMsg + " new stream '" + streamname + "'", cr.getResult());
    verifyExists(streamname, actualDefinition, deploy);
  }
View Full Code Here

   * Deploy the given stream
   *
   * @param streamname name of the stream
   */
  public void deploy(String streamname) {
    CommandResult cr = getShell().executeCommand("stream deploy --name " + streamname);
    stateVerifier.waitForDeploy(streamname);
    assertTrue("Failure.  CommandResult = " + cr.toString(), cr.isSuccess());
    assertEquals("Deployed stream '" + streamname + "'", cr.getResult());
  }
View Full Code Here

   * Destroy all streams that were created using the 'create' method. Commonly called in a @After annotated method
   */
  public void destroyCreatedStreams() {
    for (int s = streams.size() - 1; s >= 0; s--) {
      String streamname = streams.get(s);
      CommandResult cr = executeCommand("stream destroy --name " + streamname);
      stateVerifier.waitForDestroy(streamname);
      assertTrue("Failure to destroy stream " + streamname + ".  CommandResult = " + cr.toString(),
          cr.isSuccess());
    }
  }
View Full Code Here

   * Destroy a specific stream
   *
   * @param stream The stream to destroy
   */
  public void destroyStream(String stream) {
    CommandResult cr = executeCommand("stream destroy --name " + stream);
    stateVerifier.waitForDestroy(stream);
    assertTrue("Failure to destroy stream " + stream + ".  CommandResult = " + cr.toString(),
        cr.isSuccess());
    streams.remove(stream);
  }
View Full Code Here

   * Undeploy the given stream name
   *
   * @param streamname name of the stream.
   */
  public void undeploy(String streamname) {
    CommandResult cr = getShell().executeCommand("stream undeploy --name " + streamname);
    stateVerifier.waitForUndeploy(streamname);
    assertTrue(cr.isSuccess());
    assertEquals("Un-deployed stream '" + streamname + "'", cr.getResult());
  }
View Full Code Here

   *
   * @param streamName the name of the stream
   * @param definition definition of the stream
   */
  public void verifyExists(String streamName, String definition, boolean deployed) {
    CommandResult cr = getShell().executeCommand("stream list");
    assertTrue("Failure.  CommandResult = " + cr.toString(), cr.isSuccess());
    Table t = (Table) cr.getResult();
    assertTrue(t.getRows().contains(
        new TableRow().addValue(1, streamName).addValue(2, definition).addValue(3, deployed ? "deployed" : "undeployed")));
  }
View Full Code Here

  private static final Log logger = LogFactory.getLog(RuntimeCommandTests.class);

  @Test
  public void testListContainers() {
    logger.info("List runtime containers");
    CommandResult cmdResult = executeCommand("runtime containers");
    Table table = (Table) cmdResult.getResult();
    for (TableRow row : table.getRows()) {
      // Verify host name & ip address are not empty
      assertTrue(StringUtils.hasText(row.getValue(2)) && StringUtils.hasText(row.getValue(3)));
    }
    // Verify there should be at least one container in the list.
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.