Package com.google.api.client.http

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


    // Enable direct media upload.
    uploader.setDirectUploadEnabled(true);
    // Set Metadata
    uploader.setMetadata(new MockHttpContent());

    HttpResponse response = uploader.upload(new GenericUrl(TEST_MULTIPART_REQUEST_URL));
    assertEquals(200, response.getStatusCode());

    // There should be only 1 call made for direct media upload.
    assertEquals(1, fakeTransport.lowLevelExecCalls);
  }
View Full Code Here


    // Enable direct media upload.
    uploader.setDirectUploadEnabled(true);
    // Set Metadata
    uploader.setMetadata(new MockHttpContent());

    HttpResponse response = uploader.upload(new GenericUrl(TEST_MULTIPART_REQUEST_URL));
    assertEquals(200, response.getStatusCode());

    // There should be only 1 call made for direct media upload.
    assertEquals(1, fakeTransport.lowLevelExecCalls);
  }
View Full Code Here

    ByteArrayContent mediaContent =
        new ByteArrayContent(TEST_CONTENT_TYPE, new byte[contentLength]);
    MediaHttpUploader uploader =
        new MediaHttpUploader(mediaContent, fakeTransport, new ZeroBackOffRequestInitializer());
    uploader.setDirectUploadEnabled(true);
    uploader.upload(new GenericUrl(TEST_DIRECT_REQUEST_URL));

    // should be 2 calls made: 1 upload request with server error, 1 successful upload request
    assertEquals(2, fakeTransport.lowLevelExecCalls);
  }
View Full Code Here

    fakeTransport.directUploadEnabled = true;
    ByteArrayContent mediaContent =
        new ByteArrayContent(TEST_CONTENT_TYPE, new byte[contentLength]);
    MediaHttpUploader uploader = new MediaHttpUploader(mediaContent, fakeTransport, null);
    uploader.setDirectUploadEnabled(true);
    uploader.upload(new GenericUrl(TEST_DIRECT_REQUEST_URL));

    // should be 1 call made: 1 upload request with server error
    assertEquals(1, fakeTransport.lowLevelExecCalls);
  }
View Full Code Here

    fakeTransport.directUploadEnabled = true;
    ByteArrayContent mediaContent =
        new ByteArrayContent(TEST_CONTENT_TYPE, new byte[contentLength]);
    MediaHttpUploader uploader = new MediaHttpUploader(mediaContent, fakeTransport, null);
    uploader.setDirectUploadEnabled(true);
    uploader.upload(new GenericUrl(TEST_DIRECT_REQUEST_URL));

    // There should be only 1 call made for direct media upload.
    assertEquals(1, fakeTransport.lowLevelExecCalls);
  }
View Full Code Here

    int contentLength = 0;
    MediaTransport fakeTransport = new MediaTransport(contentLength);
    ByteArrayContent mediaContent =
        new ByteArrayContent(TEST_CONTENT_TYPE, new byte[contentLength]);
    MediaHttpUploader uploader = new MediaHttpUploader(mediaContent, fakeTransport, null);
    uploader.upload(new GenericUrl(TEST_RESUMABLE_REQUEST_URL));

    // There should be 2 calls made. 1 initiation request and 1 upload request.
    assertEquals(2, fakeTransport.lowLevelExecCalls);
  }
View Full Code Here

    MediaTransport fakeTransport = new MediaTransport(contentLength);
    fakeTransport.contentLengthNotSpecified = true;
    InputStream is = new ByteArrayInputStream(new byte[contentLength]);
    InputStreamContent mediaContent = new InputStreamContent(TEST_CONTENT_TYPE, is);
    MediaHttpUploader uploader = new MediaHttpUploader(mediaContent, fakeTransport, null);
    uploader.upload(new GenericUrl(TEST_RESUMABLE_REQUEST_URL));

    // There should be 2 calls made. 1 initiation request and 1 upload request.
    assertEquals(2, fakeTransport.lowLevelExecCalls);
  }
View Full Code Here

    TestableByteArrayInputStream inputStream =
        new TestableByteArrayInputStream(new byte[contentLength]);
    InputStreamContent mediaContent =
        new InputStreamContent(TEST_CONTENT_TYPE, inputStream).setLength(contentLength);
    MediaHttpUploader uploader = new MediaHttpUploader(mediaContent, fakeTransport, null);
    uploader.upload(new GenericUrl(TEST_RESUMABLE_REQUEST_URL));
    assertTrue(inputStream.isClosed());
  }
View Full Code Here

    TestableByteArrayInputStream inputStream =
        new TestableByteArrayInputStream(new byte[contentLength]);
    InputStreamContent mediaContent = new InputStreamContent(
        TEST_CONTENT_TYPE, inputStream).setLength(contentLength).setCloseInputStream(false);
    MediaHttpUploader uploader = new MediaHttpUploader(mediaContent, fakeTransport, null);
    uploader.upload(new GenericUrl(TEST_RESUMABLE_REQUEST_URL));
    assertFalse(inputStream.isClosed());
  }
View Full Code Here

          .setTokenServerEncodedUrl(TOKEN_SERVER_ENCODED_URL));
    }

    @Override
    protected TokenResponse executeRefreshToken() throws IOException {
      GenericUrl tokenUrl = new GenericUrl(getTokenServerEncodedUrl());
      HttpRequest request = getTransport().createRequestFactory().buildGetRequest(tokenUrl);
      JsonObjectParser parser = new JsonObjectParser(getJsonFactory());
      request.setParser(parser);
      request.getHeaders().set("X-Google-Metadata-Request", true);
      request.setThrowExceptionOnExecuteError(false);
View Full Code Here

TOP

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

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.