Search in sources :

Example 1 with DefaultEventConfDao

use of org.opennms.netmgt.config.DefaultEventConfDao in project opennms by OpenNMS.

the class BsmdIT method verifyStartupWithChangedReductionKey.

@Test
public void verifyStartupWithChangedReductionKey() throws Exception {
    // Load custom events
    DefaultEventConfDao eventConfDao = new DefaultEventConfDao();
    eventConfDao.setConfigResource(new ClassPathResource("/eventconf.xml"));
    eventConfDao.afterPropertiesSet();
    // change reduction key
    REQUIRED_EVENT_UEIS.forEach(uei -> eventConfDao.getEvents(uei).get(0).getAlarmData().setReductionKey("custom"));
    // verify that reduction key actually changed
    REQUIRED_EVENT_UEIS.forEach(uei -> Assert.assertEquals("custom", eventConfDao.getEvents(uei).get(0).getAlarmData().getReductionKey()));
    m_bsmd.setEventConfDao(eventConfDao);
    m_bsmd.setVerifyReductionKeys(true);
    m_bsmd.start();
}
Also used : DefaultEventConfDao(org.opennms.netmgt.config.DefaultEventConfDao) ClassPathResource(org.springframework.core.io.ClassPathResource) Test(org.junit.Test)

Example 2 with DefaultEventConfDao

use of org.opennms.netmgt.config.DefaultEventConfDao in project opennms by OpenNMS.

the class BsmdIT method verifyStartupWithoutAlarmData.

@Test
public void verifyStartupWithoutAlarmData() throws Exception {
    // Load custom events
    DefaultEventConfDao eventConfDao = new DefaultEventConfDao();
    eventConfDao.setConfigResource(new ClassPathResource("/eventconf.xml"));
    eventConfDao.afterPropertiesSet();
    // Remove Alarm Data
    REQUIRED_EVENT_UEIS.forEach(eventUei -> eventConfDao.getEvents(eventUei).get(0).setAlarmData(null));
    // Verify that the alarm data is actually null
    m_bsmd.setEventConfDao(eventConfDao);
    REQUIRED_EVENT_UEIS.forEach(eventUei -> {
        Assert.assertEquals(1, m_bsmd.getEventConfDao().getEvents(eventUei).size());
        Assert.assertNull(m_bsmd.getEventConfDao().getEvents(eventUei).get(0).getAlarmData());
    });
    // Verify start up with null alarm data
    m_bsmd.setVerifyReductionKeys(true);
    m_bsmd.start();
}
Also used : DefaultEventConfDao(org.opennms.netmgt.config.DefaultEventConfDao) ClassPathResource(org.springframework.core.io.ClassPathResource) Test(org.junit.Test)

Example 3 with DefaultEventConfDao

use of org.opennms.netmgt.config.DefaultEventConfDao in project opennms by OpenNMS.

the class EventFormTest method setUp.

/**
 * Sets the up.
 *
 * @throws Exception the exception
 */
@Before
public void setUp() throws Exception {
    File config = new File(ConfigurationTestUtils.getDaemonEtcDirectory(), "events/MPLS.events.xml");
    Assert.assertTrue(config.exists());
    dao = new DefaultEventConfDao();
    dao.setConfigResource(new FileSystemResource(config));
    dao.afterPropertiesSet();
}
Also used : FileSystemResource(org.springframework.core.io.FileSystemResource) DefaultEventConfDao(org.opennms.netmgt.config.DefaultEventConfDao) File(java.io.File) Before(org.junit.Before)

Example 4 with DefaultEventConfDao

use of org.opennms.netmgt.config.DefaultEventConfDao in project opennms by OpenNMS.

the class OpenNMSITCase method setUp.

