@Test public void testgetSurveillerStatus() throws SerialException, SQLException { HealthCheckEntity hcv = daoService.createHealthCheckEntity(0, cte, region_id, TestDataProvider.getMesosPlatform()); HealthCheckVO hcvo = new HealthCheckVO(); Map<String,String> paramList = new HashMap<String,String>(); paramList.put("URL","https: hcvo.setParamDetails(paramList); paramDetails=paramList; init(hcvo); try { StatusVO result = getSurveillerStatus(); } catch(Exception e) { } }
@Override public StatusVO getSurveillerStatus() { XmlReader reader = null; try { if(paramDetails.get(PARAM_KEY_URL)==null ){ logger.error("Configuration Error : The RSS URL is null in DB"); throw new IllegalArgumentException("Configuration Error : The RSS URL is null in DB"); } URL url = new URL(paramDetails.get(PARAM_KEY_URL)); reader = new XmlReader(url); SyndFeed feed = new SyndFeedInput().build(reader); if(feed.getEntries().size() == 0){ return new StatusVO(Status.UP); } else{ SyndEntry entry = (SyndEntry) feed.getEntries().get(0); if(entry.getTitle().contains("operating normally") || (entry.getDescription().getValue().contains("operating normally"))){ return new StatusVO(Status.UP); } else{ logger.debug(feed.getTitle() + " - " + entry.getTitle() + "for" + paramDetails.get(PARAM_KEY_URL)); return new StatusVO(Status.DOWN,feed.getTitle() + " - " + entry.getTitle() + ". Date -" + entry.getPublishedDate()); } } } catch (Exception e) { logger.error("Got Exception while connecting", e); return new StatusVO(Status.DOWN,e.getMessage() + ". URL=" + paramDetails.get(PARAM_KEY_URL)); } finally{ try { if (reader != null) { reader.close(); } } catch (Exception e) { logger.error("Got Exception while closing reader", e); } } }
GlobalAWSHandler extends SurveillerHandler { @Override public StatusVO getSurveillerStatus() { XmlReader reader = null; try { if(paramDetails.get(PARAM_KEY_URL)==null ){ logger.error("Configuration Error : The RSS URL is null in DB"); throw new IllegalArgumentException("Configuration Error : The RSS URL is null in DB"); } URL url = new URL(paramDetails.get(PARAM_KEY_URL)); reader = new XmlReader(url); SyndFeed feed = new SyndFeedInput().build(reader); if(feed.getEntries().size() == 0){ return new StatusVO(Status.UP); } else{ SyndEntry entry = (SyndEntry) feed.getEntries().get(0); if(entry.getTitle().contains("operating normally") || (entry.getDescription().getValue().contains("operating normally"))){ return new StatusVO(Status.UP); } else{ logger.debug(feed.getTitle() + " - " + entry.getTitle() + "for" + paramDetails.get(PARAM_KEY_URL)); return new StatusVO(Status.DOWN,feed.getTitle() + " - " + entry.getTitle() + ". Date -" + entry.getPublishedDate()); } } } catch (Exception e) { logger.error("Got Exception while connecting", e); return new StatusVO(Status.DOWN,e.getMessage() + ". URL=" + paramDetails.get(PARAM_KEY_URL)); } finally{ try { if (reader != null) { reader.close(); } } catch (Exception e) { logger.error("Got Exception while closing reader", e); } } } }
GlobalAWSHandler extends SurveillerHandler { @Override public StatusVO getSurveillerStatus() { XmlReader reader = null; try { if(paramDetails.get(PARAM_KEY_URL)==null ){ logger.error("Configuration Error : The RSS URL is null in DB"); throw new IllegalArgumentException("Configuration Error : The RSS URL is null in DB"); } URL url = new URL(paramDetails.get(PARAM_KEY_URL)); reader = new XmlReader(url); SyndFeed feed = new SyndFeedInput().build(reader); if(feed.getEntries().size() == 0){ return new StatusVO(Status.UP); } else{ SyndEntry entry = (SyndEntry) feed.getEntries().get(0); if(entry.getTitle().contains("operating normally") || (entry.getDescription().getValue().contains("operating normally"))){ return new StatusVO(Status.UP); } else{ logger.debug(feed.getTitle() + " - " + entry.getTitle() + "for" + paramDetails.get(PARAM_KEY_URL)); return new StatusVO(Status.DOWN,feed.getTitle() + " - " + entry.getTitle() + ". Date -" + entry.getPublishedDate()); } } } catch (Exception e) { logger.error("Got Exception while connecting", e); return new StatusVO(Status.DOWN,e.getMessage() + ". URL=" + paramDetails.get(PARAM_KEY_URL)); } finally{ try { if (reader != null) { reader.close(); } } catch (Exception e) { logger.error("Got Exception while closing reader", e); } } }  }
GlobalAWSHandler extends SurveillerHandler { @Override public StatusVO getSurveillerStatus() { XmlReader reader = null; try { if(paramDetails.get(PARAM_KEY_URL)==null ){ logger.error("Configuration Error : The RSS URL is null in DB"); throw new IllegalArgumentException("Configuration Error : The RSS URL is null in DB"); } URL url = new URL(paramDetails.get(PARAM_KEY_URL)); reader = new XmlReader(url); SyndFeed feed = new SyndFeedInput().build(reader); if(feed.getEntries().size() == 0){ return new StatusVO(Status.UP); } else{ SyndEntry entry = (SyndEntry) feed.getEntries().get(0); if(entry.getTitle().contains("operating normally") || (entry.getDescription().getValue().contains("operating normally"))){ return new StatusVO(Status.UP); } else{ logger.debug(feed.getTitle() + " - " + entry.getTitle() + "for" + paramDetails.get(PARAM_KEY_URL)); return new StatusVO(Status.DOWN,feed.getTitle() + " - " + entry.getTitle() + ". Date -" + entry.getPublishedDate()); } } } catch (Exception e) { logger.error("Got Exception while connecting", e); return new StatusVO(Status.DOWN,e.getMessage() + ". URL=" + paramDetails.get(PARAM_KEY_URL)); } finally{ try { if (reader != null) { reader.close(); } } catch (Exception e) { logger.error("Got Exception while closing reader", e); } } }  @Override StatusVO getSurveillerStatus(); }
GlobalAWSHandler extends SurveillerHandler { @Override public StatusVO getSurveillerStatus() { XmlReader reader = null; try { if(paramDetails.get(PARAM_KEY_URL)==null ){ logger.error("Configuration Error : The RSS URL is null in DB"); throw new IllegalArgumentException("Configuration Error : The RSS URL is null in DB"); } URL url = new URL(paramDetails.get(PARAM_KEY_URL)); reader = new XmlReader(url); SyndFeed feed = new SyndFeedInput().build(reader); if(feed.getEntries().size() == 0){ return new StatusVO(Status.UP); } else{ SyndEntry entry = (SyndEntry) feed.getEntries().get(0); if(entry.getTitle().contains("operating normally") || (entry.getDescription().getValue().contains("operating normally"))){ return new StatusVO(Status.UP); } else{ logger.debug(feed.getTitle() + " - " + entry.getTitle() + "for" + paramDetails.get(PARAM_KEY_URL)); return new StatusVO(Status.DOWN,feed.getTitle() + " - " + entry.getTitle() + ". Date -" + entry.getPublishedDate()); } } } catch (Exception e) { logger.error("Got Exception while connecting", e); return new StatusVO(Status.DOWN,e.getMessage() + ". URL=" + paramDetails.get(PARAM_KEY_URL)); } finally{ try { if (reader != null) { reader.close(); } } catch (Exception e) { logger.error("Got Exception while closing reader", e); } } }  @Override StatusVO getSurveillerStatus();  }