Пример #1
0
 private void appendTestMethod(@Nonnull StackTraceElement current) {
   content.append("          <li>");
   content.append(current.getClassName()).append('#');
   content
       .append(LESS_THAN_CHAR.matcher(current.getMethodName()).replaceFirst("&lt;"))
       .append(": ");
   content.append(current.getLineNumber());
 }
Пример #2
0
 public static String readToEnd(Reader reader) throws IOException {
   StringBuilder builder = new StringBuilder();
   char[] buffer = new char[1024 * 4];
   int count = reader.read(buffer);
   while (count != -1) {
     builder.append(buffer, 0, count);
     count = reader.read(buffer);
   }
   reader.close();
   return builder.toString();
 }
Пример #3
0
  @Nonnull
  private static String getRelativeSubPathToOutputDir(@Nonnull String filePath) {
    StringBuilder cssRelPath = new StringBuilder();
    int n = PATH_SEPARATOR.split(filePath).length;

    for (int i = 1; i < n; i++) {
      cssRelPath.append("../");
    }

    return cssRelPath.toString();
  }
Пример #4
0
  public void insertListOfCallPoints(@Nullable List<CallPoint> callPoints) {
    if (content.length() == 0) {
      content.append(EOL).append("      ");
    }

    content.append("  <ol style='display:none'>");

    if (callPoints == null) {
      content.append("</ol>").append(EOL).append("      ");
      return;
    }

    content.append(EOL);

    CallPoint currentCP = callPoints.get(0);
    appendTestMethod(currentCP.getStackTraceElement());
    appendRepetitionCountIfNeeded(currentCP);

    for (int i = 1, n = callPoints.size(); i < n; i++) {
      CallPoint nextCP = callPoints.get(i);
      StackTraceElement ste = nextCP.getStackTraceElement();

      if (nextCP.isSameTestMethod(currentCP)) {
        content.append(", ").append(ste.getLineNumber());
      } else {
        content.append("</li>").append(EOL);
        appendTestMethod(ste);
      }

      appendRepetitionCountIfNeeded(nextCP);
      currentCP = nextCP;
    }

    content.append("</li>").append(EOL).append("        </ol>").append(EOL).append("      ");
  }
Пример #5
0
  private void appendRepetitionCountIfNeeded(@Nonnull CallPoint callPoint) {
    int repetitionCount = callPoint.getRepetitionCount();

    if (repetitionCount > 0) {
      content.append('x').append(1 + repetitionCount);
    }
  }
Пример #6
0
 @Nonnull
 public String getContents() {
   String result = content.toString();
   content.setLength(0);
   return result;
 }