Examples of IHttpResponse


Examples of org.xlightweb.IHttpResponse

        server.start();
       
        HttpClient httpClient = new HttpClient();
        httpClient.setCacheMaxSizeKB(100);
       
        IHttpResponse resp = httpClient.call(new GetRequest("http://localhost:" + server.getLocalPort() + "/"));
        Assert.assertEquals(200, resp.getStatus());
        Assert.assertEquals("test", resp.getBody().readString());
        Assert.assertNull(resp.getHeader(CacheHandler.XHEADER_NAME));
       
        QAUtil.sleep(1000);
       
        resp = httpClient.call(new GetRequest("http://localhost:" + server.getLocalPort() + "/"));
        Assert.assertEquals(200, resp.getStatus());
        Assert.assertNull(resp.getHeader(CacheHandler.XHEADER_NAME));
        Assert.assertEquals("test", resp.getBody().readString());
       
       
        Assert.assertEquals(0, httpClient.getNumCacheHit());
        Assert.assertEquals(2, httpClient.getNumCacheMiss());
       
View Full Code Here

Examples of org.xlightweb.IHttpResponse

     
      NonBlockingConnectionPool pool = new NonBlockingConnectionPool();
             
        for (int i = 0; i < 1000; i++) {
            HttpClientConnection httpCon = new HttpClientConnection(pool.getNonBlockingConnection("localhost", server.getLocalPort()));
            IHttpResponse resp = httpCon.call(new GetRequest("http://localhost:" + server.getLocalPort() + "/"));
       
            InputStream in = Channels.newInputStream(resp.getBlockingBody());
            in.close();
               
            httpCon.close();
        }
       
View Full Code Here

Examples of org.xlightweb.IHttpResponse

      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);
     
View Full Code Here

Examples of org.xlightweb.IHttpResponse

     
      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

Examples of org.xlightweb.IHttpResponse

            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));
           
View Full Code Here

Examples of org.xlightweb.IHttpResponse

    HttpClient httpClient = new HttpClient(SSLTestContextFactory.getSSLContext());
    httpClient.setProxyHost("localhost");
    httpClient.setProxyPort(proxy.getLocalPort());

    GetRequest request = new GetRequest("http://www.amazon.de/");
    IHttpResponse response = httpClient.call(request);
   
    Assert.assertEquals(200, response.getStatus());
    Assert.assertTrue(response.getBlockingBody().readString().indexOf("amazon") != -1);
   
   
    httpClient.close();
    proxy.close();
 
View Full Code Here

Examples of org.xlightweb.IHttpResponse

    httpClient.setProxySecuredHost("localhost");
    httpClient.setProxySecuredPort(proxy.getLocalPort());
    httpClient.setProxyUser("test");
    httpClient.setProxyPassword("test");

    IHttpResponse response = httpClient.call(new GetRequest("https://localhost:" + server.getLocalPort() + "/"));
   
    String body = response.getBlockingBody().readString();

    Assert.assertEquals(200, response.getStatus());
    Assert.assertTrue(body.indexOf("it works") != -1);
   
   
    httpClient.close();
    proxy.close();
View Full Code Here

Examples of org.xlightweb.IHttpResponse

        httpClient.setProxyHost("localhost");
        httpClient.setProxyPort(proxy.getLocalPort());
        httpClient.setProxyUser("test");
        httpClient.setProxyPassword("test");

        IHttpResponse response = httpClient.call(new GetRequest("https://localhost:" + server.getLocalPort() + "/"));
       
        String body = response.getBlockingBody().readString();

        Assert.assertEquals(200, response.getStatus());
        Assert.assertTrue(body.indexOf("it works") != -1);
       
       
        httpClient.close();
        proxy.close();
View Full Code Here

Examples of org.xlightweb.IHttpResponse

    httpClient.setProxyPort(proxy.getLocalPort());
    httpClient.setProxyUser("test");
    httpClient.setProxyPassword("test");
   

    IHttpResponse response = httpClient.call(new GetRequest("http://www.amazon.de/"));
   
    Assert.assertEquals(200, response.getStatus());
    Assert.assertTrue(response.getBlockingBody().readString().indexOf("amazon") != -1);
   
   
    httpClient.close();
    proxy.close();
 
View Full Code Here

Examples of org.xlightweb.IHttpResponse

    IServer server = new Server(hdl);
    server.start();
   
   
    HttpClientConnection con = new HttpClientConnection("localhost", server.getLocalPort());
    IHttpResponse response = con.call(new GetRequest("/"));
   
    Assert.assertEquals(200, response.getStatus());
    Assert.assertEquals("12345", response.getBlockingBody().readString());
    Assert.assertEquals("me", response.getServer());
   
    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.