@Test
public void testReporterScheduling() throws InterruptedException {

	Configuration config = new Configuration();
	config.setString(MetricOptions.REPORTERS_LIST, "test");
	config.setString(ConfigConstants.METRICS_REPORTER_PREFIX + "test." + ConfigConstants.METRICS_REPORTER_CLASS_SUFFIX, TestReporter3.class.getName());
	config.setString(ConfigConstants.METRICS_REPORTER_PREFIX + "test.arg1", "hello");
	config.setString(ConfigConstants.METRICS_REPORTER_PREFIX + "test." + ConfigConstants.METRICS_REPORTER_INTERVAL_SUFFIX, "50 MILLISECONDS");
	MetricRegistryImpl registry = new MetricRegistryImpl(MetricRegistryConfiguration.fromConfiguration(config));
	long start = System.currentTimeMillis();
	// only start counting from now on
	TestReporter3.reportCount = 0;
	for (int x = 0; x < 10; x++) {
		Thread.sleep(100);
		int reportCount = TestReporter3.reportCount;
		long curT = System.currentTimeMillis();
		/**
		 * Within a given time-frame T only T/500 reports may be triggered due to the interval between reports.
		 * This value however does not not take the first triggered report into account (=> +1).
		 * Furthermore we have to account for the mis-alignment between reports being triggered and our time
		 * measurement (=> +1); for T=200 a total of 4-6 reports may have been
		 * triggered depending on whether the end of the interval for the first reports ends before
		 * or after T=50.
		 */
		long maxAllowedReports = (curT - start) / 50 + 2;
		Assert.assertTrue("Too many reports were triggered.", maxAllowedReports >= reportCount);
	}
	Assert.assertTrue("No report was triggered.", TestReporter3.reportCount > 0);
	registry.shutdown();
}