use of org.opennms.core.test.http.annotations.JUnitHttpServer in project opennms by OpenNMS.
the class HttpUrlConnectionIT method testForm.
/**
* Test POST Request based on Form Data.
*
* @throws Exception the exception
*/
@Test
@JUnitHttpServer(port = 10342, https = false, webapps = { @Webapp(context = "/junit", path = "src/test/resources/test-webapp") })
public void testForm() throws Exception {
String json = "<form-fields><form-field name='firstName'>Alejandro</form-field><form-field name='lastName'>Galue</form-field></form-fields>";
Request req = buildRequest("application/x-www-form-urlencoded", json);
executeRequest(req);
}
use of org.opennms.core.test.http.annotations.JUnitHttpServer in project opennms by OpenNMS.
the class HttpUrlConnectionIT method testJson.
/**
* Test POST Request based on JSON Data.
*
* @throws Exception the exception
*/
@Test
@JUnitHttpServer(port = 10342, https = false, webapps = { @Webapp(context = "/junit", path = "src/test/resources/test-webapp") })
public void testJson() throws Exception {
String json = "{ person: { firstName: 'Alejandro', lastName: 'Galue' } }";
Request req = buildRequest("application/json", json);
executeRequest(req);
}
use of org.opennms.core.test.http.annotations.JUnitHttpServer in project opennms by OpenNMS.
the class HttpUrlConnectionIT method testXml.
/**
* Test POST Request based on XML Data.
*
* @throws Exception the exception
*/
@Test
@JUnitHttpServer(port = 10342, https = false, webapps = { @Webapp(context = "/junit", path = "src/test/resources/test-webapp") })
public void testXml() throws Exception {
String xml = "<person><firstName>Alejandro</firstName><lastName>Galue</lastName></person>";
Request req = buildRequest("application/xml", xml);
executeRequest(req);
}
use of org.opennms.core.test.http.annotations.JUnitHttpServer in project opennms by OpenNMS.
the class NMS7963IT method testHttpCollection.
/**
* Test HTTP Data Collection with XPath
*
* @throws Exception the exception
*/
@Test
@JUnitHttpServer(port = 10342, https = false, webapps = { @Webapp(context = "/junit", path = "src/test/resources/test-webapp") })
public void testHttpCollection() throws Exception {
File configFile = new File("src/test/resources/http-datacollection-config.xml");
XmlDataCollectionConfig config = JaxbUtils.unmarshal(XmlDataCollectionConfig.class, configFile);
XmlDataCollection collection = config.getDataCollectionByName("NMS-7963");
RrdRepository repository = createRrdRepository(collection.getXmlRrd());
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("collection", "NMS-7963");
DefaultXmlCollectionHandler collector = new DefaultXmlCollectionHandler();
collector.setRrdRepository(repository);
collector.setServiceName("HTTP");
CollectionSet collectionSet = XmlCollectorTestUtils.doCollect(m_nodeDao, collector, m_collectionAgent, collection, parameters);
Assert.assertEquals(CollectionStatus.SUCCEEDED, collectionSet.getStatus());
ServiceParameters serviceParams = new ServiceParameters(new HashMap<String, Object>());
CollectionSetVisitor persister = m_persisterFactory.createGroupPersister(serviceParams, repository, false, false);
collectionSet.visit(persister);
RrdDb jrb = new RrdDb(new File(getSnmpRoot(), "1/xml-retrv-wipo-data.jrb"));
Assert.assertNotNull(jrb);
Assert.assertEquals(1, jrb.getDsCount());
Datasource ds = jrb.getDatasource("xml-wipo-paco");
Assert.assertNotNull(ds);
Assert.assertEquals(new Double(903), Double.valueOf(ds.getLastValue()));
}
use of org.opennms.core.test.http.annotations.JUnitHttpServer in project opennms by OpenNMS.
the class HypericAckProcessorIT method testStartAckd.
@Test
@JUnitHttpServer(port = 7081)
public void testStartAckd() throws Exception {
AckdConfigurationDao realDao = createAckdConfigDao();
AckdConfigurationDao mockDao = createMock(AckdConfigurationDao.class);
expect(mockDao.getEnabledReaderCount()).andDelegateTo(realDao);
expect(mockDao.isReaderEnabled("JavaMailReader")).andDelegateTo(realDao).times(2);
expect(mockDao.isReaderEnabled("HypericReader")).andDelegateTo(realDao).times(2);
expect(mockDao.getReaderSchedule("HypericReader")).andDelegateTo(realDao).times(2);
replay(mockDao);
m_daemon.setConfigDao(mockDao);
m_daemon.start();
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
}
m_daemon.destroy();
verify(mockDao);
}
Aggregations