Search in sources :

Example 11 with DetectFuture

use of org.opennms.netmgt.provision.DetectFuture in project opennms by OpenNMS.

the class CitrixDetectorTest method testDetectorSuccess.

@Test(timeout = 20000)
public void testDetectorSuccess() throws Exception {
    m_detector.setPort(m_server.getLocalPort());
    m_detector.setIdleTime(10000);
    m_detector.init();
    // assertTrue(m_detector.isServiceDetected(m_server.getInetAddress()));
    DetectFuture future = m_detector.isServiceDetected(m_server.getInetAddress());
    assertNotNull(future);
    future.awaitForUninterruptibly();
    assertTrue(future.isServiceDetected());
}
Also used : DetectFuture(org.opennms.netmgt.provision.DetectFuture) Test(org.junit.Test)

Example 12 with DetectFuture

use of org.opennms.netmgt.provision.DetectFuture in project opennms by OpenNMS.

the class CitrixDetectorTest method testDetectorFailWrongPort.

@Test(timeout = 20000)
public void testDetectorFailWrongPort() throws Exception {
    m_detector.setPort(65535);
    m_detector.setIdleTime(10000);
    m_detector.init();
    // assertFalse(m_detector.isServiceDetected(m_server.getInetAddress()));
    DetectFuture future = m_detector.isServiceDetected(m_server.getInetAddress());
    assertNotNull(future);
    future.awaitForUninterruptibly();
    assertFalse(future.isServiceDetected());
}
Also used : DetectFuture(org.opennms.netmgt.provision.DetectFuture) Test(org.junit.Test)

Example 13 with DetectFuture

use of org.opennms.netmgt.provision.DetectFuture in project opennms by OpenNMS.

the class HttpsDetectorTest method doCheck.

/**
 * @param serviceDetected
 * @return
 * @throws InterruptedException
 */
private boolean doCheck(DetectFuture serviceDetected) throws InterruptedException {
    DetectFuture future = serviceDetected;
    future.awaitFor();
    return future.isServiceDetected();
}
Also used : DetectFuture(org.opennms.netmgt.provision.DetectFuture)

Example 14 with DetectFuture

use of org.opennms.netmgt.provision.DetectFuture in project opennms by OpenNMS.

the class ImapDetectorTest method testDetectorFailUnexpectedLogoutResponse.

@Test(timeout = 20000)
public void testDetectorFailUnexpectedLogoutResponse() throws Exception {
    m_server = new SimpleServer() {

        @Override
        public void onInit() {
            setBanner("* NOT OK THIS IS A BANNER FOR IMAP");
            addResponseHandler(contains("LOGOUT"), singleLineRequest("* NOT OK"));
        }
    };
    m_server.init();
    m_server.startServer();
    try {
        m_detector.setPort(m_server.getLocalPort());
        // assertFalse(m_detector.isServiceDetected(m_server.getInetAddress()));
        DetectFuture future = m_detector.isServiceDetected(m_server.getInetAddress());
        assertNotNull(future);
        future.awaitForUninterruptibly();
        assertFalse(future.isServiceDetected());
    } finally {
        m_server.stopServer();
    }
}
Also used : SimpleServer(org.opennms.netmgt.provision.server.SimpleServer) DetectFuture(org.opennms.netmgt.provision.DetectFuture) Test(org.junit.Test)

Example 15 with DetectFuture

use of org.opennms.netmgt.provision.DetectFuture in project opennms by OpenNMS.

the class ImapDetectorTest method testDetectorFailUnexpectedBanner.

@Test(timeout = 20000)
public void testDetectorFailUnexpectedBanner() throws Exception {
    m_server = new SimpleServer() {

        @Override
        public void onInit() {
            setBanner("* NOT OK THIS IS A BANNER FOR IMAP");
        }
    };
    m_server.init();
    m_server.startServer();
    try {
        m_detector.setPort(m_server.getLocalPort());
        // assertFalse(m_detector.isServiceDetected(m_server.getInetAddress()));
        DetectFuture future = m_detector.isServiceDetected(m_server.getInetAddress());
        assertNotNull(future);
        future.awaitForUninterruptibly();
        assertFalse(future.isServiceDetected());
    } finally {
        m_server.stopServer();
    }
}
Also used : SimpleServer(org.opennms.netmgt.provision.server.SimpleServer) DetectFuture(org.opennms.netmgt.provision.DetectFuture) Test(org.junit.Test)

Aggregations

DetectFuture (org.opennms.netmgt.provision.DetectFuture)24 Test (org.junit.Test)21 SimpleServer (org.opennms.netmgt.provision.server.SimpleServer)12 AsyncAbstractDetector (org.opennms.netmgt.provision.support.AsyncAbstractDetector)5 InetAddress (java.net.InetAddress)4 OutputStream (java.io.OutputStream)2 ChannelFuture (org.jboss.netty.channel.ChannelFuture)2 TcpDetector (org.opennms.netmgt.provision.detector.simple.TcpDetector)2 RequestHandler (org.opennms.netmgt.provision.server.exchange.RequestHandler)2 IOException (java.io.IOException)1 InetSocketAddress (java.net.InetSocketAddress)1 SocketAddress (java.net.SocketAddress)1 KeyManagementException (java.security.KeyManagementException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 ClientBootstrap (org.jboss.netty.bootstrap.ClientBootstrap)1 ChannelFutureListener (org.jboss.netty.channel.ChannelFutureListener)1 ChannelPipeline (org.jboss.netty.channel.ChannelPipeline)1 ChannelPipelineFactory (org.jboss.netty.channel.ChannelPipelineFactory)1 SslHandler (org.jboss.netty.handler.ssl.SslHandler)1 Ignore (org.junit.Ignore)1