Package org.xlightweb.client

Examples of org.xlightweb.client.HttpClientConnectionPool


      };
     
      IServer server = new Server(dh);
      server.start();
     
      HttpClientConnectionPool pool = new HttpClientConnectionPool();
             
      HttpClientConnection httpCon = pool.getHttpClientConnection("localhost", server.getLocalPort());
      IHttpResponse resp = httpCon.call(new GetRequest("http://localhost:" + server.getLocalPort() + "/"));
       
      InputStream in = Channels.newInputStream(resp.getBlockingBody());
      in.close();


      QAUtil.sleep(2000);
     
      Assert.assertEquals(1, pool.getNumIdle());
       
      QAUtil.sleep(15000);
      Assert.assertEquals(0, pool.getNumIdle());
      Assert.assertEquals(1, pool.getNumDestroyed());
     
        pool.close();
  }
View Full Code Here


      };
     
      IServer server = new Server(dh);
      server.start();
     
      HttpClientConnectionPool pool = new HttpClientConnectionPool();
             
        for (int i = 0; i < 1000; i++) {
            HttpClientConnection httpCon = pool.getHttpClientConnection("localhost", server.getLocalPort());
            IHttpResponse resp = httpCon.call(new GetRequest("http://localhost:" + server.getLocalPort() + "/"));
       
            InputStream in = Channels.newInputStream(resp.getBlockingBody());
            in.close();
            System.out.print(".");
        }
       
        pool.close();
  }
View Full Code Here

    public void testStreaming() throws Exception {

        WebContainer container = new WebContainer(new MyServlet());
        container.start();
            
        HttpClientConnectionPool pool = new HttpClientConnectionPool();

       
        for (int i = 0; i < 100; i++) {
            HttpClientConnection con = pool.getHttpClientConnection("localhost", container.getLocalPort());
           
            FutureResponseHandler respHdl = new FutureResponseHandler();
            BodyDataSink dataSink = con.send(new HttpRequestHeader("POST", "http://localhost:" + container.getLocalPort() + "/test"), respHdl);
           
            dataSink.write("test");
           
            IHttpResponse response = respHdl.getResponse();
            Assert.assertEquals(200, response.getStatus());
           
            BlockingBodyDataSource dataSource = response.getBlockingBody();
            Assert.assertEquals("test", dataSource.readStringByLength(4));
           
            dataSink.write("12345");
            Assert.assertEquals("12345", dataSource.readStringByLength(5));
           
            dataSink.write("789");
            Assert.assertEquals("789", dataSource.readStringByLength(3));
           
            dataSink.close();
            con.close();   
           
            System.out.print(".");
        }
       
       
        pool.close();
        container.stop();
    }   
View Full Code Here

      };
     
      IServer server = new Server(dh);
      server.start();
     
      HttpClientConnectionPool pool = new HttpClientConnectionPool();
             
      HttpClientConnection httpCon = pool.getHttpClientConnection("localhost", server.getLocalPort());
      IHttpResponse resp = httpCon.call(new GetRequest("http://localhost:" + server.getLocalPort() + "/"));
       
      InputStream in = Channels.newInputStream(resp.getBlockingBody());
      in.close();


      QAUtil.sleep(2000);
     
      Assert.assertEquals(1, pool.getNumIdle());
       
      QAUtil.sleep(15000);
      Assert.assertEquals(0, pool.getNumIdle());
      Assert.assertEquals(1, pool.getNumDestroyed());
     
        pool.close();
  }
View Full Code Here

      };
     
      IServer server = new Server(dh);
      server.start();
     
      HttpClientConnectionPool pool = new HttpClientConnectionPool();
             
        for (int i = 0; i < 1000; i++) {
            HttpClientConnection httpCon = pool.getHttpClientConnection("localhost", server.getLocalPort());
            IHttpResponse resp = httpCon.call(new GetRequest("http://localhost:" + server.getLocalPort() + "/"));
       
            InputStream in = Channels.newInputStream(resp.getBlockingBody());
            in.close();
            System.out.print(".");
        }
       
        pool.close();
  }