@Before
public void setUp() throws Exception {
    MockUtil.println("------------ Begin Test " + this + " --------------------------");
    MockLogAppender.setupLogging();
    if (m_runSupers) {
        createMockNetwork();
        populateDatabase();
        DataSourceFactory.setInstance(m_db);
        SnmpPeerFactory.setInstance(new SnmpPeerFactory(new ByteArrayResource(getSnmpConfig().getBytes())));
        if (isStartEventd()) {
            m_eventdIpcMgr = new EventIpcManagerDefaultImpl(m_registry);
            EventUtilJdbcImpl eventUtil = new EventUtilJdbcImpl();
            AbstractEventUtil.setInstance(eventUtil);
            JdbcEventdServiceManager eventdServiceManager = new JdbcEventdServiceManager();
            eventdServiceManager.setDataSource(m_db);
            eventdServiceManager.afterPropertiesSet();
            /*
                 * Make sure we specify a full resource path since "this" is
                 * the unit test class, which is most likely in another package. 
                 */
            File configFile = ConfigurationTestUtils.getFileForResource(this, "/org/opennms/netmgt/mock/eventconf.xml");
            DefaultEventConfDao eventConfDao = new DefaultEventConfDao();
            eventConfDao.setConfigResource(new FileSystemResource(configFile));
            eventConfDao.afterPropertiesSet();
            EventExpander eventExpander = new EventExpander(m_registry);
            eventExpander.setEventConfDao(eventConfDao);
            eventExpander.setEventUtil(eventUtil);
            eventExpander.afterPropertiesSet();
            EventIpcBroadcastProcessor eventIpcBroadcastProcessor = new EventIpcBroadcastProcessor(m_registry);
            eventIpcBroadcastProcessor.setEventIpcBroadcaster(m_eventdIpcMgr);
            eventIpcBroadcastProcessor.afterPropertiesSet();
            List<EventProcessor> eventProcessors = new ArrayList<EventProcessor>(3);
            eventProcessors.add(eventExpander);
            eventProcessors.add(eventIpcBroadcastProcessor);
            DefaultEventHandlerImpl eventHandler = new DefaultEventHandlerImpl(m_registry);
            eventHandler.setEventProcessors(eventProcessors);
            eventHandler.afterPropertiesSet();
            m_eventdIpcMgr.setHandlerPoolSize(5);
            m_eventdIpcMgr.setEventHandler(eventHandler);
            m_eventdIpcMgr.afterPropertiesSet();
            m_eventProxy = m_eventdIpcMgr;
            EventIpcManagerFactory.setIpcManager(m_eventdIpcMgr);
            EventIpcManagerEventHandlerProxy proxy = new EventIpcManagerEventHandlerProxy();
            proxy.setEventIpcManager(m_eventdIpcMgr);
            proxy.afterPropertiesSet();
            List<EventHandler> eventHandlers = new ArrayList<EventHandler>(1);
            eventHandlers.add(proxy);
            m_eventd = new Eventd();
            m_eventd.setEventdServiceManager(eventdServiceManager);
            m_eventd.setReceiver(new BroadcastEventProcessor(m_eventdIpcMgr, eventConfDao));
            m_eventd.init();
            m_eventd.start();
        }
    }
    m_transMgr = new DataSourceTransactionManager(DataSourceFactory.getInstance());
}
Also used : EventExpander(org.opennms.netmgt.eventd.EventExpander) EventIpcManagerEventHandlerProxy(org.opennms.netmgt.eventd.adaptors.EventIpcManagerEventHandlerProxy) JdbcEventdServiceManager(org.opennms.netmgt.dao.mock.JdbcEventdServiceManager) Eventd(org.opennms.netmgt.eventd.Eventd) SnmpPeerFactory(org.opennms.netmgt.config.SnmpPeerFactory) ArrayList(java.util.ArrayList) EventHandler(org.opennms.netmgt.eventd.adaptors.EventHandler) ByteArrayResource(org.springframework.core.io.ByteArrayResource) EventIpcManagerDefaultImpl(org.opennms.netmgt.eventd.EventIpcManagerDefaultImpl) FileSystemResource(org.springframework.core.io.FileSystemResource) DefaultEventConfDao(org.opennms.netmgt.config.DefaultEventConfDao) DefaultEventHandlerImpl(org.opennms.netmgt.eventd.DefaultEventHandlerImpl) EventIpcBroadcastProcessor(org.opennms.netmgt.eventd.processor.EventIpcBroadcastProcessor) BroadcastEventProcessor(org.opennms.netmgt.eventd.BroadcastEventProcessor) EventProcessor(org.opennms.netmgt.events.api.EventProcessor) BroadcastEventProcessor(org.opennms.netmgt.eventd.BroadcastEventProcessor) File(java.io.File) DataSourceTransactionManager(org.springframework.jdbc.datasource.DataSourceTransactionManager) Before(org.junit.Before)

Aggregations

DefaultEventConfDao (org.opennms.netmgt.config.DefaultEventConfDao)4 File (java.io.File)2 Before (org.junit.Before)2 Test (org.junit.Test)2 ClassPathResource (org.springframework.core.io.ClassPathResource)2 FileSystemResource (org.springframework.core.io.FileSystemResource)2 ArrayList (java.util.ArrayList)1 SnmpPeerFactory (org.opennms.netmgt.config.SnmpPeerFactory)1 JdbcEventdServiceManager (org.opennms.netmgt.dao.mock.JdbcEventdServiceManager)1 BroadcastEventProcessor (org.opennms.netmgt.eventd.BroadcastEventProcessor)1 DefaultEventHandlerImpl (org.opennms.netmgt.eventd.DefaultEventHandlerImpl)1 EventExpander (org.opennms.netmgt.eventd.EventExpander)1 EventIpcManagerDefaultImpl (org.opennms.netmgt.eventd.EventIpcManagerDefaultImpl)1 Eventd (org.opennms.netmgt.eventd.Eventd)1 EventHandler (org.opennms.netmgt.eventd.adaptors.EventHandler)1 EventIpcManagerEventHandlerProxy (org.opennms.netmgt.eventd.adaptors.EventIpcManagerEventHandlerProxy)1 EventIpcBroadcastProcessor (org.opennms.netmgt.eventd.processor.EventIpcBroadcastProcessor)1 EventProcessor (org.opennms.netmgt.events.api.EventProcessor)1 ByteArrayResource (org.springframework.core.io.ByteArrayResource)1 DataSourceTransactionManager (org.springframework.jdbc.datasource.DataSourceTransactionManager)1