Search in sources :

Example 26 with MockEventIpcManager

use of org.opennms.netmgt.dao.mock.MockEventIpcManager 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");
    StringBuffer sb = new StringBuffer("<?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<Event>();
}
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) Event(org.opennms.netmgt.xml.event.Event) FileAnticipator(org.opennms.test.FileAnticipator) File(java.io.File) SimpleDateFormat(java.text.SimpleDateFormat) Before(org.junit.Before)

Aggregations

MockEventIpcManager (org.opennms.netmgt.dao.mock.MockEventIpcManager)26 Before (org.junit.Before)14 NodeDao (org.opennms.netmgt.dao.api.NodeDao)5 MockPollerConfig (org.opennms.netmgt.mock.MockPollerConfig)5 EasyMockUtils (org.opennms.test.mock.EasyMockUtils)5 EventIpcManager (org.opennms.netmgt.events.api.EventIpcManager)4 MockNetwork (org.opennms.netmgt.mock.MockNetwork)4 OutageAnticipator (org.opennms.netmgt.mock.OutageAnticipator)4 File (java.io.File)3 PollOutagesConfigFactory (org.opennms.netmgt.config.PollOutagesConfigFactory)3 MockNodeDao (org.opennms.netmgt.dao.mock.MockNodeDao)3 FilterDao (org.opennms.netmgt.filter.api.FilterDao)3 LocationAwarePingClient (org.opennms.netmgt.icmp.proxy.LocationAwarePingClient)3 MockPersisterFactory (org.opennms.netmgt.mock.MockPersisterFactory)3 NetworkBuilder (org.opennms.netmgt.model.NetworkBuilder)3 OnmsServiceType (org.opennms.netmgt.model.OnmsServiceType)3 PollableNetwork (org.opennms.netmgt.poller.pollables.PollableNetwork)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 InputStream (java.io.InputStream)2 Date (java.util.Date)2