Search in sources :

Example 16 with MockEventIpcManager

use of org.opennms.netmgt.dao.mock.MockEventIpcManager in project opennms by OpenNMS.

the class PollerIT method setUp.

// 
// SetUp and TearDown
// 
@Before
public void setUp() throws Exception {
    MockUtil.println("------------ Begin Test  --------------------------");
    MockLogAppender.setupLogging();
    m_network = new MockNetwork();
    m_network.setCriticalService("ICMP");
    m_network.addNode(1, "Router");
    m_network.addInterface("192.168.1.1");
    m_network.addService("ICMP");
    m_network.addService("SMTP");
    m_network.addService("SNMP");
    m_network.addInterface("192.168.1.2");
    m_network.addService("ICMP");
    m_network.addService("SMTP");
    m_network.addNode(2, "Server");
    m_network.addInterface("192.168.1.3");
    m_network.addService("ICMP");
    m_network.addService("HTTP");
    m_network.addService("SMTP");
    m_network.addService("SNMP");
    m_network.addNode(3, "Firewall");
    m_network.addInterface("192.168.1.4");
    m_network.addService("SMTP");
    m_network.addService("HTTP");
    m_network.addInterface("192.168.1.5");
    m_network.addService("SMTP");
    m_network.addService("HTTP");
    m_network.addNode(4, "DownNode");
    m_network.addInterface("192.168.1.6");
    m_network.addService("SNMP");
    m_network.addNode(5, "Loner");
    m_network.addInterface("192.168.1.7");
    m_network.addService("ICMP");
    m_network.addService("SNMP");
    MockService unmonitoredService = m_network.addService("NotMonitored");
    m_db.populate(m_network);
    DataSourceFactory.setInstance(m_db);
    m_pollerConfig = new MockPollerConfig(m_network);
    m_pollerConfig.setNextOutageIdSql(m_db.getNextOutageIdStatement());
    m_pollerConfig.setNodeOutageProcessingEnabled(true);
    m_pollerConfig.setCriticalService("ICMP");
    m_pollerConfig.addPackage("TestPackage");
    m_pollerConfig.addDowntime(1000L, 0L, -1L, false);
    m_pollerConfig.setDefaultPollInterval(1000L);
    m_pollerConfig.populatePackage(m_network, unmonitoredService);
    m_pollerConfig.addPackage("TestPkg2");
    m_pollerConfig.addDowntime(1000L, 0L, -1L, false);
    m_pollerConfig.setDefaultPollInterval(2000L);
    m_pollerConfig.addService(m_network.getService(2, "192.168.1.3", "HTTP"));
    m_outageAnticipator = new OutageAnticipator(m_db);
    m_eventMgr = new MockEventIpcManager();
    m_eventMgr.setEventWriter(m_db);
    m_eventMgr.setEventAnticipator(m_eventMgr.getEventAnticipator());
    m_eventMgr.addEventListener(m_outageAnticipator);
    m_eventMgr.setSynchronous(false);
    m_eventMgr.setNumSchedulerThreads(2);
    m_locationAwarePingClient = mock(LocationAwarePingClient.class);
    DefaultPollContext pollContext = new DefaultPollContext();
    pollContext.setEventManager(m_eventMgr);
    pollContext.setLocalHostName("localhost");
    pollContext.setName("Test.DefaultPollContext");
    pollContext.setPollerConfig(m_pollerConfig);
    pollContext.setQueryManager(m_queryManager);
    pollContext.setLocationAwarePingClient(m_locationAwarePingClient);
    PollableNetwork network = new PollableNetwork(pollContext);
    m_poller = new Poller();
    m_poller.setMonitoredServiceDao(m_monitoredServiceDao);
    m_poller.setOutageDao(m_outageDao);
    m_poller.setTransactionTemplate(m_transactionTemplate);
    m_poller.setEventIpcManager(m_eventMgr);
    m_poller.setNetwork(network);
    m_poller.setQueryManager(m_queryManager);
    m_poller.setPollerConfig(m_pollerConfig);
    m_poller.setPollOutagesConfig(m_pollerConfig);
    m_poller.setLocationAwarePollerClient(m_locationAwarePollerClient);
}
Also used : LocationAwarePingClient(org.opennms.netmgt.icmp.proxy.LocationAwarePingClient) MockNetwork(org.opennms.netmgt.mock.MockNetwork) MockEventIpcManager(org.opennms.netmgt.dao.mock.MockEventIpcManager) MockService(org.opennms.netmgt.mock.MockService) OutageAnticipator(org.opennms.netmgt.mock.OutageAnticipator) MockPollerConfig(org.opennms.netmgt.mock.MockPollerConfig) PollableNetwork(org.opennms.netmgt.poller.pollables.PollableNetwork) Before(org.junit.Before)

