use of org.opennms.netmgt.provision.DetectFuture in project opennms by OpenNMS.
the class AsyncDetectorFileDescriptorLeakTest method testNoServerPresent.
@Test
@Repeat(10000)
public void testNoServerPresent() throws Exception {
AsyncAbstractDetector detector = getNewDetector(1999, ".*");
LOG.info("Starting testNoServerPresent with detector: {}\n", detector);
final DetectFuture future = detector.isServiceDetected(InetAddressUtils.getLocalHostAddress());
assertNotNull(future);
future.awaitFor();
assertFalse("False positive during detection!!", future.isServiceDetected());
assertNull(future.getException());
LOG.info("Finished testNoServerPresent with detector: {}\n", detector);
}
use of org.opennms.netmgt.provision.DetectFuture in project opennms by OpenNMS.
the class FtpDetectorTest method testFailureClosedPort.
@Test(timeout = 20000)
public void testFailureClosedPort() throws Exception {
m_server.setBanner("WRONG BANNER");
m_detector.setPort(65535);
m_detector.setIdleTime(10000);
DetectFuture df = m_detector.isServiceDetected(m_server.getInetAddress());
assertFalse("Test should fail because the server closes before detection takes place", doCheck(df));
}
use of org.opennms.netmgt.provision.DetectFuture in project opennms by OpenNMS.
the class AsyncDetectorFileDescriptorLeakTest method testBannerlessServer.
@Test
public void testBannerlessServer() throws Throwable {
// No banner
setUpServer(null);
final int port = m_server.getLocalPort();
final InetAddress address = m_server.getInetAddress();
int i = 0;
while (i < 30000) {
LOG.info("current loop: {}", i);
AsyncAbstractDetector detector = getNewDetector(port, null);
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();
}
assertTrue("False negative during detection!!", future.isServiceDetected());
assertNull(future.getException());
i++;
}
}
use of org.opennms.netmgt.provision.DetectFuture in project opennms by OpenNMS.
the class TcpDetectorTest method testSuccessServer.
@Test(timeout = 20000)
public void testSuccessServer() throws Exception {
initializeDefaultDetector();
m_server = new SimpleServer() {
@Override
public void onInit() {
setBanner("Hello");
}
};
m_server.init();
m_server.startServer();
m_detector.setPort(m_server.getLocalPort());
DetectFuture future = m_detector.isServiceDetected(m_server.getInetAddress());
future.addListener(new DetectFutureListener<DetectFuture>() {
@Override
public void operationComplete(DetectFuture future) {
TcpDetector detector = m_detector;
m_detector = null;
detector.dispose();
}
});
assertNotNull(future);
future.awaitForUninterruptibly();
assertTrue(future.isServiceDetected());
}
Aggregations