Package org.xlightweb.client

Examples of org.xlightweb.client.HttpClient.call()


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


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

   
    HttpClient httpClient = new HttpClient();
    httpClient.setAutoHandleCookies(true);
   
    IHttpRequest req = new GetRequest("http://localhost:" + server.getLocalPort() + "/");
    httpClient.call(req);
   
    req = new GetRequest("http://localhost:" + server.getLocalPort() + "/");
    httpClient.call(req);
   
    Assert.assertEquals("name1=1; name2=2", req.getHeader("Cookie"));
View Full Code Here

   
    IHttpRequest req = new GetRequest("http://localhost:" + server.getLocalPort() + "/");
    httpClient.call(req);
   
    req = new GetRequest("http://localhost:" + server.getLocalPort() + "/");
    httpClient.call(req);
   
    Assert.assertEquals("name1=1; name2=2", req.getHeader("Cookie"));
   
    httpClient.close();
    server.close();
View Full Code Here

          try {
            HttpClient httpClient = new HttpClient();
 
            for (int j = 0; j < loops; j++) {
              long start = System.currentTimeMillis();
              IHttpResponse response = httpClient.call(new GetRequest("http://localhost:" + port + "/"));

              long elapsed = (System.currentTimeMillis() - start);
              total.addAndGet((int) elapsed);
         
             
View Full Code Here

        server.start();

        HttpClient httpClient = new HttpClient();
       
        long start = System.currentTimeMillis();
        IHttpResponse response = httpClient.call(new GetRequest("http://localhost:" + server.getLocalPort() + "/test?delay=2000"));
       
        long elapsed = System.currentTimeMillis() - start;
        System.out.println("elapsed " + elapsed);
       
        Assert.assertTrue(elapsed < 2000);
View Full Code Here

        HttpClient httpClient = new HttpClient();
        httpClient.setCallReturnOnMessage(true);
       
        long start = System.currentTimeMillis();
        IHttpResponse response = httpClient.call(new GetRequest("http://localhost:" + server.getLocalPort() + "/test?delay=2000"));
       
        long elapsed = System.currentTimeMillis() - start;
        System.out.println("elapsed " + elapsed);
       
        Assert.assertTrue(elapsed >= 2000);
View Full Code Here


        HttpClient httpClient = new HttpClient();
        httpClient.setCallReturnOnMessage(true);
       
        IHttpResponse response = httpClient.call(new GetRequest("http://localhost:" + server.getLocalPort() + "/test"));
       
        Assert.assertEquals(200, response.getStatus());
        Assert.assertTrue(response.getNonBlockingBody().isCompleteReceived());
       
        httpClient.close();
View Full Code Here


        HttpClient httpClient = new HttpClient();
        httpClient.setCallReturnOnMessage(true);
       
        IHttpResponse response = httpClient.call(new GetRequest("http://localhost:" + server.getLocalPort() + "/test"));
       
        Assert.assertEquals(200, response.getStatus());
        Assert.assertTrue(response.getNonBlockingBody().isCompleteReceived());
       
        httpClient.close();
View Full Code Here

        HttpClient httpClient = new HttpClient();
        httpClient.setMaxRetries(4);
        httpClient.setCallReturnOnMessage(true);
       
        try {
            httpClient.call(new GetRequest("http://localhost:" + server.getLocalPort() + "/test"));
            Assert.fail("IOException expected");
        } catch (IOException expected) { }
       
       
        httpClient.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.