Code example for URL

Methods: getHost, getPort

0
 
  private String url;
 
  private JSONArray getSessions() throws Exception {
    HttpClient client = HttpClientFactory.getClient();
    URL u = new URL(url);
    BasicHttpEntityEnclosingRequest r = new BasicHttpEntityEnclosingRequest("GET", url);
 
    HttpHost h = new HttpHost(u.getHost(), u.getPort());
    HttpResponse response = client.execute(h, r);
 
    Response resp = Helper.exctractResponse(response);
    String value = (String) resp.getValue();
    return new JSONArray(value);
  } 
 
  @Test 
  public void canGetSessionsFromServer() throws JSONException, Exception { 
    url = getRemoteURL() + "/sessions";
 
    Assert.assertEquals(getSessions().length(), 0);