예제 #1
0
  @Test(timeout = 90000)
  public void testDetectorSuccess() throws Exception {
    m_server = createServer(serverOKResponse);

    m_detector.setPort(m_server.getLocalPort());
    m_detector.init();
    assertTrue(doCheck(m_detector.isServiceDetected(m_server.getInetAddress())));
  }
예제 #2
0
  @Test(timeout = 90000)
  public void testDetectorSucessCheckCodeTrue() throws Exception {
    m_detector.setCheckRetCode(true);
    m_detector.setUrl("http://localhost/");
    m_detector.init();
    m_detector.setIdleTime(1000);
    m_server = createServer(getServerOKResponse());
    m_detector.setPort(m_server.getLocalPort());

    assertTrue(doCheck(m_detector.isServiceDetected(m_server.getInetAddress())));
  }
예제 #3
0
  @Test(timeout = 90000)
  public void testDetectorMaxRetCode600() throws Exception {
    m_detector.setCheckRetCode(true);
    m_detector.setMaxRetCode(600);
    m_detector.init();

    m_server = createServer(getServerOKResponse());
    m_detector.setPort(m_server.getLocalPort());

    assertTrue(doCheck(m_detector.isServiceDetected(m_server.getInetAddress())));
  }
예제 #4
0
  @Test(timeout = 90000)
  public void testDetectorSucessMaxRetCode399() throws Exception {
    m_detector.setCheckRetCode(true);
    m_detector.setUrl("/blog");
    m_detector.setMaxRetCode(399);

    m_server = createServer(serverOKResponse);
    m_detector.setPort(m_server.getLocalPort());
    m_detector.init();
    assertTrue(doCheck(m_detector.isServiceDetected(m_server.getInetAddress())));
  }
예제 #5
0
  @Test(timeout = 90000)
  public void testDetectorFailMaxRetCodeBelow200() throws Exception {
    m_detector.setCheckRetCode(true);
    m_detector.setUrl("/blog");
    m_detector.setMaxRetCode(199);
    m_detector.init();

    m_server = createServer(getServerOKResponse());
    m_detector.setPort(m_server.getLocalPort());

    assertFalse(doCheck(m_detector.isServiceDetected(m_server.getInetAddress())));
  }
예제 #6
0
  private SSLServer createServer(final String httpResponse) throws Exception {
    SSLServer server =
        new SSLServer() {

          public void onInit() {
            addResponseHandler(contains("GET"), shutdownServer(httpResponse));
          }
        };
    server.setPort(SSL_PORT);
    server.init();
    server.startServer();

    return server;
  }
예제 #7
0
  @Test(timeout = 90000)
  public void testDetectorFailWrongPort() throws Exception {
    m_detector.setPort(2000);
    m_server = createServer(serverOKResponse);

    assertFalse(doCheck(m_detector.isServiceDetected(m_server.getInetAddress())));
  }
예제 #8
0
 @After
 public void tearDown() throws IOException {
   if (m_server != null) {
     m_server.stopServer();
     m_server = null;
     try {
       Thread.sleep(100);
     } catch (final InterruptedException e) {
       Thread.currentThread().interrupt();
     }
   }
 }