@Test @JUnitHttpServer(port=10342, webapps=@Webapp(context="/opennms", path="src/test/resources/loginTestWar")) public void testLoginDynamicCredentialsTwice() throws Exception { m_params.put("page-sequence", "" + "<?xml version=\"1.0\"?>" + "<page-sequence>\n" + " <page path=\"/opennms/\" port=\"10342\" virtual-host=\"localhost\" successMatch=\"(?s)&gt;Login (.)(.)(.)(.) Username and Password&lt;\">\n" + " <session-variable name=\"ltr1\" match-group=\"1\" />\n" + " <session-variable name=\"ltr2\" match-group=\"2\" />\n" + " <session-variable name=\"ltr3\" match-group=\"3\" />\n" + " <session-variable name=\"ltr4\" match-group=\"4\" />\n" + " </page>\n" + " <page virtual-host=\"localhost\" path=\"/opennms/j_spring_security_check\" response-range=\"300-399\" port=\"10342\" method=\"POST\">\n" + " <parameter key=\"j_username\" value=\"${ltr1}${ltr2}${ltr3}${ltr4}\"/>\n" + " <parameter key=\"j_password\" value=\"${ltr1}${ltr2}${ltr3}${ltr4}\"/>\n" + " </page>\n" + " <page virtual-host=\"localhost\" path=\"/opennms/spring_security_login\" port=\"10342\" failureMatch=\"(?s)Log out\" failureMessage=\"Login should have Failed but did not\" successMatch=\"(?s)Your login attempt was not successful.*\">\n" + " <parameter key=\"login_error\" value=\"\"/>\n" + " </page>\n" + " <page path=\"/opennms/\" port=\"10342\" virtual-host=\"localhost\" successMatch=\"(?s)&lt;hea(.)&gt;&lt;titl(.)&gt;.*&lt;/for(.)&gt;&lt;/b(.)dy&gt;\">\n" + " <session-variable name=\"ltr1\" match-group=\"1\" />\n" + " <session-variable name=\"ltr2\" match-group=\"2\" />\n" + " <session-variable name=\"ltr3\" match-group=\"3\" />\n" + " <session-variable name=\"ltr4\" match-group=\"4\" />\n" + " </page>\n" + " <page virtual-host=\"localhost\" path=\"/opennms/j_spring_security_check\" response-range=\"300-399\" port=\"10342\" method=\"POST\">\n" + " <parameter key=\"j_username\" value=\"${ltr1}${ltr2}${ltr3}${ltr4}\"/>\n" + " <parameter key=\"j_password\" value=\"${ltr1}${ltr2}${ltr3}${ltr4}\"/>\n" + " </page>\n" + " <page virtual-host=\"localhost\" path=\"/opennms/events.html\" port=\"10342\" successMatch=\"Event Queries\" />\n" + " <page virtual-host=\"localhost\" path=\"/opennms/j_spring_security_logout\" port=\"10342\" successMatch=\"Login with Username and Password\" />\n" + "</page-sequence>\n"); try { PollStatus status = m_monitor.poll(getHttpService("localhost"), m_params); assertTrue("Expected available but was "+status+": reason = "+status.getReason(), status.isAvailable()); } finally { } }
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);  }