Example 17 with MockEventIpcManager

use of org.opennms.netmgt.dao.mock.MockEventIpcManager in project opennms by OpenNMS.

the class AMQPEventReceiverBlueprintTest method addServicesOnStartup.

@SuppressWarnings("rawtypes")
@Override
protected void addServicesOnStartup(Map<String, KeyValueHolder<Object, Dictionary>> services) {
    MockEventIpcManager mockEventIpcManager = new MockEventIpcManager();
    services.put(EventIpcManager.class.getName(), asService(mockEventIpcManager, null));
    MockNodeDao mockNodeDao = new MockNodeDao();
    services.put(NodeDao.class.getName(), asService(mockNodeDao, null));
}
Also used : MockNodeDao(org.opennms.netmgt.dao.mock.MockNodeDao) NodeDao(org.opennms.netmgt.dao.api.NodeDao) MockNodeDao(org.opennms.netmgt.dao.mock.MockNodeDao) EventIpcManager(org.opennms.netmgt.events.api.EventIpcManager) MockEventIpcManager(org.opennms.netmgt.dao.mock.MockEventIpcManager) MockEventIpcManager(org.opennms.netmgt.dao.mock.MockEventIpcManager)

Example 18 with MockEventIpcManager

use of org.opennms.netmgt.dao.mock.MockEventIpcManager in project opennms by OpenNMS.

the class AMQPEventForwarderBlueprintTest method addServicesOnStartup.

@SuppressWarnings("rawtypes")
@Override
protected void addServicesOnStartup(Map<String, KeyValueHolder<Object, Dictionary>> services) {
    MockEventIpcManager mockEventIpcManager = new MockEventIpcManager();
    services.put(EventIpcManager.class.getName(), asService(mockEventIpcManager, null));
    MockNodeDao mockNodeDao = new MockNodeDao();
    services.put(NodeDao.class.getName(), asService(mockNodeDao, null));
}
Also used : MockNodeDao(org.opennms.netmgt.dao.mock.MockNodeDao) NodeDao(org.opennms.netmgt.dao.api.NodeDao) MockNodeDao(org.opennms.netmgt.dao.mock.MockNodeDao) EventIpcManager(org.opennms.netmgt.events.api.EventIpcManager) MockEventIpcManager(org.opennms.netmgt.dao.mock.MockEventIpcManager) MockEventIpcManager(org.opennms.netmgt.dao.mock.MockEventIpcManager)

Example 19 with MockEventIpcManager

use of org.opennms.netmgt.dao.mock.MockEventIpcManager in project opennms by OpenNMS.

the class EifAdapterBlueprintTest method addServicesOnStartup.

@SuppressWarnings("rawtypes")
@Override
protected void addServicesOnStartup(Map<String, KeyValueHolder<Object, Dictionary>> services) {
    MockEventIpcManager mockEventIpcManager = new MockEventIpcManager();
    MockNodeDao mockNodeDao = new MockNodeDao();
    services.put(EventIpcManager.class.getName(), asService(mockEventIpcManager, null));
    services.put(NodeDao.class.getName(), asService(mockNodeDao, null));
}
Also used : MockNodeDao(org.opennms.netmgt.dao.mock.MockNodeDao) NodeDao(org.opennms.netmgt.dao.api.NodeDao) MockNodeDao(org.opennms.netmgt.dao.mock.MockNodeDao) EventIpcManager(org.opennms.netmgt.events.api.EventIpcManager) MockEventIpcManager(org.opennms.netmgt.dao.mock.MockEventIpcManager) MockEventIpcManager(org.opennms.netmgt.dao.mock.MockEventIpcManager)

Example 20 with MockEventIpcManager

use of org.opennms.netmgt.dao.mock.MockEventIpcManager in project opennms by OpenNMS.

the class BroadcastEventProcessorTest method testReloadDaemonConfig.

public void testReloadDaemonConfig() {
    MockEventIpcManager eventIpcManager = new MockEventIpcManager();
    BroadcastEventProcessor processor = new BroadcastEventProcessor(eventIpcManager, m_eventConfDao);
    EventBuilder eventBuilder = new EventBuilder(EventConstants.RELOAD_DAEMON_CONFIG_UEI, "dunno");
    eventBuilder.addParam(EventConstants.PARM_DAEMON_NAME, "Eventd");
    // Expect a call to reload the EventConfDao
    m_eventConfDao.reload();
    m_mocks.replayAll();
    processor.onEvent(eventBuilder.getEvent());
    m_mocks.verifyAll();
}
Also used : EventBuilder(org.opennms.netmgt.model.events.EventBuilder) MockEventIpcManager(org.opennms.netmgt.dao.mock.MockEventIpcManager)

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