use of org.jrobin.core.Datasource in project opennms by OpenNMS.
the class HttpDataCollectionIT method testCssSelectorHttpCollection.
/**
* Test HTTP Data Collection with CSS Selector
*
* @throws Exception the exception
*/
@Test
@JUnitHttpServer(port = 10342, https = false, webapps = { @Webapp(context = "/junit", path = "src/test/resources/test-webapp") })
public void testCssSelectorHttpCollection() 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-Market");
RrdRepository repository = createRrdRepository(collection.getXmlRrd());
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("collection", "Http-Market");
HttpCollectionHandler collector = new HttpCollectionHandler();
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/market.jrb"));
Assert.assertNotNull(jrb);
Assert.assertEquals(2, jrb.getDsCount());
Datasource ds = jrb.getDatasource("nasdaq");
Assert.assertNotNull(ds);
Assert.assertEquals(new Double(3578.30), Double.valueOf(ds.getLastValue()));
}
use of org.jrobin.core.Datasource in project opennms by OpenNMS.
the class HttpDataCollectionIT method testPostRequestHttpCollection.
/**
* Test HTTP Data Collection with a POST Request
*
* @throws Exception the exception
*/
@Test
@JUnitHttpServer(port = 10342, https = false, webapps = { @Webapp(context = "/junit", path = "src/test/resources/test-webapp") })
public void testPostRequestHttpCollection() 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-Person-Stats");
RrdRepository repository = createRrdRepository(collection.getXmlRrd());
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("collection", "Http-Person-Stats");
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/person-stats.jrb"));
Assert.assertNotNull(jrb);
Assert.assertEquals(3, jrb.getDsCount());
Datasource ds = jrb.getDatasource("contributions");
Assert.assertNotNull(ds);
Assert.assertEquals(new Double(500), Double.valueOf(ds.getLastValue()));
}
use of org.jrobin.core.Datasource in project opennms by OpenNMS.
the class NodeLevelDataOnMultipleNodesTest method validateJrb.
/**
* Validates a JRB.
* <p>It assumes storeByGroup=true</p>
*
* @param file the JRB file instance
* @param dsnames the array of data source names
* @param dsvalues the array of data source values
* @throws Exception the exception
*/
public void validateJrb(File file, String[] dsnames, Double[] dsvalues) throws Exception {
Assert.assertTrue(file.exists());
RrdDb jrb = new RrdDb(file);
Assert.assertEquals(dsnames.length, jrb.getDsCount());
for (int i = 0; i < dsnames.length; i++) {
Datasource ds = jrb.getDatasource(dsnames[i]);
Assert.assertNotNull(ds);
Assert.assertEquals(dsvalues[i], Double.valueOf(ds.getLastValue()));
}
}
use of org.jrobin.core.Datasource in project opennms by OpenNMS.
the class XmlCollectorITCase method validateJrb.
/**
* Validates a JRB.
* <p>It assumes storeByGroup=true</p>
*
* @param file the JRB file instance
* @param dsnames the array of data source names
* @param dsvalues the array of data source values
* @throws Exception the exception
*/
public void validateJrb(File file, String[] dsnames, Double[] dsvalues) throws Exception {
Assert.assertTrue(file.exists());
RrdDb jrb = new RrdDb(file);
Assert.assertEquals(dsnames.length, jrb.getDsCount());
for (int i = 0; i < dsnames.length; i++) {
Datasource ds = jrb.getDatasource(dsnames[i]);
Assert.assertNotNull(ds);
Assert.assertEquals(dsvalues[i], Double.valueOf(ds.getLastValue()));
}
}
Aggregations