Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Upgrade to HTTP client that logs exception message
  • Loading branch information
medb committed Mar 16, 2020
commit 35a3379c44d574e4ee05a5faff0fe763caf8b99d
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package com.google.api.client.googleapis.json;

import com.google.api.client.googleapis.json.GoogleJsonErrorTest.ErrorTransport;
import com.google.api.client.http.GenericUrl;
import com.google.api.client.http.HttpRequest;
import com.google.api.client.http.HttpResponse;
import com.google.api.client.http.HttpTransport;
Expand Down Expand Up @@ -43,7 +42,7 @@ public void testFrom_noDetails() throws Exception {
GoogleJsonResponseException responseException =
GoogleJsonResponseException.from(GoogleJsonErrorTest.FACTORY, response);
assertNull(responseException.getDetails());
String expectedMessage = "200" + getRequestUrl(HttpTesting.SIMPLE_GENERIC_URL);
String expectedMessage = "200\nGET " + HttpTesting.SIMPLE_GENERIC_URL;
assertEquals(expectedMessage, responseException.getMessage());
}

Expand All @@ -59,7 +58,7 @@ public void testFrom_withDetails() throws Exception {
GoogleJsonErrorTest.ERROR,
GoogleJsonErrorTest.FACTORY.toString(responseException.getDetails()));
String expectedMessage =
"403" + getRequestUrl(HttpTesting.SIMPLE_GENERIC_URL) + StringUtils.LINE_SEPARATOR + "{";
"403\nGET " + HttpTesting.SIMPLE_GENERIC_URL + StringUtils.LINE_SEPARATOR + "{";
assertTrue(
responseException.getMessage(), responseException.getMessage().startsWith(expectedMessage));
}
Expand All @@ -73,7 +72,7 @@ public void testFrom_detailsMissingContent() throws Exception {
GoogleJsonResponseException responseException =
GoogleJsonResponseException.from(GoogleJsonErrorTest.FACTORY, response);
assertNull(responseException.getDetails());
String expectedMessage = "403" + getRequestUrl(HttpTesting.SIMPLE_GENERIC_URL);
String expectedMessage = "403\nGET " + HttpTesting.SIMPLE_GENERIC_URL;
assertEquals(expectedMessage, responseException.getMessage());
}

Expand All @@ -86,7 +85,7 @@ public void testFrom_detailsArbitraryJsonContent() throws Exception {
GoogleJsonResponseException responseException =
GoogleJsonResponseException.from(GoogleJsonErrorTest.FACTORY, response);
assertNull(responseException.getDetails());
String expectedMessage = "403" + getRequestUrl(HttpTesting.SIMPLE_GENERIC_URL);
String expectedMessage = "403\nGET " + HttpTesting.SIMPLE_GENERIC_URL;
assertEquals(expectedMessage, responseException.getMessage());
}

Expand All @@ -100,7 +99,7 @@ public void testFrom_detailsArbitraryXmlContent() throws Exception {
GoogleJsonResponseException.from(GoogleJsonErrorTest.FACTORY, response);
assertNull(responseException.getDetails());
String expectedMessage =
"403" + getRequestUrl(HttpTesting.SIMPLE_GENERIC_URL) + StringUtils.LINE_SEPARATOR + "<";
"403\nGET " + HttpTesting.SIMPLE_GENERIC_URL + StringUtils.LINE_SEPARATOR + "<";
assertTrue(
responseException.getMessage(), responseException.getMessage().startsWith(expectedMessage));
}
Expand All @@ -114,7 +113,7 @@ public void testFrom_errorNoContentButWithJsonContentType() throws Exception {
GoogleJsonResponseException responseException =
GoogleJsonResponseException.from(GoogleJsonErrorTest.FACTORY, response);
assertNull(responseException.getDetails());
String expectedMessage = "403" + getRequestUrl(HttpTesting.SIMPLE_GENERIC_URL);
String expectedMessage = "403\nGET " + HttpTesting.SIMPLE_GENERIC_URL;
assertEquals(expectedMessage, responseException.getMessage());
}

Expand All @@ -127,7 +126,7 @@ public void testFrom_errorEmptyContentButWithJsonContentType() throws Exception
GoogleJsonResponseException responseException =
GoogleJsonResponseException.from(GoogleJsonErrorTest.FACTORY, response);
assertNull(responseException.getDetails());
String expectedMessage = "403" + getRequestUrl(HttpTesting.SIMPLE_GENERIC_URL);
String expectedMessage = "403\nGET " + HttpTesting.SIMPLE_GENERIC_URL;
assertEquals(expectedMessage, responseException.getMessage());
}

Expand Down Expand Up @@ -166,11 +165,8 @@ public void testFrom_detailsNoErrorField() throws Exception {
GoogleJsonResponseException responseException =
GoogleJsonResponseException.from(GoogleJsonErrorTest.FACTORY, response);
assertNull(responseException.getDetails());
String expectedMessage = "403" + getRequestUrl(HttpTesting.SIMPLE_GENERIC_URL);
String expectedMessage = "403\nGET " + HttpTesting.SIMPLE_GENERIC_URL;
assertEquals(expectedMessage, responseException.getMessage());
}

private static String getRequestUrl(GenericUrl requestUrl) {
return "\nRequest URL: " + requestUrl;
}
}
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@
</build>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.http.version>1.34.2</project.http.version>
<project.http.version>1.34.3</project.http.version>
<project.oauth.version>1.30.6</project.oauth.version>
<project.jsr305.version>3.0.2</project.jsr305.version>
<project.gson.version>2.8.6</project.gson.version>
Expand Down