/** * Test JSON reporter. * <ul> * <li>increment the counter value</li> * <li>wait a bit for the new repor to be written</li> * <li>read the value from JSON file</li> * <li>verify that the value matches expectation</li> * </ul> * This check is repeated a few times to verify that the values are updated over time. * @throws Exception if fails to read counter value */ @Test public void testFileReporting() throws Exception { int runs = 5; String counterName = "count2"; for (int i = 0; i < runs; i++) { MetricsFactory.getInstance().incrementCounter(counterName); sleep(REPORT_INTERVAL_MS + REPORT_INTERVAL_MS / 2); Assert.assertEquals(i + 1, getCounterValue(counterName)); } }