Package com.google.api.client.http

Examples of com.google.api.client.http.HttpRequest.execute()


   public void should_ReturnExpectedError_WhenSuccessfulEmptyPostMade_ToAdminPortalRoot() throws Exception {

      final String requestUrl = String.format("%s/", ADMIN_URL);
      final HttpRequest httpPuttRequest = HttpUtils.constructHttpRequest(HttpMethods.POST, requestUrl);

      final HttpResponse httpResponse = httpPuttRequest.execute();
      final String statusMessage = httpResponse.getStatusMessage().trim();

      assertThat(httpResponse.getStatusCode()).isEqualTo(HttpStatus.NO_CONTENT_204);
      assertThat(statusMessage).isEqualTo("POST request on URI / was empty");
   }
View Full Code Here


   public void should_ReturnExpectedError_WhenSuccessfulInvalidPostMade_ToAdminPortalRoot() throws Exception {

      final String requestUrl = String.format("%s/", ADMIN_URL);
      final HttpRequest httpPuttRequest = HttpUtils.constructHttpRequest(HttpMethods.POST, requestUrl, "unparseable rubbish post content");

      final HttpResponse httpResponse = httpPuttRequest.execute();
      final String statusMessage = httpResponse.getStatusMessage().trim();
      final String responseMessage = httpResponse.parseAsString().trim();

      final String expectedMessage = "Problem handling request in Admin handler: java.io.IOException: Loaded YAML root node must be an instance of ArrayList, otherwise something went wrong. Check provided YAML";
View Full Code Here

         .build();

      final String requestUrl = String.format("%s/", ADMIN_URL);
      final HttpRequest httpPuttRequest = HttpUtils.constructHttpRequest(HttpMethods.POST, requestUrl, yamlToUpdate);

      final HttpResponse httpResponse = httpPuttRequest.execute();
      final String statusMessage = httpResponse.getStatusMessage().trim();
      final String responseMessage = httpResponse.parseAsString().trim();
      final String responseLocationHeader = httpResponse.getHeaders().getLocation();

      assertThat(httpResponse.getStatusCode()).isEqualTo(HttpStatus.CREATED_201);
View Full Code Here

  public final OAuthCredentialsResponse execute() throws IOException {
    HttpRequestFactory requestFactory = transport.createRequestFactory();
    HttpRequest request =
        requestFactory.buildRequest(usePost ? HttpMethod.POST : HttpMethod.GET, this, null);
    createParameters().intercept(request);
    HttpResponse response = request.execute();
    response.setContentLoggingLimit(0);
    OAuthCredentialsResponse oauthResponse = new OAuthCredentialsResponse();
    UrlEncodedParser.parse(response.parseAsString(), oauthResponse);
    return oauthResponse;
  }
View Full Code Here

    HttpRequest request = new FakeResponseHttpTransport(
        statusCode, partContent, headerNames, headerValues).createRequestFactory()
        .buildPostRequest(new GenericUrl("http://google.com/"), null);
    request.setLoggingEnabled(false);
    request.setThrowExceptionOnExecuteError(false);
    return request.execute();
  }

  /**
   * If the boundary line consists of the boundary and "--" then there are no more individual
   * responses left to be parsed and the input stream is closed.
View Full Code Here

    // make request
    HttpRequest request = requestFactory.buildPostRequest(
        tokenServerUrl, new UrlEncodedContent(this));
    request.setParser(new JsonObjectParser(jsonFactory));
    request.setThrowExceptionOnExecuteError(false);
    HttpResponse response = request.execute();
    if (response.isSuccessStatusCode()) {
      return response;
    }
    throw TokenResponseException.from(jsonFactory, response);
  }
View Full Code Here

    HttpRequest request =
        transport.createRequestFactory().buildPostRequest(url, new UrlEncodedContent(this));
    request.setParser(AuthKeyValueParser.INSTANCE);
    request.setContentLoggingLimit(0);
    request.setThrowExceptionOnExecuteError(false);
    HttpResponse response = request.execute();
    // check for an HTTP success response (2xx)
    if (response.isSuccessStatusCode()) {
      return response.parseAs(Response.class);
    }
    // On error, throw a ClientLoginResponseException with the parsed error details
View Full Code Here

    }

    do {
      retryAllowed = retriesRemaining > 0;
      batchRequest.setContent(new MultipartMixedContent(requestInfos, "__END_OF_PART__"));
      HttpResponse response = batchRequest.execute();
      BatchUnparsedResponse batchResponse;
      try {
        // Find the boundary from the Content-Type header.
        String boundary = "--" + response.getMediaType().getParameter("boundary");
View Full Code Here

    if (directDownloadEnabled) {
      updateStateAndNotifyListener(DownloadState.MEDIA_IN_PROGRESS);

      HttpRequest request = requestFactory.buildGetRequest(requestUrl);
      HttpResponse response = request.execute();

      try {
        // All required bytes have been downloaded from the server.
        mediaContentLength = response.getHeaders().getContentLength();
        bytesDownloaded = mediaContentLength;
View Full Code Here

        // Set ExponentialBackOffPolicy as the BackOffPolicy of the HTTP Request which will
        // retry the same request again if there is a server error.
        request.setBackOffPolicy(new ExponentialBackOffPolicy());
      }

      HttpResponse response = request.execute();
      AbstractInputStreamContent.copy(response.getContent(), outputStream);

      String contentRange = response.getHeaders().getContentRange();
      long nextByteIndex = getNextByteIndex(contentRange);
      setMediaContentLength(contentRange);
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.