JmxMonitor implements IMonitor { @Override public void startMonitoring(String serverId, InteractionProtocol protocol) { _protocol = protocol; if (serverId == null || _protocol == null) { throw new IllegalArgumentException("parameters can't be null"); } _serverId = serverId; _thread = new JmxMonitorThread(); _thread.start(); }  @Override void startMonitoring(String serverId, InteractionProtocol protocol); @Override void stopMonitoring();  }
@Test public void testGetCpu() throws Exception { JmxMonitor monitor = new JmxMonitor(); String nodeId = "someId"; InteractionProtocol protocol = mock(InteractionProtocol.class); monitor.startMonitoring(nodeId, protocol); Thread.sleep(1200); verify(protocol, atLeastOnce()).setMetric(eq(nodeId), (MetricsRecord) anyObject()); }