Examples of HttpClientConnection


Examples of org.xlightweb.client.HttpClientConnection

   
    IServer server = new HttpServer(new BadServerHandler());
    server.start();
   
   
    HttpClientConnection con = new HttpClientConnection("localhost", server.getLocalPort());
   
    ResponseHandler respHdl = new ResponseHandler();
    con.send(new GetRequest("/"), respHdl);
   
    QAUtil.sleep(1000);
   
    Assert.assertNotNull(respHdl.getException());
   
    con.close();
    server.close();
  }
View Full Code Here

Examples of org.xlightweb.client.HttpClientConnection

   
    IServer server = new HttpServer(new BadServerHandler());
    server.start();
   
   
    HttpClientConnection con = new HttpClientConnection("localhost", server.getLocalPort());
   
    ResponseHandler2 respHdl = new ResponseHandler2();
    con.send(new GetRequest("/"), respHdl);
   
    QAUtil.sleep(1000);
   
    Assert.assertNotNull(respHdl.ioeRef.get());
    Assert.assertTrue(respHdl.ioeRef.get() instanceof ProtocolException);
   
    con.close();
    server.close();
  }
View Full Code Here

Examples of org.xlightweb.client.HttpClientConnection

     
      private HttpClientConnection httpCon;
      private IOException ioe;
     
      public boolean onConnect(INonBlockingConnection connection) throws IOException, BufferUnderflowException, MaxReadSizeExceededException {
          httpCon = new HttpClientConnection(connection);
          return true;
      }
View Full Code Here

Examples of org.xlightweb.client.HttpClientConnection

  public void testHttpConnection() throws Exception {
      HttpServer server = new HttpServer(new RequestHandler());
      server.start();
     
     
      HttpClientConnection con = new HttpClientConnection("localhost", server.getLocalPort());
      IFutureResponse futureResponse = con.send(new GetRequest("http://localhost:" + server.getLocalPort() + "/?pauseMillis=10"));

      IHttpResponse response = futureResponse.getResponse();
     
      Assert.assertTrue(futureResponse.isDone());
      Assert.assertFalse(futureResponse.isCancelled());
     
      Assert.assertEquals(200, response.getStatus());
     
      Assert.assertFalse(futureResponse.cancel(true));
      Assert.assertFalse(futureResponse.isCancelled());
     
      con.close();
      server.close();
  }
View Full Code Here

Examples of org.xlightweb.client.HttpClientConnection

    public void testHttpConnectionTimeout() throws Exception {
        HttpServer server = new HttpServer(new RequestHandler());
        server.start();
       
       
        HttpClientConnection con = new HttpClientConnection("localhost", server.getLocalPort());
        IFutureResponse futureResponse = con.send(new GetRequest("http://localhost:" + server.getLocalPort() + "/?pauseMillis=500"));

        try {
            futureResponse.getResponse(100, TimeUnit.MILLISECONDS);
            Assert.fail("SocketTimeoutException expected");
        } catch (SocketTimeoutException expected) { }
       
        Assert.assertFalse(futureResponse.isCancelled());
        Assert.assertTrue(futureResponse.isDone());
       
        con.close();
        server.close();
    }
View Full Code Here

Examples of org.xlightweb.client.HttpClientConnection

    public void testHttpConnectionCancel() throws Exception {
        HttpServer server = new HttpServer(new RequestHandler());
        server.start();
       
       
        HttpClientConnection con = new HttpClientConnection("localhost", server.getLocalPort());
        IFutureResponse futureResponse = con.send(new GetRequest("http://localhost:" + server.getLocalPort() + "/?pauseMillis=500"));

        futureResponse.cancel(true);
       
        Assert.assertTrue(futureResponse.isCancelled());
        Assert.assertTrue(futureResponse.isDone());
       
        con.close();
        server.close();
    }
View Full Code Here

Examples of org.xlightweb.client.HttpClientConnection

  public void testConnectionTimeoutHandled() throws Exception {

    IServer server = new HttpServer(new ServerHandler3());
    ConnectionUtils.start(server);
   
    HttpClientConnection con = new HttpClientConnection("localhost", server.getLocalPort());
    con.setConnectionTimeoutMillis(1000);
   
    ResponseHandler respHdl = new ResponseHandler();
    HttpRequestHeader reqHdr = new HttpRequestHeader("POST", "/");

    BodyDataSink bodyDataSink = con.send(reqHdr, respHdl);
    bodyDataSink.write("er");
   
    QAUtil.sleep(1500);
   
    Assert.assertEquals(1, respHdl.getCountSocketException());
    Assert.assertEquals(0, respHdl.getCountIOException());
   
    con.close();
    server.close();
  }
View Full Code Here

Examples of org.xlightweb.client.HttpClientConnection

  public void testConnectionTimeout() throws Exception {

    IServer server = new HttpServer(new ServerHandler3());
    ConnectionUtils.start(server);
   
    HttpClientConnection con = new HttpClientConnection("localhost", server.getLocalPort());
    con.setConnectionTimeoutMillis(1000);
   
    ResponseHandler2 respHdl = new ResponseHandler2();
    HttpRequestHeader reqHdr = new HttpRequestHeader("POST", "/");

    BodyDataSink bodyDataSink = con.send(reqHdr, respHdl);
    bodyDataSink.write("er");
   
    QAUtil.sleep(2000);
   
    Assert.assertEquals(1, respHdl.getCountIOException());
   
    con.close();
    server.close();
  }
View Full Code Here

Examples of org.xlightweb.client.HttpClientConnection

  public void testIdleTimeout() throws Exception {

    IServer server = new HttpServer(new ServerHandler());
    ConnectionUtils.start(server);
   
    HttpClientConnection con = new HttpClientConnection("localhost", server.getLocalPort());
    con.setIdleTimeoutMillis(500);
   
    QAUtil.sleep(1000);
    Assert.assertFalse(con.isOpen());
   
    con.close();
    server.close();
  }
View Full Code Here

Examples of org.xlightweb.client.HttpClientConnection

  @Test
  public void testIdleTimeout2() throws Exception {
    IServer server = new HttpServer(new ServerHandler());
    ConnectionUtils.start(server);
   
    HttpClientConnection con = new HttpClientConnection("localhost", server.getLocalPort());
    con.setIdleTimeoutMillis(500);
   
    GetRequest request = new GetRequest("/");
    request.setHeader("sleep-time", Integer.toString(1000));
    try {
      con.call(request);
      Assert.fail("SocketTimeoutException expected");
    } catch (IOException expected) { }
   
    con.close();
    server.close();
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.