Package com.google.api.client.http

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


    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());

    // There should be 3 calls made. 1 initiation request, 1 successful upload request and 1 upload
    // request with server error
    assertEquals(3, fakeTransport.lowLevelExecCalls);
View Full Code Here


    MediaHttpUploader uploader =
        new MediaHttpUploader(mediaContent, fakeTransport, new ZeroBackOffRequestInitializer());

    // disable GZip - so we would be able to test byte received by server.
    uploader.setDisableGZipContent(true);
    HttpResponse response = uploader.upload(new GenericUrl(TEST_RESUMABLE_REQUEST_URL));
    assertEquals(200, response.getStatusCode());

    // There should be the following number of calls made:
    // 1 initiation request + 1 call to query the range + chunks
    int calls = 2 + chunks;
View Full Code Here

    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);
    } catch (IOException e) {
      // There should be 3 calls made. 1 initiation request, 1 successful upload request,
      // and 1 upload request with server error
      assertEquals(3, fakeTransport.lowLevelExecCalls);
View Full Code Here

    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());

    // There should be 3 calls made. 1 initiation request, 1 successful upload request and 1 upload
    // request with server error
    assertEquals(3, fakeTransport.lowLevelExecCalls);
View Full Code Here

    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());

    // There should be only 1 initiation request made with a 404.
    assertEquals(1, fakeTransport.lowLevelExecCalls);
  }
View Full Code Here

    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());

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

    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());

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

    MediaHttpUploader uploader = new MediaHttpUploader(mediaContent, fakeTransport, null);
    uploader.setProgressListener(new DirectProgressListener());
    // Enable direct media upload.
    uploader.setDirectUploadEnabled(true);

    HttpResponse response = uploader.upload(new GenericUrl(TEST_DIRECT_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

    uploader.getInitiationHeaders().set("test-header-name", "test-header-value");
    uploader.setProgressListener(new DirectProgressListener());
    // Enable direct media upload.
    uploader.setDirectUploadEnabled(true);

    HttpResponse response = uploader.upload(new GenericUrl(TEST_DIRECT_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

    listener.contentLengthNotSpecified = true;
    uploader.setProgressListener(listener);
    // Enable direct media upload.
    uploader.setDirectUploadEnabled(true);

    HttpResponse response = uploader.upload(new GenericUrl(TEST_DIRECT_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

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.