use of org.opennms.protocols.xml.config.XmlDataCollectionConfig in project opennms by OpenNMS.
the class HttpDataCollectionIT 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("Http-Count");
RrdRepository repository = createRrdRepository(collection.getXmlRrd());
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("collection", "Http-Count");
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/count-stats.jrb"));
Assert.assertNotNull(jrb);
Assert.assertEquals(1, jrb.getDsCount());
Datasource ds = jrb.getDatasource("count");
Assert.assertNotNull(ds);
Assert.assertEquals(new Double(5), Double.valueOf(ds.getLastValue()));
}
use of org.opennms.protocols.xml.config.XmlDataCollectionConfig in project opennms by OpenNMS.
the class XmlCollectorComplianceTest method getRequiredBeans.
public Map<String, Object> getRequiredBeans() {
XmlDataCollectionConfig config = mock(XmlDataCollectionConfig.class);
when(config.getRrdRepository()).thenReturn("target");
when(config.buildRrdRepository(COLLECTION)).thenReturn(new RrdRepository());
XmlRrd xmlRrd = new XmlRrd();
xmlRrd.setStep(300);
XmlDataCollection collection = new XmlDataCollection();
collection.setXmlRrd(xmlRrd);
XmlDataCollectionConfigDao xmlDataCollectionConfigDao = mock(XmlDataCollectionConfigDao.class);
when(xmlDataCollectionConfigDao.getDataCollectionByName(COLLECTION)).thenReturn(collection);
when(xmlDataCollectionConfigDao.getConfig()).thenReturn(config);
return new ImmutableMap.Builder<String, Object>().put("xmlDataCollectionConfigDao", xmlDataCollectionConfigDao).build();
}
Aggregations