use of org.opennms.netmgt.collection.api.CollectionSet in project opennms by OpenNMS.
the class NodeLevelDataTest method testDefaultXmlCollector.
/**
* Test XML collector with Standard handler.
*
* @throws Exception the exception
*/
@Test
public void testDefaultXmlCollector() throws Exception {
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("collection", "NodeLevel");
parameters.put("handler-class", "org.opennms.protocols.xml.collector.MockDefaultXmlCollectionHandler");
CollectionSet collectionSet = executeCollectorTest(parameters, 1);
CountVisitor visitor = new CountVisitor();
collectionSet.visit(visitor);
Assert.assertEquals(1, visitor.getResourceCount());
Assert.assertEquals(6, visitor.getAttributeCount());
File file = new File(getSnmpRootDirectory(), "1/node-level-stats.jrb");
Assert.assertTrue(file.exists());
String[] dsnames = new String[] { "v1", "v2", "v3", "v4", "v5", "v6" };
Double[] dsvalues = new Double[] { 10.0, 11.0, 12.0, 13.0, 14.0, 15.0 };
validateJrb(file, dsnames, dsvalues);
}
use of org.opennms.netmgt.collection.api.CollectionSet in project opennms by OpenNMS.
the class XmlCollectorITCase method executeCollectorTest.
/**
* Executes collector test.
*
* @param parameters the parameters
* @param expectedFiles the expected amount of JRB files
* @return the collection set
* @throws Exception the exception
*/
public CollectionSet executeCollectorTest(Map<String, Object> parameters, int expectedFiles) throws Exception {
XmlCollector collector = new XmlCollector();
collector.setXmlCollectionDao(m_xmlCollectionDao);
CollectionSet collectionSet = XmlCollectorTestUtils.doCollect(collector, m_collectionAgent, parameters);
Assert.assertEquals(CollectionStatus.SUCCEEDED, collectionSet.getStatus());
ServiceParameters serviceParams = new ServiceParameters(new HashMap<String, Object>());
CollectionSetVisitor persister = m_persisterFactory.createGroupPersister(serviceParams, createRrdRepository((String) parameters.get("collection")), false, false);
collectionSet.visit(persister);
Assert.assertEquals(expectedFiles, FileUtils.listFiles(getSnmpRootDirectory(), new String[] { getRrdExtension() }, true).size());
return collectionSet;
}
Aggregations