JmxMetricsAccessor implements MetricsAccessor { @Override public Map<String, Double> getTimerValues(String group, String timer) { return getMetricValues(group, timer, "AverageTime"); } 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 testGetTimerValues() throws Exception { ObjectName timerObject = JmxUtil.getObjectName(SamzaContainerMetrics.class.getName(), "choose-ns", "samza-container-2"); objectNames.add(timerObject); Double time = 42.42; when(conn.getAttribute(timerObject, "AverageTime")).thenReturn(time); Map<String, Double> result = jmxMetricsAccessor.getTimerValues(SamzaContainerMetrics.class.getName(), "choose-ns"); assertTrue(result.size() == 1); assertTrue(result.get("samza-container-2").equals(time)); }