use of com.google.api.client.googleapis.testing.services.MockGoogleClientRequest in project google-api-java-client by google.
the class AbstractGoogleClientRequestTest method testExecute_void.
public void testExecute_void() throws Exception {
HttpTransport transport = new MockHttpTransport() {
@Override
public LowLevelHttpRequest buildRequest(final String method, final String url) {
return new MockLowLevelHttpRequest() {
@Override
public LowLevelHttpResponse execute() {
return new MockLowLevelHttpResponse().setContent("{\"a\":\"ignored\"}").setContentType(Json.MEDIA_TYPE);
}
};
}
};
MockGoogleClient client = new MockGoogleClient.Builder(transport, ROOT_URL, SERVICE_PATH, JSON_OBJECT_PARSER, null).setApplicationName("Test Application").build();
MockGoogleClientRequest<Void> request = new MockGoogleClientRequest<Void>(client, HttpMethods.GET, URI_TEMPLATE, null, Void.class);
Void v = request.execute();
assertNull(v);
}
use of com.google.api.client.googleapis.testing.services.MockGoogleClientRequest in project google-api-java-client by google.
the class AbstractGoogleClientTest method testMediaUpload_disableGZip.
public void testMediaUpload_disableGZip() throws Exception {
MediaTransport transport = new MediaTransport();
transport.contentLengthNotSpecified = true;
AbstractGoogleClient client = new MockGoogleClient.Builder(transport, TEST_RESUMABLE_REQUEST_URL, "", JSON_OBJECT_PARSER, new GZipCheckerInitializer(true)).setApplicationName("Test Application").build();
InputStream is = new ByteArrayInputStream(new byte[MediaHttpUploader.DEFAULT_CHUNK_SIZE]);
InputStreamContent mediaContent = new InputStreamContent(TEST_CONTENT_TYPE, is);
MockGoogleClientRequest<A> rq = new MockGoogleClientRequest<A>(client, "POST", "", null, A.class);
rq.initializeMediaUpload(mediaContent);
rq.setDisableGZipContent(true);
A result = rq.execute();
assertEquals("somevalue", result.foo);
}
Aggregations