JmxMetricsAccessor implements MetricsAccessor { @Override public Map<String, Long> getCounterValues(String group, String counter) { return getMetricValues(group, counter, "Count"); } JmxMetricsAccessor(String url); void connect(); void close(); @Override Map<String, Long> getCounterValues(String group, String counter); @Override Map<String, T> getGaugeValues(String group, String gauge); @Override Map<String, Double> getTimerValues(String group, String timer);  }
@Test public void testGetCounterValues() throws Exception { ObjectName counterObject = JmxUtil.getObjectName(SamzaContainerMetrics.class.getName(), "commit-calls", "samza-container-0"); objectNames.add(counterObject); Long commitCalls = 100L; when(conn.getAttribute(counterObject, "Count")).thenReturn(commitCalls); Map<String, Long> result = jmxMetricsAccessor.getCounterValues(SamzaContainerMetrics.class.getName(), "commit-calls"); assertTrue(result.size() == 1); assertTrue(result.get("samza-container-0").equals(commitCalls)); }