Search in sources :

Example 1 with HwInventoryAdapterConfiguration

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());
}
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)

Example 2 with HwInventoryAdapterConfiguration

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

Example 3 with HwInventoryAdapterConfiguration

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

Example 4 with HwInventoryAdapterConfiguration

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

Example 5 with HwInventoryAdapterConfiguration

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

Aggregations

Test (org.junit.Test)5 HwExtension (org.opennms.netmgt.config.hardware.HwExtension)5 HwInventoryAdapterConfiguration (org.opennms.netmgt.config.hardware.HwInventoryAdapterConfiguration)5 FileWriter (java.io.FileWriter)1 OnmsHwEntity (org.opennms.netmgt.model.OnmsHwEntity)1 Transactional (org.springframework.transaction.annotation.Transactional)1