Package com.google.api.client.http

Examples of com.google.api.client.http.HttpTransport


  @Override
  public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
    loadMovieData();

    // Set up Json parser and authentication before making Prediction API calls
    HttpTransport transport = GoogleTransport.create();
    transport.addParser(new JsonCParser());
    authenticateWithClientLogin(transport);

    final Float[] predictedRatings = new Float[numMovies];
    for (int i = 0; i < numMovies; i++) {
      /*
 
View Full Code Here


    // generate the signature
    params.computeSignature(requestMethod, url);

    // make the request
    HttpTransport transport = new NetHttpTransport();
    HttpRequestFactory f = null;
    if (useOAuth) {
      f = transport.createRequestFactory(params);
    } else {
      f = transport.createRequestFactory();
    }
    HttpRequest request = null;
    if ("POST".equals(requestMethod))
      if (postData == null)
        request = f.buildPostRequest(url, null);
View Full Code Here

  static final String ACCESS_TOKEN = "ya29.AHES6ZRN3-HlhAPya30GnW_bHSb_QtAS08i85nHq39HE3C2LTrCARA";

  public void testExecuteRefreshToken() throws Exception {

    HttpTransport transport = new MockMetadataServerTransport(ACCESS_TOKEN);

    ComputeCredential credential = new ComputeCredential(transport, new JacksonFactory());

    assertTrue(credential.refreshToken());
    assertEquals(ACCESS_TOKEN, credential.getAccessToken());
View Full Code Here

    assertEquals(requestMethod, shouldOverride ? requestMethod : null,
        request.getHeaders().get(MethodOverride.HEADER));
  }

  public void testInterceptMaxLength() throws IOException {
    HttpTransport transport = new MockHttpTransport();
    GenericUrl url = new GenericUrl(HttpTesting.SIMPLE_URL);
    url.set("a", "foo");
    HttpRequest request =
        transport.createRequestFactory().buildGetRequest(HttpTesting.SIMPLE_GENERIC_URL);
    new MethodOverride().intercept(request);
    assertEquals(HttpMethods.GET, request.getRequestMethod());
    assertNull(request.getHeaders().get(MethodOverride.HEADER));
    assertNull(request.getContent());
    char[] arr = new char[MethodOverride.MAX_URL_LENGTH];
View Full Code Here

  private static final int MAX_AGE = 12345;

  private static final int AGE = 42;

  public void testBuilder() throws Exception {
    HttpTransport transport = new MockHttpTransport();
    JsonFactory jsonFactory = new JacksonFactory();
    GooglePublicKeysManager.Builder builder = new GooglePublicKeysManager.Builder(transport, jsonFactory);

    GooglePublicKeysManager certs = builder.build();
    assertEquals(transport, certs.getTransport());
View Full Code Here

    } catch (NullPointerException expected) {
    }
  }

  public void testGetApplicationDefaultNullJsonFactoryThrows() throws IOException {
    HttpTransport transport = new MockHttpTransport();
    try {
      GoogleCredential.getApplicationDefault(transport, null);
      fail();
    } catch (NullPointerException expected) {
    }
View Full Code Here

    } catch (NullPointerException expected) {
    }
  }

  public void testFromStreamNullJsonFactoryThrows() throws IOException {
    HttpTransport transport = new MockHttpTransport();
    InputStream stream = new ByteArrayInputStream("foo".getBytes());
    try {
      GoogleCredential.fromStream(stream, transport, null);
      fail();
    } catch (NullPointerException expected) {
View Full Code Here

    } catch (NullPointerException expected) {
    }
  }

  public void testFromStreamNullStreamThrows() throws IOException {
    HttpTransport transport = new MockHttpTransport();
    try {
      GoogleCredential.fromStream(null, transport, JSON_FACTORY);
      fail();
    } catch (NullPointerException expected) {
    }
View Full Code Here

    JsonFactory secondCall = Utils.getDefaultJsonFactory();
    assertSame(jsonFactory, secondCall);
  }

  public void testGetDefaultTransport() {
    HttpTransport transport = Utils.getDefaultTransport();
    assertNotNull(transport);
    assertTrue(transport instanceof NetHttpTransport);
    HttpTransport secondCall = Utils.getDefaultTransport();
    assertSame(transport, secondCall);
  }
View Full Code Here

      "{\"error\":{\"code\":401,\"errors\":[{\"domain\":\"global\","
      + "\"location\":\"Authorization\",\"locationType\":\"header\","
      + "\"message\":\"me\",\"reason\":\"authError\"}],\"message\":\"me\"}}";

  public void testExecuteUnparsed_error() throws Exception {
    HttpTransport transport = new MockHttpTransport() {
      @Override
      public LowLevelHttpRequest buildRequest(final String method, final String url) {
        return new MockLowLevelHttpRequest() {
          @Override
          public LowLevelHttpResponse execute() {
View Full Code Here

TOP

Related Classes of com.google.api.client.http.HttpTransport

Copyright © 2018 www.massapicom. 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.