use of org.opennms.netmgt.config.hardware.HwInventoryAdapterConfiguration in project opennms by OpenNMS.
the class SnmpHardwareInventoryProvisioningAdapterIT method testDiscoverSnmpEntities.
/**
* Test discover SNMP entities.
*
* @throws Exception the exception
*/
@Test
@Transactional
public void testDiscoverSnmpEntities() throws Exception {
HwInventoryAdapterConfiguration config = m_adapter.getHwAdapterConfigDao().getConfiguration();
Assert.assertEquals(3, config.getExtensions().size());
Assert.assertEquals(5, config.getExtensions().get(0).getMibObjects().size());
Assert.assertEquals(12, config.getExtensions().get(1).getMibObjects().size());
Assert.assertEquals(10, config.getExtensions().get(2).getMibObjects().size());
HwExtension ext = config.getExtensions().get(0);
Assert.assertEquals("CISCO-ENTITY-EXT-MIB", ext.getName());
Assert.assertEquals(5, ext.getMibObjects().size());
ext = config.getExtensions().get(1);
Assert.assertEquals("CISCO-ENTITY-ASSET-MIB", ext.getName());
Assert.assertEquals(12, ext.getMibObjects().size());
Assert.assertEquals(27, m_adapter.getVendorAttributeMap().size());
for (TestOperation op : m_operations) {
m_adapter.processPendingOperationForNode(op.operation);
OnmsHwEntity root = m_entityDao.findRootByNodeId(op.nodeId);
Assert.assertNotNull(root);
Assert.assertTrue(root.isRoot());
FileWriter w = new FileWriter("target/" + op.nodeId + ".xml");
JaxbUtils.marshal(root, w);
w.close();
m_nodeDao.flush();
m_entityDao.flush();
}
Assert.assertEquals(112, m_entityDao.countAll());
}
use of org.opennms.netmgt.config.hardware.HwInventoryAdapterConfiguration in project opennms by OpenNMS.
the class DefaultSnmpHwInventoryAdapterConfigDaoTest method testInvalidOid.
/**
* Test invalid replace property.
*
* @throws Exception the exception
*/
@Test
public void testInvalidOid() throws Exception {
initDao("src/test/resources/test-config-01.xml");
emulateReload("src/test/resources/test-config-invalid-02.xml");
HwInventoryAdapterConfiguration cfg = dao.getConfiguration();
HwExtension ext = cfg.getExtensions().get(0);
Assert.assertEquals("CISCO-ENTITY-EXT-MIB", ext.getName());
Assert.assertNotNull(cfg);
}
use of org.opennms.netmgt.config.hardware.HwInventoryAdapterConfiguration in project opennms by OpenNMS.
the class DefaultSnmpHwInventoryAdapterConfigDaoTest method testDuplicateAlias.
/**
* Test duplicate Alias.
*
* @throws Exception the exception
*/
@Test
public void testDuplicateAlias() throws Exception {
initDao("src/test/resources/test-config-02.xml");
HwInventoryAdapterConfiguration cfg = dao.getConfiguration();
HwExtension ext = cfg.getExtensions().get(0);
Assert.assertEquals("CISCO-ENTITY-EXT-MIB", ext.getName());
Assert.assertEquals(5, ext.getMibObjects().size());
Assert.assertNull(ext.getMibObjectByOid(".1.3.6.1.4.1.9.9.195.1.1.1.2"));
}
use of org.opennms.netmgt.config.hardware.HwInventoryAdapterConfiguration in project opennms by OpenNMS.
the class DefaultSnmpHwInventoryAdapterConfigDaoTest method testDuplicateOid.
/**
* Test duplicate OID.
*
* @throws Exception the exception
*/
@Test
public void testDuplicateOid() throws Exception {
initDao("src/test/resources/test-config-01.xml");
HwInventoryAdapterConfiguration cfg = dao.getConfiguration();
HwExtension ext = cfg.getExtensions().get(0);
Assert.assertEquals("CISCO-ENTITY-EXT-MIB", ext.getName());
Assert.assertEquals(5, ext.getMibObjects().size());
Assert.assertNull(ext.getMibObjectByAlias("ceExtNVRAMSize"));
}
use of org.opennms.netmgt.config.hardware.HwInventoryAdapterConfiguration in project opennms by OpenNMS.
the class DefaultSnmpHwInventoryAdapterConfigDaoTest method testInvalidReplaceProperty.
/**
* Test invalid replace property.
*
* @throws Exception the exception
*/
@Test
public void testInvalidReplaceProperty() throws Exception {
initDao("src/test/resources/test-config-01.xml");
emulateReload("src/test/resources/test-config-invalid-01.xml");
HwInventoryAdapterConfiguration cfg = dao.getConfiguration();
HwExtension ext = cfg.getExtensions().get(0);
Assert.assertEquals("CISCO-ENTITY-EXT-MIB", ext.getName());
Assert.assertNotNull(cfg);
}
Aggregations