Search in sources :

Example 6 with MockHttpClient

use of com.google.api.client.testing.http.apache.MockHttpClient in project google-http-java-client by googleapis.

the class ApacheHttpRequestTest method testContentLengthSet.

@Test
public void testContentLengthSet() throws Exception {
    HttpExtensionMethod base = new HttpExtensionMethod("POST", "http://www.google.com");
    ApacheHttpRequest request = new ApacheHttpRequest(new MockHttpClient(), base);
    HttpContent content = new ByteArrayContent("text/plain", "sample".getBytes(StandardCharsets.UTF_8));
    request.setStreamingContent(content);
    request.setContentLength(content.getLength());
    request.execute();
    assertFalse(base.getEntity().isChunked());
    assertEquals(6, base.getEntity().getContentLength());
}
Also used : ByteArrayContent(com.google.api.client.http.ByteArrayContent) MockHttpClient(com.google.api.client.testing.http.apache.MockHttpClient) HttpContent(com.google.api.client.http.HttpContent) Test(org.junit.Test)

Aggregations

MockHttpClient (com.google.api.client.testing.http.apache.MockHttpClient)6 Test (org.junit.Test)6 ByteArrayInputStream (java.io.ByteArrayInputStream)4 Host (ch.cyberduck.core.Host)3 TestProtocol (ch.cyberduck.core.TestProtocol)3 SDSApiClient (ch.cyberduck.core.sds.SDSApiClient)3 SDSSession (ch.cyberduck.core.sds.SDSSession)3 FileKey (ch.cyberduck.core.sds.io.swagger.client.model.FileKey)3 DefaultX509KeyManager (ch.cyberduck.core.ssl.DefaultX509KeyManager)3 DisabledX509TrustManager (ch.cyberduck.core.ssl.DisabledX509TrustManager)3 TransferStatus (ch.cyberduck.core.transfer.TransferStatus)3 PlainFileKey (com.dracoon.sdk.crypto.model.PlainFileKey)3 ObjectReader (com.fasterxml.jackson.databind.ObjectReader)3 ObjectWriter (com.fasterxml.jackson.databind.ObjectWriter)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 StreamCopier (ch.cyberduck.core.io.StreamCopier)2 HttpContent (com.google.api.client.http.HttpContent)2 ByteArrayContent (com.google.api.client.http.ByteArrayContent)1 InputStreamContent (com.google.api.client.http.InputStreamContent)1 HttpClient (org.apache.http.client.HttpClient)1