use of org.opennms.netmgt.poller.mock.MockMonitoredService in project opennms by OpenNMS.
the class SshMonitorIT method testPollWithRegexpBanner.
@Test
public void testPollWithRegexpBanner() throws UnknownHostException {
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");
PollStatus ps = sm.poll(svc, parms);
assertTrue(createAssertMessage(ps, "Up"), ps.isUp());
assertFalse(createAssertMessage(ps, "not Down"), ps.isDown());
}
use of org.opennms.netmgt.poller.mock.MockMonitoredService in project opennms by OpenNMS.
the class LoopMonitorTest method testPoll.
/*
* Test method for 'org.opennms.netmgt.poller.monitors.LoopMonitor.poll(MonitoredService, Map, Package)'
*/
public void testPoll() throws UnknownHostException {
ServiceMonitor sm = new LoopMonitor();
MonitoredService svc = new MockMonitoredService(1, "Router", InetAddressUtils.addr("127.0.0.1"), "LOOP");
Map<String, Object> parms = new HashMap<String, Object>();
parms.put("ip-match", "127.0.0.1-2");
parms.put("is-supported", "true");
PollStatus ps = sm.poll(svc, parms);
assertTrue(ps.isUp());
assertFalse(ps.isDown());
}
use of org.opennms.netmgt.poller.mock.MockMonitoredService in project opennms by OpenNMS.
the class FtpMonitorTest method doPoll.
private PollStatus doPoll() throws UnknownHostException {
Map<String, Object> m = new HashMap<String, Object>();
m.put("port", m_serverSocket.getLocalPort());
m.put("retries", 0);
m.put("timeout", TIMEOUT);
PollStatus status = m_monitor.poll(new MockMonitoredService(1, "Node One", m_serverSocket.getInetAddress(), "FTP"), m);
return status;
}
use of org.opennms.netmgt.poller.mock.MockMonitoredService in project opennms by OpenNMS.
the class DNSResolutionMonitorIT method pollNeitherIPv4orIPv6.
@Test
public void pollNeitherIPv4orIPv6() throws Exception {
MockMonitoredService neither = new MockMonitoredService(1, "no-such-name.example.com", InetAddress.getLocalHost(), "RESOLVE");
DNSResolutionMonitor monitor = new DNSResolutionMonitor();
Map<String, Object> v4Parms = new HashMap<>();
v4Parms.put(PARM_RESOLUTION_TYPE, PARM_RESOLUTION_TYPE_V4);
v4Parms.put(PARM_NAMESERVER, "[::1]:9153");
Map<String, Object> v6Parms = new HashMap<>();
v6Parms.put(PARM_RESOLUTION_TYPE, PARM_RESOLUTION_TYPE_V6);
v6Parms.put(PARM_NAMESERVER, "[::1]:9153");
Map<String, Object> bothParms = new HashMap<>();
bothParms.put(PARM_RESOLUTION_TYPE, PARM_RESOLUTION_TYPE_BOTH);
bothParms.put(PARM_NAMESERVER, "[::1]:9153");
Map<String, Object> eitherParms = new HashMap<>();
eitherParms.put(PARM_RESOLUTION_TYPE, PARM_RESOLUTION_TYPE_EITHER);
eitherParms.put(PARM_NAMESERVER, "[::1]:9153");
assertEquals(PollStatus.unavailable(), monitor.poll(neither, v4Parms));
assertEquals(PollStatus.unavailable(), monitor.poll(neither, v6Parms));
assertEquals(PollStatus.unavailable(), monitor.poll(neither, bothParms));
assertEquals(PollStatus.unavailable(), monitor.poll(neither, eitherParms));
}
use of org.opennms.netmgt.poller.mock.MockMonitoredService in project opennms by OpenNMS.
the class DNSResolutionMonitorIT method pollIPv6Only.
@Test
public void pollIPv6Only() throws Exception {
MockMonitoredService v6only = new MockMonitoredService(1, "choopa-ipv6.opennms.org", InetAddress.getLocalHost(), "RESOLVE");
DNSResolutionMonitor monitor = new DNSResolutionMonitor();
Map<String, Object> v4Parms = new HashMap<>();
v4Parms.put(PARM_RESOLUTION_TYPE, PARM_RESOLUTION_TYPE_V4);
v4Parms.put(PARM_NAMESERVER, "[::1]:9153");
Map<String, Object> v6Parms = new HashMap<>();
v6Parms.put(PARM_RESOLUTION_TYPE, PARM_RESOLUTION_TYPE_V6);
v6Parms.put(PARM_NAMESERVER, "[::1]:9153");
Map<String, Object> bothParms = new HashMap<>();
bothParms.put(PARM_RESOLUTION_TYPE, PARM_RESOLUTION_TYPE_BOTH);
bothParms.put(PARM_NAMESERVER, "[::1]:9153");
Map<String, Object> eitherParms = new HashMap<>();
eitherParms.put(PARM_RESOLUTION_TYPE, PARM_RESOLUTION_TYPE_EITHER);
eitherParms.put(PARM_NAMESERVER, "[::1]:9153");
assertEquals(PollStatus.unavailable(), monitor.poll(v6only, v4Parms));
assertEquals(PollStatus.available(), monitor.poll(v6only, v6Parms));
assertEquals(PollStatus.unavailable(), monitor.poll(v6only, bothParms));
assertEquals(PollStatus.available(), monitor.poll(v6only, eitherParms));
}
Aggregations