use of org.opennms.netmgt.provision.support.AsyncAbstractDetector 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.support.AsyncAbstractDetector in project opennms by OpenNMS.
the class AsyncDetectorFileDescriptorLeakTest method testDetectorBannerTimeout.
/**
* TODO: This test will fail if there are more than a few milliseconds of delay
* between the characters of the banner. We need to fix this behavior.
*/
@Test
public void testDetectorBannerTimeout() throws Throwable {
// Add 50 milliseconds of delay in between sending bytes of the banner
setUpServer("Banner", 50);
final int port = m_server.getLocalPort();
final InetAddress address = m_server.getInetAddress();
AsyncAbstractDetector detector = getNewDetector(port, "Banner");
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());
}
use of org.opennms.netmgt.provision.support.AsyncAbstractDetector in project opennms by OpenNMS.
the class AsyncDetectorFileDescriptorLeakTest method testSuccessServer.
@Test
public void testSuccessServer() throws Throwable {
setUpServer("Winner");
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, ".*");
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.support.AsyncAbstractDetector 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.support.AsyncAbstractDetector 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++;
}
}
Aggregations