### Question:
AvailabilityMonitor extends AbstractServiceMonitor { public PollStatus poll(MonitoredService svc, Map<String, Object> parameters) { TimeoutTracker timeoutTracker = new TimeoutTracker(parameters, DEFAULT_RETRY, DEFAULT_TIMEOUT); for(timeoutTracker.reset(); timeoutTracker.shouldRetry(); timeoutTracker.nextAttempt()) { try { timeoutTracker.startAttempt(); if (svc.getAddress().isReachable(timeoutTracker.getSoTimeout())) { return PollStatus.available(timeoutTracker.elapsedTimeInMillis()); } } catch (IOException e) { logDown(Level.INFO, "Unable to contact "+svc.getIpAddr(), e); } } return logDown(Level.INFO, svc+" failed to respond"); }  void initialize(Map<String, Object> parameters); void initialize(MonitoredService svc); PollStatus poll(MonitoredService svc, Map<String, Object> parameters); void release(); void release(MonitoredService svc);  }### Answer:
@Test public final void testPoll() { ServiceMonitor sm = new AvailabilityMonitor(); Map<String, Object> parameters = new HashMap<String, Object>(); parameters.put("timeout", "3000"); MonitoredService svc = new MonitoredService() { public InetAddress getAddress() { final InetAddress addr = InetAddressUtils.addr("127.0.0.1"); if (addr == null) { throw new IllegalStateException("Error getting localhost address"); } return addr; } public String getIpAddr() { return InetAddressUtils.str(getAddress()); } public NetworkInterface<InetAddress> getNetInterface() { return new InetNetworkInterface(getAddress()); } public int getNodeId() { return 0; } public String getNodeLabel() { return "localhost"; } public String getSvcName() { return "ICMP"; } public String getSvcUrl() { return null; } }; PollStatus status = sm.poll(svc, parameters); assertEquals(PollStatus.SERVICE_AVAILABLE, status.getStatusCode()); }