use of org.opennms.netmgt.poller.mock.MockMonitoredService in project opennms by OpenNMS.
the class SshMonitorIT method testPollWithInvalidRegexpMatch.
@Test
public void testPollWithInvalidRegexpMatch() throws UnknownHostException, PatternSyntaxException {
ServiceMonitor sm = new SshMonitor();
MonitoredService svc = new MockMonitoredService(1, "Router", InetAddressUtils.addr(HOST_TO_TEST), "SSH");
Map<String, Object> parms = new HashMap<String, Object>();
parms.put("banner", "^SSH\\-2\\.0\\-OpenSSH_\\d+\\.\\d+\\g$");
PollStatus ps = sm.poll(svc, parms);
assertTrue(createAssertMessage(ps, "Unavailable"), ps.isUnavailable());
}
use of org.opennms.netmgt.poller.mock.MockMonitoredService in project opennms by OpenNMS.
the class SshMonitorIT method testPollWithInvalidHost.
@Test
public void testPollWithInvalidHost() throws UnknownHostException {
ServiceMonitor sm = new SshMonitor();
MonitoredService svc = new MockMonitoredService(1, "Router", InetAddressUtils.UNPINGABLE_ADDRESS, "SSH");
Map<String, Object> parms = new HashMap<String, Object>();
PollStatus ps = sm.poll(svc, parms);
assertTrue(createAssertMessage(ps, "Unavailable"), ps.isUnavailable());
}
use of org.opennms.netmgt.poller.mock.MockMonitoredService in project opennms by OpenNMS.
the class SshMonitorIT method testPollWithNoIpAddress.
@Test
public void testPollWithNoIpAddress() throws UnknownHostException {
ServiceMonitor sm = new SshMonitor();
MonitoredService svc = new MockMonitoredService(1, "Router", null, "SSH");
Map<String, Object> parms = new HashMap<String, Object>();
parms.put("banner", "OpenNMS");
PollStatus ps = sm.poll(svc, parms);
assertTrue(createAssertMessage(ps, "Down"), ps.isDown());
assertFalse(createAssertMessage(ps, "not Up"), ps.isUp());
}
use of org.opennms.netmgt.poller.mock.MockMonitoredService in project opennms by OpenNMS.
the class PollerConfigWithPSMIT method testPSM.
@Test
public void testPSM() throws Exception {
InputStream is = new FileInputStream(new File("src/test/resources/etc/psm-poller-configuration.xml"));
PollerConfigFactory factory = new PollerConfigFactory(0, is, "localhost", false);
PollerConfigFactory.setInstance(factory);
IOUtils.closeQuietly(is);
ServiceMonitor monitor = PollerConfigFactory.getInstance().getServiceMonitor("MQ_API_DirectRte_v2");
Assert.assertNotNull(monitor);
Package pkg = PollerConfigFactory.getInstance().getPackage("MapQuest");
Assert.assertNotNull(pkg);
Service svc = PollerConfigFactory.getInstance().getServiceInPackage("MQ_API_DirectRte_v2", pkg);
Assert.assertNotNull(svc);
Map<String, Object> parameters = new HashMap<String, Object>();
for (Parameter p : svc.getParameters()) {
parameters.put(p.getKey(), p.getValue() == null ? p.getAnyObject() : p.getValue());
}
PollStatus status = monitor.poll(new MockMonitoredService(1, "www.mapquest.com", InetAddress.getByName("www.mapquest.com"), "MQ_API_DirectRte_v2"), parameters);
Assert.assertEquals(PollStatus.SERVICE_AVAILABLE, status.getStatusCode());
}
use of org.opennms.netmgt.poller.mock.MockMonitoredService in project opennms by OpenNMS.
the class PassiveStatusKeeperIT method testDownPassiveStatus.
@Test
public void testDownPassiveStatus() throws InterruptedException, UnknownHostException {
Event e = createPassiveStatusEvent("Router", "192.168.1.1", "ICMP", "Down");
m_eventMgr.sendNow(e);
PollStatus ps = m_psk.getStatus("Router", "192.168.1.1", "ICMP");
assertTrue(ps.isDown());
MockMonitoredService svc = new MockMonitoredService(1, "Router", InetAddressUtils.addr("192.168.1.1"), "ICMP");
ServiceMonitor m = new PassiveServiceMonitor();
PollStatus ps2 = m.poll(svc, null);
assertEquals(ps, ps2);
}
Aggregations