Package org.apache.http.client

Examples of org.apache.http.client.HttpClient.execute()


            StringEntity communityEntity = new StringEntity("{\"name\":\""+ community.name +"\"}");

            request.setEntity(communityEntity);
            Logger.info("ready");
            HttpResponse response = httpClient.execute(request);

            Logger.info("response: " + response.toString());
            if(response.getStatusLine().getStatusCode() == 200) {
                Logger.info("ok");
                Community parsedCommunity = Community.parseCommunityFromJSON(Json.parse(EntityUtils.toString(response.getEntity())));
View Full Code Here


            String email = requestData.get("email");
            String password = requestData.get("password");
            StringEntity params =new StringEntity("{\"email\":\"" + email + "\",\"password\":\"" + password + "\"}");
            request.addHeader("content-type", "application/json");
            request.setEntity(params);
            HttpResponse response = httpClient.execute(request);

            if(response.getStatusLine().getStatusCode() == 200) {
                String responseBody = EntityUtils.toString(response.getEntity());
                String token = responseBody;
                session().clear();
View Full Code Here

        try {
            HttpPost request = new HttpPost(baseRestUrl + "/logout");
            request.addHeader("Content-Type", "application/json");
            String token = session("userToken");
            request.addHeader("rest-dspace-token", token);
            HttpResponse response = httpClient.execute(request);

            session().remove("userEmail");
            session().remove("userFullname");
            session().clear();
View Full Code Here

            request.setHeader("Accept", "application/json");
            request.addHeader("content-type", "application/json");
            String token = session("userToken");
            request.addHeader("rest-dspace-token", token);

            HttpResponse response = httpClient.execute(request);
            String responseBody = EntityUtils.toString(response.getEntity());
            User user = new User();
            user = user.parseUserFromJSON(Json.parse(responseBody));
            setSessionFromUser(user);
View Full Code Here

        HttpGet request = new HttpGet(Application.baseRestUrl + "/collections/" + id + "?expand=all");
        request.setHeader("Accept", "application/json");
        request.addHeader("Content-Type", "application/json");
        request.addHeader("rest-dspace-token", token);
        HttpResponse httpResponse = httpClient.execute(request);

        JsonNode collNode = Json.parse(httpResponse.getEntity().getContent());

        Collection collection = new Collection();
View Full Code Here

                .put("sidebarText", this.sidebarText);
        StringEntity stringEntity = new StringEntity(jsonObjectNode.toString());
        Logger.info("EditCommunity certain attributes: " + jsonObjectNode.toString());

        request.setEntity(stringEntity);
        HttpResponse httpResponse = httpClient.execute(request);
        RestResponse restResponse = new RestResponse();
        restResponse.httpResponse = httpResponse;
        restResponse.endpoint = request.getURI().toString();
        return restResponse;
    }
View Full Code Here

   
    HttpResponse httpResponse = Mockito.mock(HttpResponse.class);
    when(httpResponse.getStatusLine()).thenReturn(statusLine);
    when(httpResponse.getEntity()).thenReturn(httpEntity);
   
    when(httpClient.execute(Mockito.any(HttpUriRequest.class))).thenReturn(httpResponse);
   
    TestWSPostAuthenticatedClient testClient = new TestWSPostAuthenticatedClient(params);
    testClient.setHttpClient(httpClient);

    return testClient;
View Full Code Here

    // create a HTTP client that always returns Cher top tracks
    HttpClient httpClient = mock(HttpClient.class);
    ClientConnectionManager connectionManager = mock(ClientConnectionManager.class);
    when(httpClient.getConnectionManager()).thenReturn(connectionManager);
    String httpResponse = new ResourceUtil(CHER_TOP_TAGS).getContent();
    when(httpClient.execute(Mockito.any(HttpUriRequest.class),
        Mockito.any(ResponseHandler.class))).thenReturn(httpResponse);

    // create a throttling service that allows calls at any rate
    ThrottleService throttleService = mock(ThrottleService.class);
View Full Code Here

  private TestWSGetClient getTestWSClient(
      boolean allowCalls, String responseURI) throws IOException {
    TestWSGetClient testWSClient = getTestWSClient(allowCalls);
    HttpClient httpClient = testWSClient.getHttpClient();
    String httpResponse = new ResourceUtil(responseURI).getContent();
    when(httpClient.execute(Mockito.any(HttpUriRequest.class),
        Mockito.any(ResponseHandler.class))).thenReturn(httpResponse);
    return testWSClient;
  }
 
  /*
 
View Full Code Here

   */
  @SuppressWarnings("unchecked")
  private TestWSGetClient getTestWSClient(Exception e) throws IOException {
    TestWSGetClient testWSClient = getTestWSClient(true);
    HttpClient httpClient = testWSClient.getHttpClient();
    when(httpClient.execute(Mockito.any(HttpUriRequest.class),
        Mockito.any(ResponseHandler.class))).thenThrow(e);
    return testWSClient;
  }
 
  /*
 
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.