use of com.google.api.client.http.HttpTransport in project google-api-java-client by google.
the class GoogleCredentialTest method testFromStreamNullStreamThrows.
public void testFromStreamNullStreamThrows() throws IOException {
HttpTransport transport = new MockHttpTransport();
try {
GoogleCredential.fromStream(null, transport, JSON_FACTORY);
fail();
} catch (NullPointerException expected) {
}
}
use of com.google.api.client.http.HttpTransport in project google-api-java-client by google.
the class GoogleCredentialTest method testFromStreamNullJsonFactoryThrows.
public void testFromStreamNullJsonFactoryThrows() throws IOException {
HttpTransport transport = new MockHttpTransport();
InputStream stream = new ByteArrayInputStream("foo".getBytes());
try {
GoogleCredential.fromStream(stream, transport, null);
fail();
} catch (NullPointerException expected) {
}
}
use of com.google.api.client.http.HttpTransport in project google-api-java-client by google.
the class GoogleJsonResponseExceptionTest method testFrom_detailsArbitraryJsonContent.
public void testFrom_detailsArbitraryJsonContent() throws Exception {
HttpTransport transport = new ErrorTransport("{\"foo\":\"bar\"}", Json.MEDIA_TYPE);
HttpRequest request = transport.createRequestFactory().buildGetRequest(HttpTesting.SIMPLE_GENERIC_URL);
request.setThrowExceptionOnExecuteError(false);
HttpResponse response = request.execute();
GoogleJsonResponseException ge = GoogleJsonResponseException.from(GoogleJsonErrorTest.FACTORY, response);
assertNull(ge.getDetails());
assertEquals("403", ge.getMessage());
}
use of com.google.api.client.http.HttpTransport in project google-api-java-client by google.
the class GoogleJsonResponseExceptionTest method testFrom_errorNoContentButWithJsonContentType.
public void testFrom_errorNoContentButWithJsonContentType() throws Exception {
HttpTransport transport = new ErrorTransport("", Json.MEDIA_TYPE);
HttpRequest request = transport.createRequestFactory().buildGetRequest(HttpTesting.SIMPLE_GENERIC_URL);
request.setThrowExceptionOnExecuteError(false);
HttpResponse response = request.execute();
GoogleJsonResponseException ge = GoogleJsonResponseException.from(GoogleJsonErrorTest.FACTORY, response);
assertNull(ge.getDetails());
assertEquals("403", ge.getMessage());
}
use of com.google.api.client.http.HttpTransport in project google-api-java-client by google.
the class GoogleJsonResponseExceptionTest method testFrom_detailsArbitraryXmlContent.
public void testFrom_detailsArbitraryXmlContent() throws Exception {
HttpTransport transport = new ErrorTransport("<foo>", "application/atom+xml; charset=utf-8");
HttpRequest request = transport.createRequestFactory().buildGetRequest(HttpTesting.SIMPLE_GENERIC_URL);
request.setThrowExceptionOnExecuteError(false);
HttpResponse response = request.execute();
GoogleJsonResponseException ge = GoogleJsonResponseException.from(GoogleJsonErrorTest.FACTORY, response);
assertNull(ge.getDetails());
assertTrue(ge.getMessage(), ge.getMessage().startsWith("403" + StringUtils.LINE_SEPARATOR + "<"));
}
Aggregations