use of org.opennms.core.test.http.annotations.JUnitHttpServer in project opennms by OpenNMS.
the class PageSequenceMonitorIT method testRedirectLocationMatch.
@Test
@JUnitHttpServer(port = 10342, webapps = @Webapp(context = "/opennms", path = "src/test/resources/loginTestWar"))
public void testRedirectLocationMatch() throws Exception {
m_params.put("page-sequence", "" + "<?xml version=\"1.0\"?>" + "<page-sequence>\n" + " <page path=\"/opennms/\" port=\"10342\" virtual-host=\"localhost\" successMatch=\"(?s)<hea(.)><titl(.)>.*</for(.)></b(.)dy>\">\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\" port=\"10342\" method=\"POST\" response-range=\"300-399\" locationMatch=\"/opennms/\">\n" + " <parameter key=\"j_username\" value=\"${ltr1}${ltr2}${ltr3}${ltr4}\"/>\n" + " <parameter key=\"j_password\" value=\"${ltr1}${ltr2}${ltr3}${ltr4}\"/>\n" + " </page>\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 a DS called 'response-time' but did not find one", status.getProperties().containsKey(PollStatus.PROPERTY_RESPONSE_TIME));
}
use of org.opennms.core.test.http.annotations.JUnitHttpServer in project opennms by OpenNMS.
the class PageSequenceMonitorIT method testDsNamePerPage.
@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=\"<title>(.*?)</title>\" />\n" + " <page path=\"/opennms/j_spring_security_check\" ds-name=\"test2\" port=\"10342\" virtual-host=\"localhost\" successMatch=\"<title>(.*?)</title>\" />\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"));
assertTrue("Expected a DS called 'response-time' but did not find one", status.getProperties().containsKey(PollStatus.PROPERTY_RESPONSE_TIME));
}
use of org.opennms.core.test.http.annotations.JUnitHttpServer in project opennms by OpenNMS.
the class FasterFilesystemForeignSourceRepositoryTest method testImportHttpSource.
@Test
@JUnitHttpServer(port = 9162)
public void testImportHttpSource() throws Exception {
FileSystemBuilder bldr = new FileSystemBuilder("target", "testGetForeignSource");
File fsDir = bldr.dir("foreignSource").file("test.xml", fs("test")).file("noreq.xml", fs("noreq")).pop();
File reqDir = bldr.dir("requisitions").file("test.xml", req("test")).file("pending.xml", req("pending")).pop();
FasterFilesystemForeignSourceRepository repo = repo(fsDir, reqDir);
Resource resource = new UrlResource("http://localhost:9162/requisition-test.xml");
Requisition req = repo.importResourceRequisition(resource);
assertNotNull(req);
System.err.println(JaxbUtils.marshal(req));
assertNotNull(req.getNode("4243"));
assertNotNull(req.getNode("4244"));
}
Aggregations