use of org.opennms.netmgt.dao.support.PropertiesGraphDao in project opennms by OpenNMS.
the class JsmiMibParserTest method testGenerateGraphTemplates.
/**
* Test generate graph templates.
*
* @throws Exception the exception
*/
@Test
public void testGenerateGraphTemplates() throws Exception {
if (parser.parseMib(new File(MIB_DIR, "Clavister-MIB.mib"))) {
List<PrefabGraph> graphs = parser.getPrefabGraphs();
StringWriter writer = new StringWriter();
PrefabGraphDumper dumper = new PrefabGraphDumper();
dumper.dump(graphs, writer);
System.out.println(writer.getBuffer().toString());
// FIXME we should implement a more comprehensive check here.
Assert.assertEquals(102533, writer.getBuffer().toString().length());
PropertiesGraphDao dao = new PropertiesGraphDao();
StringBuffer sb = new StringBuffer();
sb.append("command.prefix=/usr/bin/rrdtool\n");
sb.append("output.mime=image/png\n");
sb.append(writer.getBuffer().toString());
dao.loadProperties("performance", new ByteArrayInputStream(sb.toString().getBytes()));
Assert.assertEquals(graphs.size(), dao.getAllPrefabGraphs().size());
for (PrefabGraph g : graphs) {
try {
PrefabGraph graph = dao.getPrefabGraph(g.getName());
Assert.assertEquals(g.getTitle(), graph.getTitle());
} catch (ObjectRetrievalFailureException e) {
Assert.fail(e.getMessage());
}
}
} else {
Assert.fail("The Clavister-MIB.mib file couldn't be parsed successfully.");
}
}
use of org.opennms.netmgt.dao.support.PropertiesGraphDao in project opennms by OpenNMS.
the class GraphResultsControllerTest method setUp.
/**
* Sets the up.
*
* @throws Exception the exception
*/
@Before
public void setUp() throws Exception {
m_service = EasyMock.createMock(GraphResultsService.class);
PropertiesGraphDao graphDao = new PropertiesGraphDao();
graphDao.loadProperties("performance", new FileSystemResource(new File("src/test/resources/etc/snmp-graph.properties")));
List<PrefabGraph> prefabs = graphDao.getAllPrefabGraphs();
Assert.assertNotNull(prefabs);
Assert.assertFalse(prefabs.isEmpty());
EasyMock.expect(m_service.getAllPrefabGraphs(ResourceId.get("node", "1").resolve("nodeSnmp", ""))).andReturn(prefabs.toArray(new PrefabGraph[prefabs.size()])).anyTimes();
m_controller = new GraphResultsController();
m_controller.setGraphResultsService(m_service);
EasyMock.replay(m_service);
}
Aggregations