@Test
public void testMeterReporting() throws Exception {

	MetricRegistryImpl registry = null;
	String meterName = "meter";
	try {
		Configuration config = new Configuration();
		config.setString(MetricOptions.REPORTERS_LIST, "jmx_test");
		config.setString(ConfigConstants.METRICS_REPORTER_PREFIX + "jmx_test." + ConfigConstants.METRICS_REPORTER_CLASS_SUFFIX, JMXReporter.class.getName());
		registry = new MetricRegistryImpl(MetricRegistryConfiguration.fromConfiguration(config));
		TaskManagerMetricGroup metricGroup = new TaskManagerMetricGroup(registry, "localhost", "tmId");
		TestMeter meter = new TestMeter();
		metricGroup.meter(meterName, meter);
		MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
		ObjectName objectName = new ObjectName(JMX_DOMAIN_PREFIX + "taskmanager." + meterName, JMXReporter.generateJmxTable(metricGroup.getAllVariables()));
		MBeanInfo info = mBeanServer.getMBeanInfo(objectName);
		MBeanAttributeInfo[] attributeInfos = info.getAttributes();
		assertEquals(2, attributeInfos.length);
		assertEquals(meter.getRate(),  mBeanServer.getAttribute(objectName, "Rate"));
		assertEquals(meter.getCount(), mBeanServer.getAttribute(objectName, "Count"));
	} finally {
		if (registry != null) {
			registry.shutdown();
		}
	}
}