Search in sources :

Example 6 with HwExtension

use of org.opennms.netmgt.config.hardware.HwExtension 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"));
}
Also used : HwExtension(org.opennms.netmgt.config.hardware.HwExtension) HwInventoryAdapterConfiguration(org.opennms.netmgt.config.hardware.HwInventoryAdapterConfiguration) Test(org.junit.Test)

Example 7 with HwExtension

use of org.opennms.netmgt.config.hardware.HwExtension 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());
}
Also used : OnmsHwEntity(org.opennms.netmgt.model.OnmsHwEntity) HwExtension(org.opennms.netmgt.config.hardware.HwExtension) FileWriter(java.io.FileWriter) HwInventoryAdapterConfiguration(org.opennms.netmgt.config.hardware.HwInventoryAdapterConfiguration) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

HwExtension (org.opennms.netmgt.config.hardware.HwExtension)7 Test (org.junit.Test)5 HwInventoryAdapterConfiguration (org.opennms.netmgt.config.hardware.HwInventoryAdapterConfiguration)5 MibObj (org.opennms.netmgt.config.hardware.MibObj)2 FileWriter (java.io.FileWriter)1 HashSet (java.util.HashSet)1 HwEntityAttributeType (org.opennms.netmgt.model.HwEntityAttributeType)1 OnmsHwEntity (org.opennms.netmgt.model.OnmsHwEntity)1 Transactional (org.springframework.transaction.annotation.Transactional)1