Example #1
0
 /**
  * Test.
  *
  * @throws IOException e
  */
 @Test
 public void testErrorCounter() throws IOException {
   // errorCounter
   errorCounter.addRequestForSystemError("error", -1, -1, null);
   errorCounter.addRequestForSystemError("error2", -1, -1, "ma stack-trace");
   collector.collectWithoutErrors(javaInformationsList);
   final HtmlReport htmlReport =
       new HtmlReport(collector, null, javaInformationsList, Period.TOUT, writer);
   htmlReport.toHtml("message 3", null);
   assertNotEmptyAndClear(writer);
   for (final CounterRequest request : errorCounter.getRequests()) {
     htmlReport.writeRequestAndGraphDetail(request.getId());
   }
   htmlReport.writeRequestAndGraphDetail("n'importe quoi");
   assertNotEmptyAndClear(writer);
 }
Example #2
0
  /**
   * Test.
   *
   * @throws Exception e
   */
  @Test
  public void testWriteRequests() throws Exception { // NOPMD
    final HtmlReport htmlReport =
        new HtmlReport(collector, null, javaInformationsList, Period.SEMAINE, writer);
    htmlReport.writeRequestAndGraphDetail("httpHitsRate");
    assertNotEmptyAndClear(writer);

    // writeRequestAndGraphDetail avec drill-down
    collector.collectWithoutErrors(javaInformationsList);
    // si sqlCounter reste à displayed=false,
    // il ne sera pas utilisé dans writeRequestAndGraphDetail
    sqlCounter.setDisplayed(true);
    final String requestName = "test 1";
    counter.bindContext(requestName, "complete test 1", null, -1);
    servicesCounter.clear();
    servicesCounter.bindContext("myservices.service1", "service1", null, -1);
    sqlCounter.bindContext("sql1", "complete sql1", null, -1);
    sqlCounter.addRequest("sql1", 5, -1, false, -1);
    servicesCounter.addRequest("myservices.service1", 10, 10, false, -1);
    servicesCounter.bindContext("myservices.service2", "service2", null, -1);
    servicesCounter.addRequest("myservices.service2", 10, 10, false, -1);
    servicesCounter.addRequest("otherservices.service3", 10, 10, false, -1);
    servicesCounter.addRequest("otherservices", 10, 10, false, -1);
    jspCounter.addRequest("jsp1", 10, 10, false, -1);
    counter.addRequest(requestName, 0, 0, false, 1000);
    collector.collectWithoutErrors(javaInformationsList);
    final HtmlReport toutHtmlReport =
        new HtmlReport(collector, null, javaInformationsList, Period.TOUT, writer);
    for (final Counter collectorCounter : collector.getCounters()) {
      for (final CounterRequest request : collectorCounter.getRequests()) {
        toutHtmlReport.writeRequestAndGraphDetail(request.getId());
        assertNotEmptyAndClear(writer);
        toutHtmlReport.writeRequestUsages(request.getId());
        assertNotEmptyAndClear(writer);
      }
    }
    sqlCounter.setDisplayed(false);

    // writeCounterSummaryPerClass
    toutHtmlReport.writeCounterSummaryPerClass(servicesCounter.getName(), null);
    String requestId = new CounterRequest("myservices", servicesCounter.getName()).getId();
    toutHtmlReport.writeCounterSummaryPerClass(servicesCounter.getName(), requestId);
    requestId = new CounterRequest("otherservices", servicesCounter.getName()).getId();
    toutHtmlReport.writeCounterSummaryPerClass(servicesCounter.getName(), requestId);
    toutHtmlReport.writeCounterSummaryPerClass(servicesCounter.getName(), "unknown");
  }