示例#1
0
  /**
   * Resolves something.
   *
   * @throws Exception if failed
   */
  @Test
  public void resolve() throws Exception {
    CommandScript script =
        new CommandScript(
            "testing",
            set("blk1", "blk2"),
            "profile",
            "module",
            Arrays.asList(
                ExecutionScript.PLACEHOLDER_HOME + "/cmd1",
                ExecutionScript.PLACEHOLDER_EXECUTION_ID,
                ExecutionScript.PLACEHOLDER_ARGUMENTS),
            map("ASAKUSA_HOME", ExecutionScript.PLACEHOLDER_HOME));

    ExecutionContext context =
        new ExecutionContext("b", "f", "e", ExecutionPhase.MAIN, map("arg", "ARG"));
    CommandScript resolved =
        script.resolve(
            context, handler(ExecutionScriptHandler.KEY_ENV_PREFIX + "ASAKUSA_HOME", "ah"));
    assertThat(resolved.isResolved(), is(true));
    assertThat(
        resolved.getCommandLineTokens(),
        is(Arrays.asList("ah/cmd1", "e", context.getArgumentsAsString())));
    assertThat(resolved.getEnvironmentVariables().size(), is(1));
    assertThat(resolved.getEnvironmentVariables().get("ASAKUSA_HOME"), is("ah"));
  }
示例#2
0
  /**
   * Resolves nothing.
   *
   * @throws Exception if failed
   */
  @Test
  public void resolve_nothing() throws Exception {
    CommandScript script =
        new CommandScript(
            "testing",
            set("blk1", "blk2"),
            "profile",
            "module",
            Arrays.asList("cmd1", "cmd2"),
            map("ASAKUSA_HOME", folder.getRoot().getAbsolutePath()));

    ExecutionContext context =
        new ExecutionContext("b", "f", "e", ExecutionPhase.MAIN, map("arg", "ARG"));
    CommandScript resolved = script.resolve(context, handler());
    assertThat(resolved.isResolved(), is(true));
    assertThat(resolved, is(script));
  }