Search in sources :

Example 6 with MockEventIpcManager

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

the class PollerBackEndTest method setUp.

@Override
protected void setUp() throws Exception {
    System.setProperty("opennms.home", "src/test/test-configurations/PollerBackEndTest-home");
    m_monitoringLocationDao = m_mocks.createMock(MonitoringLocationDao.class);
    m_locMonDao = m_mocks.createMock(LocationMonitorDao.class);
    m_scanReportDao = m_mocks.createMock(ScanReportDao.class);
    m_monSvcDao = m_mocks.createMock(MonitoredServiceDao.class);
    m_pollerConfig = m_mocks.createMock(PollerConfig.class);
    m_timeKeeper = m_mocks.createMock(TimeKeeper.class);
    m_eventIpcManager = new MockEventIpcManager();
    m_backEnd = new DefaultPollerBackEnd();
    m_backEnd.setMonitoringLocationDao(m_monitoringLocationDao);
    m_backEnd.setLocationMonitorDao(m_locMonDao);
    m_backEnd.setScanReportDao(m_scanReportDao);
    m_backEnd.setMonitoredServiceDao(m_monSvcDao);
    m_backEnd.setPollerConfig(m_pollerConfig);
    m_backEnd.setTimeKeeper(m_timeKeeper);
    m_backEnd.setEventIpcManager(m_eventIpcManager);
    m_backEnd.setDisconnectedTimeout(DISCONNECTED_TIMEOUT);
    m_backEnd.setPersisterFactory(new MockPersisterFactory());
    m_startTime = new Date(System.currentTimeMillis() - 600000);
    expect(m_timeKeeper.getCurrentDate()).andReturn(m_startTime);
    replay(m_timeKeeper);
    m_backEnd.afterPropertiesSet();
    verify(m_timeKeeper);
    reset(m_timeKeeper);
    // set up some objects that can be used to mock up the tests
    // the location definition
    m_locationDefinition = new OnmsMonitoringLocation();
    m_locationDefinition.setMonitoringArea("Oakland");
    m_locationDefinition.setLocationName("OAK");
    m_locationDefinition.setPollingPackageNames(Collections.singletonList("OAKPackage"));
    m_package = createPackage("OAKPackage", "ipaddr = '192.168.1.1'");
    m_serviceSelector = new ServiceSelector(m_package.getFilter().getContent(), Arrays.asList(new String[] { "HTTP", "DNS" }));
    m_httpSvcConfig = addService(m_package, "HTTP", 1234, "url", "http://www.opennms.org");
    m_dnsSvcConfig = addService(m_package, "DNS", 5678, "hostname", "www.opennms.org");
    m_locationMonitor = new OnmsLocationMonitor();
    m_locationMonitor.setId(LOCATION_MONITOR_ID);
    m_locationMonitor.setLocation(m_locationDefinition.getLocationName());
    OnmsApplication application = new OnmsApplication();
    application.setName(APPLICATION_NAME);
    NetworkBuilder builder = new NetworkBuilder();
    builder.addNode("testNode").setId(1);
    builder.addInterface("192.168.1.1").setId(1);
    m_httpService = builder.addService(new OnmsServiceType("HTTP"));
    m_httpService.setId(1);
    m_httpService.setApplications(Collections.singleton(application));
    m_dnsService = builder.addService(new OnmsServiceType("DNS"));
    m_dnsService.setId(2);
    m_dnsService.setApplications(Collections.singleton(application));
    m_monServices = new OnmsMonitoredService[] { m_httpService, m_dnsService };
    long now = System.currentTimeMillis();
    PollStatus httpResult = PollStatus.available(1000.0);
    httpResult.setTimestamp(new Date(now - 300000));
    m_httpCurrentStatus = new OnmsLocationSpecificStatus(m_locationMonitor, m_httpService, httpResult);
    m_httpCurrentStatus.setId(1);
    PollStatus dnsResult = PollStatus.unavailable("Non responsive");
    dnsResult.setTimestamp(new Date(now - 300000));
    m_dnsCurrentStatus = new OnmsLocationSpecificStatus(m_locationMonitor, m_dnsService, dnsResult);
    m_dnsCurrentStatus.setId(2);
    m_pollerDetails = new HashMap<String, String>();
    m_pollerDetails.put("os.name", "WonkaOS");
    m_pollerDetails.put("os.version", "1.2.3");
}
Also used : PollStatus(org.opennms.netmgt.poller.PollStatus) TimeKeeper(org.opennms.netmgt.collection.api.TimeKeeper) MockEventIpcManager(org.opennms.netmgt.dao.mock.MockEventIpcManager) OnmsLocationSpecificStatus(org.opennms.netmgt.model.OnmsLocationSpecificStatus) ScanReportDao(org.opennms.netmgt.dao.api.ScanReportDao) MonitoredServiceDao(org.opennms.netmgt.dao.api.MonitoredServiceDao) PollerConfig(org.opennms.netmgt.config.PollerConfig) ServiceSelector(org.opennms.netmgt.model.ServiceSelector) MonitoringLocationDao(org.opennms.netmgt.dao.api.MonitoringLocationDao) OnmsApplication(org.opennms.netmgt.model.OnmsApplication) LocationMonitorDao(org.opennms.netmgt.dao.api.LocationMonitorDao) DefaultPollerBackEnd(org.opennms.netmgt.poller.remote.support.DefaultPollerBackEnd) Date(java.util.Date) NetworkBuilder(org.opennms.netmgt.model.NetworkBuilder) OnmsServiceType(org.opennms.netmgt.model.OnmsServiceType) MockPersisterFactory(org.opennms.netmgt.mock.MockPersisterFactory) OnmsLocationMonitor(org.opennms.netmgt.model.OnmsLocationMonitor) OnmsMonitoringLocation(org.opennms.netmgt.model.monitoringLocations.OnmsMonitoringLocation)

