use of org.opennms.netmgt.config.EventTranslatorConfigFactory in project opennms by OpenNMS.
the class EventTranslatorIT method testTranslateLinkDown.
@Test
public void testTranslateLinkDown() throws SQLException, IOException {
InputStream rdr = new ByteArrayInputStream(getLinkDownTranslation().getBytes(StandardCharsets.UTF_8));
m_config = new EventTranslatorConfigFactory(rdr, m_db);
EventTranslatorConfigFactory.setInstance(m_config);
m_translator = EventTranslator.getInstance();
m_translator.setEventManager(m_eventMgr);
m_translator.setConfig(EventTranslatorConfigFactory.getInstance());
//m_translator.setDataSource(m_db);
Connection c = m_db.getConnection();
Statement stmt = c.createStatement();
stmt.executeUpdate("update snmpinterface set snmpifname = 'david', snmpifalias = 'p-brane' WHERE nodeid = 1 and snmpifindex = 2");
stmt.close();
c.close();
List<Event> translatedEvents = m_config.translateEvent(createLinkDownEvent());
assertNotNull(translatedEvents);
assertEquals(1, translatedEvents.size());
assertEquals(3, translatedEvents.get(0).getParmCollection().size());
assertEquals(".1.3.6.1.2.1.2.2.1.1.2", translatedEvents.get(0).getParmCollection().get(0).getParmName());
assertEquals("ifName", translatedEvents.get(0).getParmCollection().get(1).getParmName());
assertEquals("ifAlias", translatedEvents.get(0).getParmCollection().get(2).getParmName());
assertEquals("david", translatedEvents.get(0).getParmCollection().get(1).getValue().getContent());
assertEquals("p-brane", translatedEvents.get(0).getParmCollection().get(2).getValue().getContent());
}
use of org.opennms.netmgt.config.EventTranslatorConfigFactory in project opennms by OpenNMS.
the class EventTranslatorIT method setUp.
@Before
public void setUp() throws Exception {
// MockUtil.println("------------ Begin Test "+getName()+" --------------------------");
MockLogAppender.setupLogging();
createMockNetwork();
createMockDb();
createAnticipators();
m_eventMgr = new MockEventIpcManager();
m_eventMgr.setEventWriter(m_db);
m_eventMgr.addEventListener(m_outageAnticipator);
m_eventMgr.setSynchronous(true);
InputStream rdr = new ByteArrayInputStream(m_passiveStatusConfiguration.getBytes(StandardCharsets.UTF_8));
m_config = new EventTranslatorConfigFactory(rdr, m_db);
EventTranslatorConfigFactory.setInstance(m_config);
m_translator = EventTranslator.getInstance();
m_translator.setEventManager(m_eventMgr);
m_translator.setConfig(EventTranslatorConfigFactory.getInstance());
m_translator.setDataSource(m_db);
m_translator.init();
m_translator.start();
}
Aggregations