예제 #1
0
 public void testInitialCount() {
   Meter meter =
       MetricManager.meter(Level.INFO, MetricManager.name(this.getClass(), "test-initial-count"));
   assertEquals("Initial count should be zero", 0, meter.getCount());
   Meter meter2 =
       MetricManager.meter(Level.INFO, MetricManager.name(this.getClass(), "test-initial-count"));
   assertEquals("Initial count should be zero", 0, meter2.getCount());
 }
예제 #2
0
  public void testSameMetric() {
    String name = MetricManager.name(this.getClass(), "test-same-meter");
    Meter meter = MetricManager.meter(Level.INFO, name);
    meter.mark();
    assertEquals("Count should be one", 1, meter.getCount());

    Meter meter2 = MetricManager.meter(Level.INFO, name);
    assertEquals("Count should be one", 1, meter2.getCount());
  }
예제 #3
0
  public void testMarkEvent() {
    Meter meter =
        MetricManager.meter(Level.INFO, MetricManager.name(this.getClass(), "test-meter-mark"));
    meter.mark();
    assertEquals("Count should be one", 1, meter.getCount());

    metricService.setRootLevel(Level.OFF);
    meter.mark();
    assertEquals("Count should be one", 1, meter.getCount());
  }
예제 #4
0
  public void testMarkEventByRandomNumber() {
    Meter meter =
        MetricManager.meter(
            Level.INFO, MetricManager.name(this.getClass(), "test-meter-mark-rand"));
    int n = randomGenerator.nextInt();
    meter.mark(n);
    assertEquals("Count should be " + n, n, meter.getCount());

    metricService.setRootLevel(Level.OFF);
    meter.mark(n);
    assertEquals("Count should be " + n, n, meter.getCount());
  }