View Full Code Here

    public void testStreaming() throws Exception {

        WebContainer container = new WebContainer(new MyServlet());
        container.start();
            
        HttpClientConnectionPool pool = new HttpClientConnectionPool();

       
        for (int i = 0; i < 100; i++) {
            HttpClientConnection con = pool.getHttpClientConnection("localhost", container.getLocalPort());
           
            FutureResponseHandler respHdl = new FutureResponseHandler();
            BodyDataSink dataSink = con.send(new HttpRequestHeader("POST", "http://localhost:" + container.getLocalPort() + "/test"), respHdl);
           
            dataSink.write("test");
           
            IHttpResponse response = respHdl.getResponse();
            Assert.assertEquals(200, response.getStatus());
           
            BlockingBodyDataSource dataSource = response.getBlockingBody();
            Assert.assertEquals("test", dataSource.readStringByLength(4));
           
            dataSink.write("12345");
            Assert.assertEquals("12345", dataSource.readStringByLength(5));
           
            dataSink.write("789");
            Assert.assertEquals("789", dataSource.readStringByLength(3));
           
            dataSink.close();
            con.close();   
           
            System.out.print(".");
        }
       
       
        pool.close();
        container.stop();
    }   
View Full Code Here

      };
     
      IServer server = new Server(dh);
      server.start();
     
      HttpClientConnectionPool pool = new HttpClientConnectionPool();
             
      HttpClientConnection httpCon = pool.getHttpClientConnection("localhost", server.getLocalPort());
      IHttpResponse resp = httpCon.call(new GetRequest("http://localhost:" + server.getLocalPort() + "/"));
       
      InputStream in = Channels.newInputStream(resp.getBody());
      in.close();


      QAUtil.sleep(2000);
     
      Assert.assertEquals(1, pool.getNumIdle());
       
      QAUtil.sleep(15000);
      Assert.assertEquals(0, pool.getNumIdle());
      Assert.assertEquals(1, pool.getNumDestroyed());
     
        pool.close();
  }
View Full Code Here

      };
     
      IServer server = new Server(dh);
      server.start();
     
      HttpClientConnectionPool pool = new HttpClientConnectionPool();
             
        for (int i = 0; i < 1000; i++) {
            HttpClientConnection httpCon = pool.getHttpClientConnection("localhost", server.getLocalPort());
            IHttpResponse resp = httpCon.call(new GetRequest("http://localhost:" + server.getLocalPort() + "/"));
       
            InputStream in = Channels.newInputStream(resp.getBody());
            in.close();
            System.out.print(".");
        }
       
        pool.close();
  }
View Full Code Here

    public void testStreaming() throws Exception {

        WebContainer container = new WebContainer(new MyServlet());
        container.start();
            
        HttpClientConnectionPool pool = new HttpClientConnectionPool();

       
        for (int i = 0; i < 100; i++) {
            HttpClientConnection con = pool.getHttpClientConnection("localhost", container.getLocalPort());
           
            FutureResponseHandler respHdl = new FutureResponseHandler();
            BodyDataSink dataSink = con.send(new HttpRequestHeader("POST", "http://localhost:" + container.getLocalPort() + "/test"), respHdl);
           
            dataSink.write("test");
           
            IHttpResponse response = respHdl.getResponse();
            Assert.assertEquals(200, response.getStatus());
           
            BodyDataSource dataSource = response.getBody();
            Assert.assertEquals("test", dataSource.readStringByLength(4));
           
            dataSink.write("12345");
            Assert.assertEquals("12345", dataSource.readStringByLength(5));
           
            dataSink.write("789");
            Assert.assertEquals("789", dataSource.readStringByLength(3));
           
            dataSink.close();
            con.close();   
           
            System.out.print(".");
        }
       
       
        pool.close();
        container.stop();
    }   
View Full Code Here

TOP

Related Classes of org.xlightweb.client.HttpClientConnectionPool

Copyright © 2018 www.massapicom. 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.