Examples of InputStreamContent


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

  public void testUploadProgressListener_WithNoContentSizeProvided() throws Exception {
    int contentLength = MediaHttpUploader.DEFAULT_CHUNK_SIZE * 2;
    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);
    ResumableProgressListenerWithTwoUploadCalls listener =
        new ResumableProgressListenerWithTwoUploadCalls();
    listener.contentLengthNotSpecified = true;
    uploader.setProgressListener(listener);
View Full Code Here

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

  public void testUploadServerError_WithoutUnsuccessfulHandler() throws Exception {
    int contentLength = MediaHttpUploader.DEFAULT_CHUNK_SIZE * 2;
    MediaTransport fakeTransport = new MediaTransport(contentLength);
    fakeTransport.testServerError = true;
    InputStream is = new ByteArrayInputStream(new byte[contentLength]);
    InputStreamContent mediaContent = new InputStreamContent(TEST_CONTENT_TYPE, is);
    mediaContent.setLength(contentLength);
    MediaHttpUploader uploader = new MediaHttpUploader(mediaContent, fakeTransport, null);

    HttpResponse response = uploader.upload(new GenericUrl(TEST_RESUMABLE_REQUEST_URL));
    assertEquals(500, response.getStatusCode());

View Full Code Here

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

    fakeTransport.contentLengthNotSpecified = !contentLengthKnown;
    fakeTransport.maxByteIndexUploadedOnError = maxByteIndexUploadedOnError;
    byte[] testedData = new byte[contentLength];
    new Random().nextBytes(testedData);
    InputStream is = new ByteArrayInputStream(testedData);
    InputStreamContent mediaContent = new InputStreamContent(TEST_CONTENT_TYPE, is);
    if (contentLengthKnown) {
      mediaContent.setLength(contentLength);
    }
    MediaHttpUploader uploader =
        new MediaHttpUploader(mediaContent, fakeTransport, new ZeroBackOffRequestInitializer());

    // disable GZip - so we would be able to test byte received by server.
View Full Code Here

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

  public void testUploadIOException_WithoutIOExceptionHandler() throws Exception {
    int contentLength = MediaHttpUploader.DEFAULT_CHUNK_SIZE * 2;
    MediaTransport fakeTransport = new MediaTransport(contentLength);
    fakeTransport.testIOException = true;
    InputStream is = new ByteArrayInputStream(new byte[contentLength]);
    InputStreamContent mediaContent = new InputStreamContent(TEST_CONTENT_TYPE, is);
    mediaContent.setLength(contentLength);
    MediaHttpUploader uploader = new MediaHttpUploader(mediaContent, fakeTransport, null);

    try {
      uploader.upload(new GenericUrl(TEST_RESUMABLE_REQUEST_URL));
      fail("expected " + IOException.class);
View Full Code Here

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

    int contentLength = MediaHttpUploader.DEFAULT_CHUNK_SIZE * 2;
    MediaTransport fakeTransport = new MediaTransport(contentLength);
    fakeTransport.testServerError = true;
    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);

    HttpResponse response = uploader.upload(new GenericUrl(TEST_RESUMABLE_REQUEST_URL));
    assertEquals(500, response.getStatusCode());

View Full Code Here

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

  public void testUploadAuthenticationError() throws Exception {
    int contentLength = MediaHttpUploader.DEFAULT_CHUNK_SIZE * 2;
    MediaTransport fakeTransport = new MediaTransport(contentLength);
    fakeTransport.testAuthenticationError = true;
    InputStream is = new ByteArrayInputStream(new byte[contentLength]);
    InputStreamContent mediaContent = new InputStreamContent(TEST_CONTENT_TYPE, is);
    mediaContent.setLength(contentLength);
    MediaHttpUploader uploader = new MediaHttpUploader(mediaContent, fakeTransport, null);

    HttpResponse response = uploader.upload(new GenericUrl(TEST_RESUMABLE_REQUEST_URL));
    assertEquals(404, response.getStatusCode());

View Full Code Here

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

  public void testUploadClientErrorInUploadCalls() throws Exception {
    int contentLength = MediaHttpUploader.DEFAULT_CHUNK_SIZE * 2;
    MediaTransport fakeTransport = new MediaTransport(contentLength);
    fakeTransport.testClientError = true;
    InputStream is = new ByteArrayInputStream(new byte[contentLength]);
    InputStreamContent mediaContent = new InputStreamContent(TEST_CONTENT_TYPE, is);
    mediaContent.setLength(contentLength);
    MediaHttpUploader uploader = new MediaHttpUploader(mediaContent, fakeTransport, null);

    HttpResponse response = uploader.upload(new GenericUrl(TEST_RESUMABLE_REQUEST_URL));
    assertEquals(411, response.getStatusCode());

View Full Code Here

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

    int contentLength = MediaHttpUploader.DEFAULT_CHUNK_SIZE * 2;
    MediaTransport fakeTransport = new MediaTransport(contentLength);
    fakeTransport.testClientError = true;
    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);

    HttpResponse response = uploader.upload(new GenericUrl(TEST_RESUMABLE_REQUEST_URL));
    assertEquals(411, response.getStatusCode());

View Full Code Here

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

  public void testDirectMediaUpload() throws Exception {
    int contentLength = MediaHttpUploader.DEFAULT_CHUNK_SIZE * 2;
    MediaTransport fakeTransport = new MediaTransport(contentLength);
    fakeTransport.directUploadEnabled = true;
    InputStream is = new ByteArrayInputStream(new byte[contentLength]);
    InputStreamContent mediaContent = new InputStreamContent(TEST_CONTENT_TYPE, is);
    mediaContent.setLength(contentLength);
    MediaHttpUploader uploader = new MediaHttpUploader(mediaContent, fakeTransport, null);
    uploader.setProgressListener(new DirectProgressListener());
    // Enable direct media upload.
    uploader.setDirectUploadEnabled(true);

View Full Code Here

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

    int contentLength = MediaHttpUploader.DEFAULT_CHUNK_SIZE * 2;
    MediaTransport fakeTransport = new MediaTransport(contentLength);
    fakeTransport.directUploadEnabled = true;
    fakeTransport.assertTestHeaders = true;
    InputStream is = new ByteArrayInputStream(new byte[contentLength]);
    InputStreamContent mediaContent = new InputStreamContent(TEST_CONTENT_TYPE, is);
    mediaContent.setLength(contentLength);
    MediaHttpUploader uploader = new MediaHttpUploader(mediaContent, fakeTransport, null);
    uploader.getInitiationHeaders().set("test-header-name", "test-header-value");
    uploader.setProgressListener(new DirectProgressListener());
    // Enable direct media upload.
    uploader.setDirectUploadEnabled(true);
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.