Exemplo n.º 1
0
  @Test
  public void testToStrings() throws Exception {
    final CommandLine cl = CommandLine.createCommandLine(EXEC_WITH_SPACES);

    cl.withArg(ARG_SPACES_NOQUOTES);
    cl.withArg(ARG_NOSPACES);
    cl.withArg(ARG_SPACES);

    final String expectedWithQuotes =
        DBL_QUOTE
            + EXEC_WITH_SPACES
            + DBL_QUOTE
            + " "
            + DBL_QUOTE
            + ARG_SPACES_NOQUOTES
            + DBL_QUOTE
            + " "
            + ARG_NOSPACES
            + " "
            + DBL_QUOTE
            + ARG_SPACES
            + DBL_QUOTE;
    assertEquals(expectedWithQuotes, cl.toString());

    assertEquals(expectedWithQuotes.replaceAll(DBL_QUOTE, ""), cl.toStringForDisplay());

    assertEquals("Did the impl of CommandLine.toString() change?", expectedWithQuotes, cl + "");
  }
Exemplo n.º 2
0
 @Test
 public void testToStringMisMatchedQuote() {
   final CommandLine cl2 = CommandLine.createCommandLine(EXEC_WITH_SPACES);
   final String argWithMismatchedDblQuote = "argMisMatch='singlequoted\"WithMismatchedDblQuote'";
   cl2.withArg(argWithMismatchedDblQuote);
   assertEquals(
       "Did behavior of mismatched quotes change? Previously it would truncate args.",
       DBL_QUOTE + EXEC_WITH_SPACES + DBL_QUOTE + " ",
       cl2.toString());
 }