ApptuitReporterTest.java 文件源码

java
阅读 23 收藏 0 点赞 0 评论 0

项目:JInsight 作者:
@Test
public void testReporter() throws Exception {

  UUID uuid = UUID.randomUUID();
  String metricName = "ApptuitReporterTest.testReporter." + uuid.toString();
  int expectedCount=2;

  AtomicBoolean foundMetric = new AtomicBoolean(false);
  AtomicInteger lastSeenCount = new AtomicInteger(-1);
  PutListener listener = dataPoints -> {
    dataPoints.forEach(dataPoint -> {
      if (!metricName.equals(dataPoint.getMetric()))
        return;
      int i = dataPoint.getValue().intValue();
      lastSeenCount.set(i);
      if (i != 2)
        return;
      foundMetric.set(true);
    });
  };
  putClient.addPutListener(listener);

  Counter counter = registry.counter(metricName);
  counter.inc();
  counter.inc();


  await().atMost(period*3, TimeUnit.SECONDS).untilTrue(foundMetric);
  putClient.removePutListener(listener);

  assertEquals(expectedCount, lastSeenCount.intValue());
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号