Examples of IHttpResponse


Examples of com.subgraph.vega.api.http.requests.IHttpResponse

  @Override
  public void run() {
   
    final IHttpRequestEngine requestEngine = createRequestEngine();
    final IHttpResponse response = sendRequest(requestEngine);
    if(response != null && !response.getBodyAsString().isEmpty()) {
      processResponseBody(response.getBodyAsString());
    }
  }
View Full Code Here

Examples of org.xlightweb.IHttpResponse

   
    @Test
    public void testSSL() throws Exception {
    HttpClient httpClient = new HttpClient(SSLTestContextFactory.getSSLContext());
   
    IHttpResponse response = httpClient.call(new GetRequest("https://localhost:" + proxySslServer.getLocalPort() + "/test"));
    Assert.assertEquals(200, response.getStatus());
    Assert.assertEquals("isSecured=true", response.getBody().readString());
   
    httpClient.close();
  }
View Full Code Here

Examples of org.xlightweb.IHttpResponse

   
    @Test
    public void testPlain() throws Exception {
        HttpClient httpClient = new HttpClient(SSLTestContextFactory.getSSLContext());
       
        IHttpResponse response = httpClient.call(new GetRequest("http://localhost:" + proxyServer.getLocalPort() + "/test"));
        Assert.assertEquals(200, response.getStatus());
        Assert.assertEquals("isSecured=false", response.getBody().readString());
       
        httpClient.close();
    }
View Full Code Here

Examples of org.xlightweb.IHttpResponse

    server.start();
   
   
    HttpClient httpClient = new HttpClient();
   
    IHttpResponse response = httpClient.call(new GetRequest("http://localhost:" + server.getLocalPort() + "/site/" + testFile.getName()));
    Assert.assertEquals(200, response.getStatus());
    Assert.assertEquals("application/octet-stream", response.getContentType());
    Assert.assertTrue(response.hasBody());
   
    response = httpClient.call(new GetRequest("http://localhost:" + server.getLocalPort() + "/rpc/getCustomers"));
    Assert.assertEquals(200, response.getStatus());
    Assert.assertTrue(response.getContentType().startsWith("text/plain"));
    Assert.assertTrue(response.hasBody());
   
    httpClient.close();
    server.close();
   
   
View Full Code Here

Examples of org.xlightweb.IHttpResponse

    server.start();
   
   
    HttpClient httpClient = new HttpClient();
   
    IHttpResponse response = httpClient.call(new GetRequest("http://localhost:" + server.getLocalPort() + "/site/" + testFile.getName()));
    Assert.assertEquals(200, response.getStatus());
    Assert.assertEquals("application/octet-stream", response.getContentType());
    Assert.assertTrue(response.hasBody());
   
    response = httpClient.call(new GetRequest("http://localhost:" + server.getLocalPort() + "/rpc/getCustomers"));
    Assert.assertEquals(200, response.getStatus());
    Assert.assertTrue(response.getContentType().startsWith("text/plain"));
    Assert.assertTrue(response.hasBody());
   
    httpClient.close();
    server.close();
   
   
View Full Code Here

Examples of org.xlightweb.IHttpResponse

      IServer server = new HttpServer(port, rootCtx);
      server.start();

      HttpClient httpClient = new HttpClient()
     
      IHttpResponse response = httpClient.call(new GetRequest("http://localhost:" + server.getLocalPort()+ "/Person/1"));
      Assert.assertEquals(200, response.getStatus());
      Assert.assertEquals("person", response.getBlockingBody().readString());
     
      response = httpClient.call(new GetRequest("http://localhost:" + server.getLocalPort()+ "/Account/1"));
        Assert.assertEquals(200, response.getStatus());
        Assert.assertEquals("account", response.getBlockingBody().readString());
     
      httpClient.close();
      server.close();
    }
View Full Code Here

Examples of org.xlightweb.IHttpResponse

    server.start();
   
   
    HttpClient httpClient = new HttpClient();
   
    IHttpResponse response = httpClient.call(new GetRequest("http://localhost:" + server.getLocalPort() + "/test"));
    Assert.assertEquals(200, response.getStatus());
   
    response = httpClient.call(new GetRequest("http://localhost:" + server.getLocalPort() + "/badRequest"));
    Assert.assertEquals(400, response.getStatus());

    httpClient.close();
    server.close();
  }
View Full Code Here

Examples of org.xlightweb.IHttpResponse

    server.start();
   
   
    HttpClient httpClient = new HttpClient();
   
    IHttpResponse response = httpClient.call(new GetRequest("http://localhost:" + jettyServer.getConnectors()[0].getLocalPort() + "/ctx1/test/you"));
    if (response.getStatus() != 200) {
      System.out.println("got " + response.getStatus() + " instead of 200");
      Assert.fail();
    }
   
    String body = response.getBlockingBody().readString();
    if (body.indexOf("contextPath=/ctx1") == -1) {
      System.out.println("contextPath=/ctx1 expected");
      Assert.fail();
    }
   
    if (body.indexOf("contextPath=/ctx1") == -1) {
      System.out.println("servletPath=/test expected");
      Assert.fail();
    }

   
    response = httpClient.call(new GetRequest("http://localhost:" + server.getLocalPort() + "/ctx1/test/you"));
    if (response.getStatus() != 200) {
      System.out.println("got " + response.getStatus());
      Assert.fail();
    }
   
    body = response.getBlockingBody().readString();
    Assert.assertTrue(body.indexOf("contextPath=/ctx1") != -1);
    Assert.assertTrue(body.indexOf("servletPath=/test") != -1);

   
    httpClient.close();
View Full Code Here

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.assertTrue(resp.getHeader(CacheHandler.XHEADER_NAME).startsWith("HIT"));
        Assert.assertEquals("test", resp.getBody().readString());
       
       
        Assert.assertEquals(1, httpClient.getNumCacheHit());
        Assert.assertEquals(1, httpClient.getNumCacheMiss());
       
View Full Code Here

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
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.