Exemplo n.º 1
0
  /**
   * Log resource upload event.
   *
   * @param fileName is the name only
   * @param fileContent is the content of the file
   * @param url is the target url
   */
  public void logResourceUploadRequestEvent(
      final String fileName, final String fileContent, final String url) {
    HtmlRunReporter reporter = getTestClassExecutionData().getHtmlRunReporter();
    LogFileWriter logWriter = reporter.getTestMethodHtmlLog();

    String addStr = "";
    String text = "Uploading resource: '" + fileName + "' to Wilma, using URL: " + url;

    reporter.systemOutPrintLn(text);

    if (logWriter != null) {
      try {
        String dumpFileName = dumpSource(fileContent);
        File dumpFile = new File(dumpFileName);
        addStr =
            " <small>[<a href=\""
                + dumpFile.getName()
                + "\" target=\"_new\">resource content</a>] </small>";
      } catch (Exception e) {
        addStr =
            " <small>[Dump failed:"
                + e.getMessage()
                + "]<br/><code><small><br><pre>"
                + getFullStackTrace(e)
                + "</pre></small></code></small>";
      }
    }
    if (logWriter != null) {
      logWriter.insertText(
          "<tr><td align=\"center\">&nbsp;</td><td bgcolor=\"#F0F0F0\">"
              + text
              + addStr
              + "</td></tr>\n");
    }
  }
Exemplo n.º 2
0
  /**
   * Log response event.
   *
   * @param responseMessage that was received
   */
  public void logResponseEvent(ResponseHolder responseMessage) {
    HtmlRunReporter reporter = getTestClassExecutionData().getHtmlRunReporter();
    LogFileWriter logWriter = reporter.getTestMethodHtmlLog();

    String addStr = "";
    String text = "Receiving response, response code: " + responseMessage.getResponseCode();
    String message = responseMessage.getResponseMessage();

    reporter.systemOutPrintLn(text);

    if (logWriter != null) {
      try {
        String dumpFileName = dumpSource(message);
        File dumpFile = new File(dumpFileName);
        addStr =
            " <small>[<a href=\""
                + dumpFile.getName()
                + "\" target=\"_new\">response source</a>] </small>";
      } catch (Exception e) {
        addStr =
            " <small>[Dump failed:"
                + e.getMessage()
                + "]<br/><code><small><br><pre>"
                + getFullStackTrace(e)
                + "</pre></small></code></small>";
      }
    }
    if (logWriter != null) {
      logWriter.insertText(
          "<tr><td>&nbsp;</td><td bgcolor=\"#F0F0F0\">" + text + addStr + "</td></tr>\n");
    }
  }
Exemplo n.º 3
0
  /**
   * Log POST request event.
   *
   * @param requestParameters that was sent in the request.
   */
  public void logPostRequestEvent(RequestParameters requestParameters) {
    HtmlRunReporter reporter = getTestClassExecutionData().getHtmlRunReporter();
    LogFileWriter logWriter = reporter.getTestMethodHtmlLog();

    String text = "Sending POST request to URL: " + requestParameters.getTestServerUrl();
    if (requestParameters.isUseProxy()) {
      text +=
          "\nUsing proxy:"
              + requestParameters.getWilmaHost()
              + ":"
              + requestParameters.getWilmaPort();
    } else {
      text += "\nWithout any proxy.";
    }

    reporter.systemOutPrintLn(getStep() + ". " + text);

    String addStr = "";
    if (logWriter != null) {
      try {
        String dumpFileName = dumpSource(originalRequestMessage);
        File dumpFile = new File(dumpFileName);
        addStr =
            " <small>[<a href=\""
                + dumpFile.getName()
                + "\" target=\"_new\">request source</a>] </small>";
      } catch (Exception e) {
        addStr =
            " <small>[Dump failed:"
                + e.getMessage()
                + "]<br/><code><small><br><pre>"
                + getFullStackTrace(e)
                + "</pre></small></code></small>";
      }
    }
    if (logWriter != null) {
      logWriter.insertText(
          "<tr><td align=\"center\">&nbsp;&nbsp;"
              + getStep()
              + ".&nbsp;&nbsp;</td><td bgcolor=\"#F0F0F0\">"
              + text
              + addStr
              + "</td></tr>\n");
    }
    increaseStep();
  }