示例#1
0
  /**
   * One round of test for max_retries and timeout.
   *
   * @param expected the expected kdc# timeout kdc# timeout...
   */
  private static void test0(ByteArrayOutputStream bo, String expected) throws Exception {
    PrintStream oldout = System.out;
    boolean failed = false;
    System.setOut(new PrintStream(bo));
    try {
      Context.fromUserPass(OneKDC.USER, OneKDC.PASS, false);
    } catch (Exception e) {
      failed = true;
    } finally {
      System.setOut(oldout);
    }

    String[] lines = new String(bo.toByteArray()).split("\n");
    StringBuilder sb = new StringBuilder();
    for (String line : lines) {
      Matcher m = re.matcher(line);
      if (m.find()) {
        System.out.println(line);
        sb.append(m.group(1)).append(toSymbolicSec(Integer.parseInt(m.group(2))));
      }
    }
    if (failed) sb.append('-');

    String output = sb.toString();
    System.out.println("Expected: " + expected + ", actual " + output);
    if (!output.matches(expected)) {
      throw new Exception("Does not match");
    }
  }