コード例 #1
0
ファイル: CommandLineTest.java プロジェクト: qiaoliang/GoCD
  @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 + "");
  }
コード例 #2
0
ファイル: CommandLineTest.java プロジェクト: qiaoliang/GoCD
  @Test
  public void testToStringWithSeparator() throws Exception {
    final String separator = "], [";
    assertEquals("", CommandLine.toString(null, false, separator));

    assertEquals(
        ARG_SPACES_NOQUOTES,
        CommandLine.toString(new String[] {ARG_SPACES_NOQUOTES}, false, separator));

    assertEquals(
        ARG_SPACES_NOQUOTES + separator + ARG_NOSPACES,
        CommandLine.toString(new String[] {ARG_SPACES_NOQUOTES, ARG_NOSPACES}, false, separator));

    assertEquals(
        ARG_SPACES_NOQUOTES + separator + ARG_NOSPACES + separator + ARG_SPACES,
        CommandLine.toString(
            new String[] {ARG_SPACES_NOQUOTES, ARG_NOSPACES, ARG_SPACES}, false, separator));
  }
コード例 #3
0
ファイル: CommandLineTest.java プロジェクト: qiaoliang/GoCD
 @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());
 }
コード例 #4
0
ファイル: CommandLineTest.java プロジェクト: qiaoliang/GoCD
 @Test
 public void shouldReportPasswordsOnTheLogAsStars() {
   CommandLine line =
       CommandLine.createCommandLine("notexist").withArg(new PasswordArgument("secret"));
   assertThat(line.toString(), not(containsString("secret")));
 }