@Test @JUnitHttpServer(port=10342, webapps=@Webapp(context="/opennms", path="src/test/resources/loginTestWar")) public void testDsNamePerPage() throws Exception { m_params.put("page-sequence", "" + "<?xml version=\"1.0\"?>" + "<page-sequence>\n" + " <page path=\"/opennms/\" ds-name=\"test1\" port=\"10342\" virtual-host=\"localhost\" successMatch=\"&lt;title&gt;(.*?)&lt;/title&gt;\" />\n" + " <page path=\"/opennms/j_spring_security_check\" ds-name=\"test2\" port=\"10342\" virtual-host=\"localhost\" successMatch=\"&lt;title&gt;(.*?)&lt;/title&gt;\" />\n" + "</page-sequence>\n"); PollStatus status = m_monitor.poll(getHttpService("localhost"), m_params); assertTrue("Expected available but was "+status+": reason = "+status.getReason(), status.isAvailable()); assertTrue("Expected three DSes", (3 == status.getProperties().size())); assertTrue("Expected a DS called 'test1' but did not find one", status.getProperties().containsKey("test1")); assertTrue("Expected a DS called 'test2' but did not find one", status.getProperties().containsKey("test2")); }
public PollStatus poll(final MonitoredService svc, final Map<String, Object> parameterMap) { DefaultHttpClient client = null; PollStatus serviceStatus = PollStatus.unavailable("Poll not completed yet"); Map<String,Number> responseTimes = new LinkedHashMap<String,Number>(); SequenceTracker tracker = new SequenceTracker(parameterMap, DEFAULT_SEQUENCE_RETRY, DEFAULT_TIMEOUT); for(tracker.reset(); tracker.shouldRetry() && !serviceStatus.isAvailable(); tracker.nextAttempt() ) { try { PageSequenceMonitorParameters parms = PageSequenceMonitorParameters.get(parameterMap); client = parms.createHttpClient(); tracker.startAttempt(); responseTimes.put("response-time", Double.NaN); parms.getPageSequence().execute(client, svc, responseTimes); double responseTime = tracker.elapsedTimeInMillis(); serviceStatus = PollStatus.available(); responseTimes.put("response-time", responseTime); serviceStatus.setProperties(responseTimes); } catch (PageSequenceMonitorException e) { serviceStatus = PollStatus.unavailable(e.getMessage()); serviceStatus.setProperties(responseTimes); } catch (IllegalArgumentException e) { log().error("Invalid parameters to monitor: " + e.getMessage(), e); serviceStatus = PollStatus.unavailable("Invalid parameter to monitor: " + e.getMessage() + ". See log for details."); serviceStatus.setProperties(responseTimes); } finally { if (client != null) { client.getConnectionManager().shutdown(); } } } return serviceStatus; }
PageSequenceMonitor extends AbstractServiceMonitor { public PollStatus poll(final MonitoredService svc, final Map<String, Object> parameterMap) { DefaultHttpClient client = null; PollStatus serviceStatus = PollStatus.unavailable("Poll not completed yet"); Map<String,Number> responseTimes = new LinkedHashMap<String,Number>(); SequenceTracker tracker = new SequenceTracker(parameterMap, DEFAULT_SEQUENCE_RETRY, DEFAULT_TIMEOUT); for(tracker.reset(); tracker.shouldRetry() && !serviceStatus.isAvailable(); tracker.nextAttempt() ) { try { PageSequenceMonitorParameters parms = PageSequenceMonitorParameters.get(parameterMap); client = parms.createHttpClient(); tracker.startAttempt(); responseTimes.put("response-time", Double.NaN); parms.getPageSequence().execute(client, svc, responseTimes); double responseTime = tracker.elapsedTimeInMillis(); serviceStatus = PollStatus.available(); responseTimes.put("response-time", responseTime); serviceStatus.setProperties(responseTimes); } catch (PageSequenceMonitorException e) { serviceStatus = PollStatus.unavailable(e.getMessage()); serviceStatus.setProperties(responseTimes); } catch (IllegalArgumentException e) { log().error("Invalid parameters to monitor: " + e.getMessage(), e); serviceStatus = PollStatus.unavailable("Invalid parameter to monitor: " + e.getMessage() + ". See log for details."); serviceStatus.setProperties(responseTimes); } finally { if (client != null) { client.getConnectionManager().shutdown(); } } } return serviceStatus; } }
PageSequenceMonitor extends AbstractServiceMonitor { public PollStatus poll(final MonitoredService svc, final Map<String, Object> parameterMap) { DefaultHttpClient client = null; PollStatus serviceStatus = PollStatus.unavailable("Poll not completed yet"); Map<String,Number> responseTimes = new LinkedHashMap<String,Number>(); SequenceTracker tracker = new SequenceTracker(parameterMap, DEFAULT_SEQUENCE_RETRY, DEFAULT_TIMEOUT); for(tracker.reset(); tracker.shouldRetry() && !serviceStatus.isAvailable(); tracker.nextAttempt() ) { try { PageSequenceMonitorParameters parms = PageSequenceMonitorParameters.get(parameterMap); client = parms.createHttpClient(); tracker.startAttempt(); responseTimes.put("response-time", Double.NaN); parms.getPageSequence().execute(client, svc, responseTimes); double responseTime = tracker.elapsedTimeInMillis(); serviceStatus = PollStatus.available(); responseTimes.put("response-time", responseTime); serviceStatus.setProperties(responseTimes); } catch (PageSequenceMonitorException e) { serviceStatus = PollStatus.unavailable(e.getMessage()); serviceStatus.setProperties(responseTimes); } catch (IllegalArgumentException e) { log().error("Invalid parameters to monitor: " + e.getMessage(), e); serviceStatus = PollStatus.unavailable("Invalid parameter to monitor: " + e.getMessage() + ". See log for details."); serviceStatus.setProperties(responseTimes); } finally { if (client != null) { client.getConnectionManager().shutdown(); } } } return serviceStatus; }  }
PageSequenceMonitor extends AbstractServiceMonitor { public PollStatus poll(final MonitoredService svc, final Map<String, Object> parameterMap) { DefaultHttpClient client = null; PollStatus serviceStatus = PollStatus.unavailable("Poll not completed yet"); Map<String,Number> responseTimes = new LinkedHashMap<String,Number>(); SequenceTracker tracker = new SequenceTracker(parameterMap, DEFAULT_SEQUENCE_RETRY, DEFAULT_TIMEOUT); for(tracker.reset(); tracker.shouldRetry() && !serviceStatus.isAvailable(); tracker.nextAttempt() ) { try { PageSequenceMonitorParameters parms = PageSequenceMonitorParameters.get(parameterMap); client = parms.createHttpClient(); tracker.startAttempt(); responseTimes.put("response-time", Double.NaN); parms.getPageSequence().execute(client, svc, responseTimes); double responseTime = tracker.elapsedTimeInMillis(); serviceStatus = PollStatus.available(); responseTimes.put("response-time", responseTime); serviceStatus.setProperties(responseTimes); } catch (PageSequenceMonitorException e) { serviceStatus = PollStatus.unavailable(e.getMessage()); serviceStatus.setProperties(responseTimes); } catch (IllegalArgumentException e) { log().error("Invalid parameters to monitor: " + e.getMessage(), e); serviceStatus = PollStatus.unavailable("Invalid parameter to monitor: " + e.getMessage() + ". See log for details."); serviceStatus.setProperties(responseTimes); } finally { if (client != null) { client.getConnectionManager().shutdown(); } } } return serviceStatus; }  PollStatus poll(final MonitoredService svc, final Map<String, Object> parameterMap); }
PageSequenceMonitor extends AbstractServiceMonitor { public PollStatus poll(final MonitoredService svc, final Map<String, Object> parameterMap) { DefaultHttpClient client = null; PollStatus serviceStatus = PollStatus.unavailable("Poll not completed yet"); Map<String,Number> responseTimes = new LinkedHashMap<String,Number>(); SequenceTracker tracker = new SequenceTracker(parameterMap, DEFAULT_SEQUENCE_RETRY, DEFAULT_TIMEOUT); for(tracker.reset(); tracker.shouldRetry() && !serviceStatus.isAvailable(); tracker.nextAttempt() ) { try { PageSequenceMonitorParameters parms = PageSequenceMonitorParameters.get(parameterMap); client = parms.createHttpClient(); tracker.startAttempt(); responseTimes.put("response-time", Double.NaN); parms.getPageSequence().execute(client, svc, responseTimes); double responseTime = tracker.elapsedTimeInMillis(); serviceStatus = PollStatus.available(); responseTimes.put("response-time", responseTime); serviceStatus.setProperties(responseTimes); } catch (PageSequenceMonitorException e) { serviceStatus = PollStatus.unavailable(e.getMessage()); serviceStatus.setProperties(responseTimes); } catch (IllegalArgumentException e) { log().error("Invalid parameters to monitor: " + e.getMessage(), e); serviceStatus = PollStatus.unavailable("Invalid parameter to monitor: " + e.getMessage() + ". See log for details."); serviceStatus.setProperties(responseTimes); } finally { if (client != null) { client.getConnectionManager().shutdown(); } } } return serviceStatus; }  PollStatus poll(final MonitoredService svc, final Map<String, Object> parameterMap);  }