Esempio n. 1
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");
  }
 /** {@inheritDoc} */
 @Override
 public synchronized void incrAllCounters(AbstractCounters<Counter, CounterGroup> other) {
   for (CounterGroup group : other) {
     for (Counter counter : group) {
       findCounter(group.getName(), counter.getName()).increment(counter.getValue());
     }
   }
 }
Esempio n. 3
0
 // loads the Storage object and updates the displayed count
 protected void recoverData() {
   storage = loadStorage();
   if (storage == null) storage = new Storage();
   else {
     Counter item = storage.getCounter(id);
     titleText.setText(String.format("%s - Counter", item.getName()));
     setCurrCount(item.getCount());
   }
 }
  private long calculateFirstIdForReduceOutput(IdSetterKey key) {
    TreeMap<String, Long> tempMap = new TreeMap<String, Long>();

    for (Counter counter : this.counterGroup.getGroup(IdSetterMapper.MAP_COUNTERS)) {
      tempMap.put(counter.getName(), counter.getValue());
    }

    return calculatePreviousLinesInFile(key, tempMap) + 1;
  }
Esempio n. 5
0
 private PdfCounterReport writeCounter(Counter counter) throws DocumentException, IOException {
   final String counterLabel = getString(counter.getName() + "Label");
   addParagraph(
       getFormattedString("Statistiques_compteur", counterLabel) + " - " + range.getLabel(),
       counter.getIconName());
   final PdfCounterReport pdfCounterReport =
       new PdfCounterReport(collector, counter, range, false, getDocument());
   pdfCounterReport.toPdf();
   return pdfCounterReport;
 }
  private void setupUI() {
    // Find counter name box
    mNameText = (EditText) findViewById(R.id.counteredit_name_text);

    Log.w(TAG, "mNameText: " + mNameText);

    // Fill name box with counter's name
    mNameText.append(mCounter.getName());

    // Create an OnClickListener for the updown radio buttons
    OnClickListener updown_listener =
        new OnClickListener() {
          public void onClick(View v) {
            Log.w(TAG, "clicked radiobutton");

            RadioButton rb = (RadioButton) v;
            if (rb.getId() == R.id.counteredit_updown_up) {
              Log.w(TAG, "clicked UP");
              mCounter.setCountUp(true);
            } else {
              Log.w(TAG, "clicked DOWN");
              mCounter.setCountUp(false);
            }
          }
        };

    // Find updown RadioButtons
    mUpdownUp = (RadioButton) findViewById(R.id.counteredit_updown_up);
    mUpdownDown = (RadioButton) findViewById(R.id.counteredit_updown_down);

    // Attach OnClickListeners
    mUpdownUp.setOnClickListener(updown_listener);
    mUpdownDown.setOnClickListener(updown_listener);

    // Select the correct radiobutton based on the current setting
    if (mCounter.getCountUp()) {
      mUpdownUp.setChecked(true);
    } else {
      mUpdownDown.setChecked(true);
    }

    // Find pattern checkbox
    mPatternCheckBox = (CheckBox) findViewById(R.id.counteredit_pattern_checkbox);

    // Check/uncheck the checkbox based on the current setting
    mPatternCheckBox.setChecked(mCounter.getPatternOn());

    // Callback function for when the checkbox changes
    mPatternCheckBox.setOnCheckedChangeListener(
        new CheckBox.OnCheckedChangeListener() {
          @Override
          public void onCheckedChanged(CompoundButton v, boolean checked) {
            Log.w(TAG, "checkbox changed");

            // Make text normal/dim
            refreshPattern();

            // Enable/disable pattern mode
            mCounter.setPatternOn(checked);
          }
        });

    // Find pattern length number
    mPatternNumber = (EditText) findViewById(R.id.counteredit_pattern_number);

    // Set the number based on the current setting
    mPatternNumber.append(Integer.toString(mCounter.getPatternLength()));

    // Find end of pattern text (" rows")
    mPatternEndText = (TextView) findViewById(R.id.counteredit_pattern_endtext);

    refreshPattern();
  }