Search in sources :

Example 6 with EventIpcManager

use of org.opennms.netmgt.events.api.EventIpcManager in project opennms by OpenNMS.

the class ThresholdingVisitorIT method setUp.

@Before
public void setUp() throws Exception {
    // Resets Counters Cache Data
    CollectionResourceWrapper.s_cache.clear();
    MockLogAppender.setupLogging();
    m_fileAnticipator = new FileAnticipator();
    m_hrStorageProperties = new HashMap<Integer, File>();
    m_resourceStorageDao = new FilesystemResourceStorageDao();
    m_resourceStorageDao.setRrdDirectory(new File(m_fileAnticipator.getTempDir(), "snmp"));
    m_filterDao = EasyMock.createMock(FilterDao.class);
    EasyMock.expect(m_filterDao.getActiveIPAddressList((String) EasyMock.anyObject())).andReturn(Collections.singletonList(addr("127.0.0.1"))).anyTimes();
    m_filterDao.flushActiveIpAddressListCache();
    EasyMock.expectLastCall().anyTimes();
    FilterDaoFactory.setInstance(m_filterDao);
    EasyMock.replay(m_filterDao);
    m_anticipator = new EventAnticipator();
    MockEventIpcManager eventMgr = new MockEventIpcManager();
    eventMgr.setEventAnticipator(m_anticipator);
    eventMgr.setSynchronous(true);
    EventIpcManager eventdIpcMgr = (EventIpcManager) eventMgr;
    EventIpcManagerFactory.setIpcManager(eventdIpcMgr);
    DateFormat formatter = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss");
    final StringBuilder sb = new StringBuilder("<?xml version=\"1.0\"?>");
    sb.append("<outages>");
    sb.append("<outage name=\"junit outage\" type=\"specific\">");
    sb.append("<time begins=\"");
    sb.append(formatter.format(new Date(System.currentTimeMillis() - 3600000)));
    sb.append("\" ends=\"");
    sb.append(formatter.format(new Date(System.currentTimeMillis() + 3600000)));
    sb.append("\"/>");
    sb.append("<interface address=\"match-any\"/>");
    sb.append("</outage>");
    sb.append("</outages>");
    File file = new File("target/poll-outages.xml");
    FileWriter writer = new FileWriter(file);
    writer.write(sb.toString());
    writer.close();
    PollOutagesConfigFactory.setInstance(new PollOutagesConfigFactory(new FileSystemResource(file)));
    PollOutagesConfigFactory.getInstance().afterPropertiesSet();
    initFactories("/threshd-configuration.xml", "/test-thresholds.xml");
    m_anticipatedEvents = new ArrayList<>();
}
Also used : MockEventIpcManager(org.opennms.netmgt.dao.mock.MockEventIpcManager) FileWriter(java.io.FileWriter) PollOutagesConfigFactory(org.opennms.netmgt.config.PollOutagesConfigFactory) FilesystemResourceStorageDao(org.opennms.netmgt.dao.support.FilesystemResourceStorageDao) FileSystemResource(org.springframework.core.io.FileSystemResource) Date(java.util.Date) EventAnticipator(org.opennms.netmgt.dao.mock.EventAnticipator) BigInteger(java.math.BigInteger) FilterDao(org.opennms.netmgt.filter.api.FilterDao) JdbcFilterDao(org.opennms.netmgt.filter.JdbcFilterDao) EventIpcManager(org.opennms.netmgt.events.api.EventIpcManager) MockEventIpcManager(org.opennms.netmgt.dao.mock.MockEventIpcManager) DateFormat(java.text.DateFormat) SimpleDateFormat(java.text.SimpleDateFormat) FileAnticipator(org.opennms.test.FileAnticipator) File(java.io.File) SimpleDateFormat(java.text.SimpleDateFormat) Before(org.junit.Before)

Aggregations

EventIpcManager (org.opennms.netmgt.events.api.EventIpcManager)6 File (java.io.File)2 Before (org.junit.Before)2 PollOutagesConfigFactory (org.opennms.netmgt.config.PollOutagesConfigFactory)2 FilterDao (org.opennms.netmgt.filter.api.FilterDao)2 PropertyVetoException (java.beans.PropertyVetoException)1 FileWriter (java.io.FileWriter)1 IOException (java.io.IOException)1 UndeclaredThrowableException (java.lang.reflect.UndeclaredThrowableException)1 BigInteger (java.math.BigInteger)1 InetAddress (java.net.InetAddress)1 SQLException (java.sql.SQLException)1 DateFormat (java.text.DateFormat)1 SimpleDateFormat (java.text.SimpleDateFormat)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 DefaultServiceCollectorRegistry (org.opennms.netmgt.collection.support.DefaultServiceCollectorRegistry)1 ThresholdingConfigFactory (org.opennms.netmgt.config.ThresholdingConfigFactory)1 IpInterfaceDao (org.opennms.netmgt.dao.api.IpInterfaceDao)1 NodeDao (org.opennms.netmgt.dao.api.NodeDao)1