Пример #1
0
  private void doConnectionClosesTest(String url, TestBootstrapServer server) throws Exception {
    String responseData = "this is response data";
    int length = responseData.length();
    server.setResponseData(responseData);
    server.setResponse("HTTP/1.1 200 OK\r\nContent-Length: " + length);
    server.setAllowConnectionReuse(true);
    HttpGet get;
    LimeHttpClient client;

    get = new HttpGet(url);
    client = injector.getInstance(Key.get(LimeHttpClient.class));
    HttpResponse response = null;
    try {
      response = client.execute(get);
    } finally {
      client.releaseConnection(response);
    }

    Thread.sleep(1000 * 70);

    get = new HttpGet(url);
    client = injector.getInstance(Key.get(LimeHttpClient.class));
    try {
      response = client.execute(get);
    } finally {
      client.releaseConnection(response);
    }

    assertEquals("wrong connection attempts", 2, server.getConnectionAttempts());
    assertEquals("wrong request attempts", 2, server.getRequestAttempts());
  }
Пример #2
0
 private void doUppercaseTest(String url, TestBootstrapServer server) throws Exception {
   // Make sure we can deal with strange info such as uppercase
   // HTTP stuff.
   HttpGet get = new HttpGet(url.toUpperCase());
   HttpClient client = injector.getInstance(Key.get(LimeHttpClient.class));
   client.execute(get);
   assertNotNull(server.getRequest());
 }