Search in sources :

Example 1 with MockTimer

use of org.opennms.netmgt.poller.mock.MockTimer in project opennms by OpenNMS.

the class PollablesIT method setUp.

@Before
public void setUp() throws Exception {
    DaoTestConfigBean bean = new DaoTestConfigBean();
    bean.afterPropertiesSet();
    MockUtil.println("------------ Begin Test --------------------------");
    MockLogAppender.setupLogging();
    m_lockCount = 0;
    m_mockNetwork = new MockNetwork();
    m_mockNetwork.addNode(1, "Router");
    m_mockNetwork.addInterface("192.168.1.1");
    m_mockNetwork.addService("ICMP");
    m_mockNetwork.addService("SMTP");
    m_mockNetwork.addInterface("192.168.1.2");
    m_mockNetwork.addService("ICMP");
    m_mockNetwork.addService("SMTP");
    m_mockNetwork.addNode(2, "Server");
    m_mockNetwork.addInterface("192.168.1.3");
    m_mockNetwork.addService("ICMP");
    m_mockNetwork.addService("HTTP");
    m_mockNetwork.addNode(3, "Firewall");
    m_mockNetwork.addInterface("192.168.1.4");
    m_mockNetwork.addService("SMTP");
    m_mockNetwork.addService("HTTP");
    m_mockNetwork.addInterface("192.168.1.5");
    m_mockNetwork.addService("SMTP");
    m_mockNetwork.addService("SNMP");
    m_db = new MockDatabase();
    m_db.populate(m_mockNetwork);
    m_outageAnticipator = new OutageAnticipator(m_db);
    m_eventMgr = new MockEventIpcManager();
    m_eventMgr.setEventWriter(m_db);
    m_eventMgr.addEventListener(m_outageAnticipator);
    m_pollContext = new MockPollContext();
    m_pollContext.setDatabase(m_db);
    m_pollContext.setCriticalServiceName("ICMP");
    m_pollContext.setNodeProcessingEnabled(true);
    m_pollContext.setPollingAllIfCritServiceUndefined(true);
    m_pollContext.setServiceUnresponsiveEnabled(true);
    m_pollContext.setEventMgr(m_eventMgr);
    m_pollContext.setMockNetwork(m_mockNetwork);
    m_pollerConfig = new MockPollerConfig(m_mockNetwork);
    m_pollerConfig.setNodeOutageProcessingEnabled(true);
    m_pollerConfig.setCriticalService("ICMP");
    m_pollerConfig.addPackage("TestPackage");
    m_pollerConfig.addDowntime(100L, 0L, 500L, false);
    m_pollerConfig.addDowntime(200L, 500L, 1500L, false);
    m_pollerConfig.addDowntime(500L, 1500L, -1L, true);
    m_pollerConfig.setDefaultPollInterval(1000L);
    m_pollerConfig.populatePackage(m_mockNetwork);
    m_pollerConfig.addPackage("TestPkg2");
    m_pollerConfig.addDowntime(500L, 0L, 1000L, false);
    m_pollerConfig.addDowntime(500L, 1000L, -1L, true);
    m_pollerConfig.setDefaultPollInterval(2000L);
    m_pollerConfig.addService(m_mockNetwork.getService(2, "192.168.1.3", "HTTP"));
    m_timer = new MockTimer();
    m_scheduler = new MockScheduler(m_timer);
    m_network = createPollableNetwork(m_db, m_scheduler, m_pollerConfig, m_pollerConfig, m_pollContext);
    // set members to make the tests easier
    mNode1 = m_mockNetwork.getNode(1);
    mDot1 = mNode1.getInterface("192.168.1.1");
    mDot1Smtp = mDot1.getService("SMTP");
    mDot1Icmp = mDot1.getService("ICMP");
    mDot2 = mNode1.getInterface("192.168.1.2");
    mDot2Icmp = mDot2.getService("ICMP");
    mNode2 = m_mockNetwork.getNode(2);
    mDot3 = mNode2.getInterface("192.168.1.3");
    mDot3Http = mDot3.getService("HTTP");
    mNode3 = m_mockNetwork.getNode(3);
    mDot4 = mNode3.getInterface("192.168.1.4");
    mDot4Smtp = mDot4.getService("SMTP");
    mDot4Http = mDot4.getService("HTTP");
    assignPollableMembers(m_network);
}
Also used : DaoTestConfigBean(org.opennms.test.DaoTestConfigBean) MockScheduler(org.opennms.netmgt.poller.mock.MockScheduler) MockTimer(org.opennms.netmgt.poller.mock.MockTimer) MockNetwork(org.opennms.netmgt.mock.MockNetwork) MockPollContext(org.opennms.netmgt.poller.mock.MockPollContext) MockEventIpcManager(org.opennms.netmgt.dao.mock.MockEventIpcManager) MockDatabase(org.opennms.core.test.db.MockDatabase) OutageAnticipator(org.opennms.netmgt.mock.OutageAnticipator) MockPollerConfig(org.opennms.netmgt.mock.MockPollerConfig) Before(org.junit.Before)

Aggregations

Before (org.junit.Before)1 MockDatabase (org.opennms.core.test.db.MockDatabase)1 MockEventIpcManager (org.opennms.netmgt.dao.mock.MockEventIpcManager)1 MockNetwork (org.opennms.netmgt.mock.MockNetwork)1 MockPollerConfig (org.opennms.netmgt.mock.MockPollerConfig)1 OutageAnticipator (org.opennms.netmgt.mock.OutageAnticipator)1 MockPollContext (org.opennms.netmgt.poller.mock.MockPollContext)1 MockScheduler (org.opennms.netmgt.poller.mock.MockScheduler)1 MockTimer (org.opennms.netmgt.poller.mock.MockTimer)1 DaoTestConfigBean (org.opennms.test.DaoTestConfigBean)1