HeartBeat { public void heartBeatHealth() { if (null == serverRegistryService) { throw new DCMABusinessException("Not able to find ServerRegistryService service of the system."); } List<ServerRegistry> serverRegistries = serverRegistryService.getAllServerRegistry(); StringBuilder url = null; String pathUrl = null; boolean isActive = false; if (null == serverRegistries || serverRegistries.isEmpty()) { LOGGER.info("No server registry found."); } else { for (ServerRegistry serverRegistry : serverRegistries) { String ipAddress = serverRegistry.getIpAddress(); String portNumber = serverRegistry.getPort(); String context = serverRegistry.getAppContext(); if (ipAddress == null || null == portNumber || null == context) { LOGGER.error("Problem in creating. Server Registry Info is Null."); } else { url = new StringBuilder("http: url.append(ipAddress); url.append(":"); url.append(portNumber); if (!context.contains("/")) { url.append("/"); } url.append(context); url.append("/"); url.append(HEALTH_FILE_NAME); pathUrl = url.toString(); LOGGER.info(pathUrl); isActive = checkHealth(pathUrl); if (!isActive) { int noOfPings = 1; try { noOfPings = Integer.parseInt(getNumberOfPings()); } catch (NumberFormatException nfe) { LOGGER.error(nfe.getMessage()); } for (int i = 1; i < noOfPings; i++) { isActive = checkHealth(pathUrl); if (isActive) { break; } } } if (serverRegistry.isActive() != isActive) { serverRegistry.setActive(isActive); serverRegistryService.updateServerRegistry(serverRegistry); } } } } }  String getNumberOfPings(); void setNumberOfPings(final String numberOfPings); void heartBeatHealth();  }
@Test public void testHeartBeat() { boolean result = false; try { heartBeatService.heartBeatHealth(); } catch (Exception e) { assertTrue(e.getMessage(), result); } }