use of org.opennms.netmgt.poller.PollStatus in project opennms by OpenNMS.
the class HostResourceSWRunMonitorTest method testInvalidMaxServices.
@Test
public void testInvalidMaxServices() throws Exception {
Map<String, Object> parameters = createBasicParams();
parameters.put("max-services", "3");
PollStatus status = monitor.poll(createMonitor(), parameters);
Assert.assertFalse(status.isAvailable());
log(status.getReason());
}
use of org.opennms.netmgt.poller.PollStatus in project opennms by OpenNMS.
the class FtpMonitorTest method testMonitorFailureWithClosedPort.
public void testMonitorFailureWithClosedPort() throws Exception {
m_serverSocket.close();
PollStatus status = doPoll();
assertTrue("status should be unavailable (Down), but is: " + status, status.isUnavailable());
}
use of org.opennms.netmgt.poller.PollStatus in project opennms by OpenNMS.
the class FtpMonitorTest method testMonitorFailureWithBogusResponse.
public void testMonitorFailureWithBogusResponse() throws Exception {
Thread m_serverThread = new Thread(new Runnable() {
@Override
public void run() {
try {
m_serverSocket.setSoTimeout(1000);
Socket s = m_serverSocket.accept();
s.getOutputStream().write("Go away!".getBytes());
} catch (Throwable e) {
throw new UndeclaredThrowableException(e);
}
}
});
m_serverThread.start();
PollStatus status = doPoll();
assertTrue("status should be unavailable (Down), but is: " + status, status.isUnavailable());
}
use of org.opennms.netmgt.poller.PollStatus 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.PollStatus in project opennms by OpenNMS.
the class DnsMonitorIT method testNotFoundWithCustomRcode.
@Test
public // type not found is still considered a valid response with the default response codes
void testNotFoundWithCustomRcode() throws UnknownHostException {
final Map<String, Object> m = new ConcurrentSkipListMap<String, Object>();
final ServiceMonitor monitor = new DnsMonitor();
final MonitoredService svc = MonitorTestUtils.getMonitoredService(99, addr("127.0.0.1"), "DNS");
m.put("port", "9153");
m.put("retry", "2");
m.put("timeout", "5000");
m.put("lookup", "bogus.example.com");
m.put("fatal-response-codes", "3");
final PollStatus status = monitor.poll(svc, m);
MockUtil.println("Reason: " + status.getReason());
assertEquals(PollStatus.SERVICE_UNAVAILABLE, status.getStatusCode());
}
Aggregations