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");
}
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");
}
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);
}
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());
}
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();
}
Aggregations