use of org.opennms.netmgt.provision.DetectFuture in project opennms by OpenNMS.
the class MemcachedDetectorTest method testServerSuccess.
@Test(timeout = 20000)
public void testServerSuccess() throws Exception {
m_server = new SimpleServer() {
@Override
public void onInit() {
addResponseHandler(contains("version"), new RequestHandler() {
@Override
public void doRequest(OutputStream out) throws IOException {
out.write(String.format("%s\r\n", "VERSION 1.2.3").getBytes());
}
});
}
};
m_server.init();
m_server.startServer();
// make sure the server is really started
Thread.sleep(100);
try {
m_detector.setPort(m_server.getLocalPort());
m_detector.setIdleTime(1000);
DetectFuture future = m_detector.isServiceDetected(m_server.getInetAddress());
assertNotNull(future);
future.awaitForUninterruptibly();
assertTrue(future.isServiceDetected());
} finally {
m_server.stopServer();
}
}
use of org.opennms.netmgt.provision.DetectFuture in project opennms by OpenNMS.
the class TcpDetectorTest method testFailureConnectionTimesOutWhenExpectingABanner.
@Test(timeout = 20000)
public void testFailureConnectionTimesOutWhenExpectingABanner() throws Exception {
initializeDefaultDetector();
m_server = new SimpleServer() {
@Override
public void onInit() {
setTimeout(500);
}
};
m_server.init();
m_server.startServer();
m_detector.setPort(m_server.getLocalPort());
DetectFuture future = m_detector.isServiceDetected(m_server.getInetAddress());
assertNotNull(future);
future.awaitForUninterruptibly();
assertFalse("Test should fail because no banner was sent when expecting a banner to be sent", future.isServiceDetected());
}
use of org.opennms.netmgt.provision.DetectFuture in project opennms by OpenNMS.
the class TcpDetectorTest method testFailureNoBannerSentWhenExpectingABanner.
@Test(timeout = 20000)
public void testFailureNoBannerSentWhenExpectingABanner() throws Exception {
initializeDefaultDetector();
m_server = new SimpleServer() {
@Override
public void onInit() {
}
};
m_server.init();
m_server.startServer();
m_detector.setPort(m_server.getLocalPort());
DetectFuture future = m_detector.isServiceDetected(m_server.getInetAddress());
assertNotNull(future);
future.awaitForUninterruptibly();
assertFalse("Test should fail because no banner was sent when expecting a banner to be sent", future.isServiceDetected());
}
use of org.opennms.netmgt.provision.DetectFuture in project opennms by OpenNMS.
the class AsyncDetectorFileDescriptorLeakTest method testDetectorTimeoutWaitingForBanner.
@Test
public void testDetectorTimeoutWaitingForBanner() throws Throwable {
// Start a socket that doesn't have a thread servicing it
setUpSocket();
final int port = m_socket.getLocalPort();
final InetAddress address = m_socket.getInetAddress();
AsyncAbstractDetector detector = getNewDetector(port, "Hello");
assertNotNull(detector);
final DetectFuture future = (DetectFuture) detector.isServiceDetected(address);
assertNotNull(future);
future.awaitFor();
if (future.getException() != null) {
LOG.debug("got future exception", future.getException());
throw future.getException();
}
assertFalse("False positive during detection!!", future.isServiceDetected());
assertNull(future.getException());
}
use of org.opennms.netmgt.provision.DetectFuture in project opennms by OpenNMS.
the class FtpDetectorTest method testFailureNoBannerSent.
@Test(timeout = 20000)
public void testFailureNoBannerSent() throws Exception {
m_server = new SimpleServer();
m_server.init();
m_server.startServer();
m_detector.setPort(m_server.getLocalPort());
m_detector.setIdleTime(10000);
DetectFuture df = m_detector.isServiceDetected(m_server.getInetAddress());
assertFalse("Test should fail because the banner doesn't even get sent", doCheck(df));
}
Aggregations