use of org.opennms.netmgt.poller.mock.MockMonitoredService in project opennms by OpenNMS.
the class DNSResolutionMonitorTest method testPoll.
@Test
public void testPoll() throws Exception {
MockMonitoredService dual = new MockMonitoredService(1, "wipv6day.opennms.org", InetAddress.getLocalHost(), "RESOLVE");
MockMonitoredService v4only = new MockMonitoredService(1, "choopa-ipv4.opennms.org", InetAddress.getLocalHost(), "RESOLVE");
MockMonitoredService v6only = new MockMonitoredService(1, "choopa-ipv6.opennms.org", InetAddress.getLocalHost(), "RESOLVE");
MockMonitoredService neither = new MockMonitoredService(1, "no-such-name.example.com", InetAddress.getLocalHost(), "RESOLVE");
DNSResolutionMonitor monitor = new DNSResolutionMonitor();
Map<String, Object> v4Parms = Collections.<String, Object>singletonMap(PARM_RESOLUTION_TYPE, PARM_RESOLUTION_TYPE_V4);
Map<String, Object> v6Parms = Collections.<String, Object>singletonMap(PARM_RESOLUTION_TYPE, PARM_RESOLUTION_TYPE_V6);
Map<String, Object> bothParms = Collections.<String, Object>singletonMap(PARM_RESOLUTION_TYPE, PARM_RESOLUTION_TYPE_BOTH);
Map<String, Object> eitherParms = Collections.<String, Object>singletonMap(PARM_RESOLUTION_TYPE, PARM_RESOLUTION_TYPE_EITHER);
assertEquals(PollStatus.available(), monitor.poll(dual, v4Parms));
assertEquals(PollStatus.available(), monitor.poll(dual, v6Parms));
assertEquals(PollStatus.available(), monitor.poll(dual, bothParms));
assertEquals(PollStatus.available(), monitor.poll(dual, eitherParms));
assertEquals(PollStatus.available(), monitor.poll(v4only, v4Parms));
assertEquals(PollStatus.unavailable(), monitor.poll(v4only, v6Parms));
assertEquals(PollStatus.unavailable(), monitor.poll(v4only, bothParms));
assertEquals(PollStatus.available(), monitor.poll(v4only, eitherParms));
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));
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 FtpMonitorTest method SKIPtestMonitorFailureOnRandomFtp.
// Let's not depend on external systems if we don't have to
public void SKIPtestMonitorFailureOnRandomFtp() throws Exception {
PollStatus status = m_monitor.poll(new MockMonitoredService(1, "Node One", InetAddressUtils.addr("1.1.1.1"), "FTP"), new HashMap<String, Object>());
assertTrue("status should be unavailable (Down), but is: " + status, status.isUnavailable());
}
use of org.opennms.netmgt.poller.mock.MockMonitoredService in project opennms by OpenNMS.
the class FtpMonitorTest method SKIPtestMonitorOnOpennmsOrgFtpSuccess.
// Let's not depend on external systems if we don't have to
public void SKIPtestMonitorOnOpennmsOrgFtpSuccess() throws Exception {
PollStatus status = m_monitor.poll(new MockMonitoredService(1, "Node One", InetAddressUtils.addr("ftp.opennms.org"), "FTP"), new HashMap<String, Object>());
assertTrue("status should be available (Up), but is: " + status, status.isAvailable());
}
use of org.opennms.netmgt.poller.mock.MockMonitoredService in project opennms by OpenNMS.
the class SshMonitorIT method testPollWithStarBanner.
@Test
public void testPollWithStarBanner() 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", "*");
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 SystemExecuteMonitorTest method setup.
@Before
public void setup() throws Exception {
monitor = new SystemExecuteMonitor();
svc = new MockMonitoredService(42, NODELABEL, InetAddress.getLocalHost(), "myService");
parameters = new HashMap<String, Object>();
}
Aggregations