Package com.google.api.client.http

Examples of com.google.api.client.http.HttpResponse.parseAsString()


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

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

      assertThat(httpResponse.getStatusCode()).isEqualTo(HttpStatus.NOT_IMPLEMENTED_501);
      assertThat(statusMessage).isEqualTo("Not Implemented");
      assertThat(responseMessage).isEqualTo("");
   }
View Full Code Here


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

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

      assertThat(httpResponse.getStatusCode()).isEqualTo(HttpStatus.NOT_IMPLEMENTED_501);
      assertThat(statusMessage).isEqualTo("Not Implemented");
      assertThat(responseMessage).isEqualTo("Method TRACE is not implemented on URI /");
   }
View Full Code Here

      final String requestUrl = String.format("%s%s", ADMIN_URL, "/status");
      final HttpRequest httpGetRequest = HttpUtils.constructHttpRequest(HttpMethods.GET, requestUrl);

      final HttpResponse httpResponse = httpGetRequest.execute();
      final String responseContentAsString = httpResponse.parseAsString().trim();

      assertThat(httpResponse.getStatusCode()).isEqualTo(HttpStatus.OK_200);
      assertThat(responseContentAsString).contains("/pdf/hello-world");
      assertThat(responseContentAsString).contains("STATUS");
      assertThat(responseContentAsString).contains("/uri/with/single/sequenced/response");
View Full Code Here

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

      final HttpResponse httpResponse = httpGetRequest.execute();
      final String responseContentAsString = httpResponse.parseAsString().trim();

      assertThat(httpResponse.getStatusCode()).isEqualTo(HttpStatus.OK_200);
      assertThat(responseContentAsString).contains("request");
      assertThat(responseContentAsString).contains("url: ^/resources/asn/");
      assertThat(responseContentAsString).contains("content-disposition: attachment; filename=hello-world.pdf");
View Full Code Here

      final String requestUrl = String.format("%s%s", ADMIN_URL, "/0");
      final HttpRequest httpGetRequest = HttpUtils.constructHttpRequest(HttpMethods.GET, requestUrl);

      final HttpResponse httpResponse = httpGetRequest.execute();
      final String responseContentAsString = httpResponse.parseAsString().trim();

      assertThat(httpResponse.getStatusCode()).isEqualTo(HttpStatus.OK_200);
      assertThat(responseContentAsString).containsOnlyOnce("request");
      assertThat(responseContentAsString).containsOnlyOnce("url: ^/resources/asn/");
      assertThat(responseContentAsString).containsOnlyOnce("response");
View Full Code Here

        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;
  }

  /**
   * Returns a new instance of the OAuth authentication provider. Subclasses may override by calling
View Full Code Here

            + " the virtual machine instance does not have permission scopes specified.",
            statusCode));
      }
      throw new IOException(String.format("Unexpected Error code %s trying to get security access"
          + " token from Compute Engine metadata for the default service account: %s", statusCode,
          response.parseAsString()));
    }
  }
}
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.