Example 7 with MockEventIpcManager

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

the class DroolsTicketerServiceLayerTest method setUp.

@Before
public void setUp() throws Exception {
    m_eventIpcManager = new MockEventIpcManager();
    EventIpcManagerFactory.setIpcManager(m_eventIpcManager);
    MockLogAppender.setupLogging();
    ResourceLoader loader = new DefaultResourceLoader();
    Resource resource = loader.getResource("classpath:/drools-ticketer-rules.drl");
    m_easyMockUtils = new EasyMockUtils();
    m_configDao = m_easyMockUtils.createMock(DroolsTicketerConfigDao.class);
    EasyMock.expect(m_configDao.getRulesFile()).andReturn(resource.getFile()).times(1);
    EasyMock.replay(m_configDao);
    m_alarmDao = m_easyMockUtils.createMock(AlarmDao.class);
    m_ticketerPlugin = m_easyMockUtils.createMock(Plugin.class);
    m_droolsTicketerServiceLayer = new DroolsTicketerServiceLayer(m_configDao);
    m_droolsTicketerServiceLayer.setAlarmDao(m_alarmDao);
    m_droolsTicketerServiceLayer.setTicketerPlugin(m_ticketerPlugin);
    EasyMock.reset(m_configDao);
    m_alarm = new OnmsAlarm();
    m_alarm.setId(1);
    m_alarm.setLogMsg("Test Logmsg");
    m_alarm.setDescription("Test Description");
    m_alarm.setUei("uei.opennms.org/nodes/nodeDown");
    m_ticket = new Ticket();
    m_ticket.setId("4");
}
Also used : ResourceLoader(org.springframework.core.io.ResourceLoader) DefaultResourceLoader(org.springframework.core.io.DefaultResourceLoader) Ticket(org.opennms.api.integration.ticketing.Ticket) MockEventIpcManager(org.opennms.netmgt.dao.mock.MockEventIpcManager) OnmsAlarm(org.opennms.netmgt.model.OnmsAlarm) Resource(org.springframework.core.io.Resource) EasyMockUtils(org.opennms.test.mock.EasyMockUtils) AlarmDao(org.opennms.netmgt.dao.api.AlarmDao) DefaultResourceLoader(org.springframework.core.io.DefaultResourceLoader) Plugin(org.opennms.api.integration.ticketing.Plugin) Before(org.junit.Before)

Example 8 with MockEventIpcManager

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

the class AccessPointMonitordTest method setUp.

@Before
public void setUp() throws Exception {
    // Create our event manager and anticipator
    m_eventMgr = new MockEventIpcManager();
    m_eventMgr.setSynchronous(true);
    // Ensure our annotations are called
    m_adapter = new AnnotationBasedEventListenerAdapter(m_apm, m_eventMgr);
}
Also used : MockEventIpcManager(org.opennms.netmgt.dao.mock.MockEventIpcManager) AnnotationBasedEventListenerAdapter(org.opennms.netmgt.events.api.AnnotationBasedEventListenerAdapter) Before(org.junit.Before)

Example 9 with MockEventIpcManager

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

the class MockNetworkTest method setUp.

@Override
protected void setUp() throws Exception {
    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.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.addInterface("192.168.1.2");
    m_network.addNode(3, "IPv6Server");
    m_network.addInterface("fe80:0000:0000:0000:0000:0000:0000:00ff");
    m_network.addService("ICMP");
    m_network.addService("HTTP");
    m_network.addService("DNS");
    m_eventMgr = new MockEventIpcManager();
    m_pollerConfig = new MockPollerConfig(m_network);
    m_pollerConfig.addPackage("TestPackage");
    m_pollerConfig.addDowntime(1000L, 0L, -1L, false);
    m_pollerConfig.setDefaultPollInterval(1000L);
    m_pollerConfig.populatePackage(m_network);
    m_pollerConfig.setPollInterval("ICMP", 500L);
    m_upChecker = new StatusChecker(PollStatus.up());
    m_downChecker = new StatusChecker(PollStatus.down());
}
Also used : MockEventIpcManager(org.opennms.netmgt.dao.mock.MockEventIpcManager)

Example 10 with MockEventIpcManager

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

the class EventTranslatorIT method setUp.

@Before
public void setUp() throws Exception {
    //        MockUtil.println("------------ Begin Test "+getName()+" --------------------------");
    MockLogAppender.setupLogging();
    createMockNetwork();
    createMockDb();
    createAnticipators();
    m_eventMgr = new MockEventIpcManager();
    m_eventMgr.setEventWriter(m_db);
    m_eventMgr.addEventListener(m_outageAnticipator);
    m_eventMgr.setSynchronous(true);
    InputStream rdr = new ByteArrayInputStream(m_passiveStatusConfiguration.getBytes(StandardCharsets.UTF_8));
    m_config = new EventTranslatorConfigFactory(rdr, m_db);
    EventTranslatorConfigFactory.setInstance(m_config);
    m_translator = EventTranslator.getInstance();
    m_translator.setEventManager(m_eventMgr);
    m_translator.setConfig(EventTranslatorConfigFactory.getInstance());
    m_translator.setDataSource(m_db);
    m_translator.init();
    m_translator.start();
}
Also used : EventTranslatorConfigFactory(org.opennms.netmgt.config.EventTranslatorConfigFactory) ByteArrayInputStream(java.io.ByteArrayInputStream) MockEventIpcManager(org.opennms.netmgt.dao.mock.MockEventIpcManager) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) 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