Skip to content

Commit

Permalink
fix: future test breakage (#1457)
Browse files Browse the repository at this point in the history
In a a future commit the wrapping of these InputStreams will change.
This should ensure the tests will still pass while at the same time
validating the raw InputStream behavior still works.
  • Loading branch information
codyoss committed Dec 18, 2019
1 parent b79be2d commit e7d5c83
Showing 1 changed file with 7 additions and 8 deletions.
Expand Up @@ -281,7 +281,8 @@ public LowLevelHttpResponse execute() {
MockGoogleClientRequest<String> request = new MockGoogleClientRequest<String>(
client, HttpMethods.GET, URI_TEMPLATE, null, String.class);
InputStream inputStream = request.executeAsInputStream();
assertTrue(inputStream instanceof GZIPInputStream);
// The response will be wrapped because of gzip encoding
assertFalse(inputStream instanceof ByteArrayInputStream);
}

public void testReturnRawInputStream_True() throws Exception {
Expand All @@ -291,12 +292,9 @@ public LowLevelHttpRequest buildRequest(final String method, final String url) {
return new MockLowLevelHttpRequest() {
@Override
public LowLevelHttpResponse execute() {
byte[] data = BaseEncoding.base64().decode(
"H4sIAAAAAAAAAPNIzcnJV3DPz0/PSVVwzskvTVEILskvSkxPVQQA/LySchsAAAA=");
ByteArrayInputStream content = new ByteArrayInputStream(data);
return new MockLowLevelHttpResponse()
.setContentEncoding("gzip")
.setContent(content);
return new MockLowLevelHttpResponse().setContentEncoding("gzip").setContent(new ByteArrayInputStream(
BaseEncoding.base64()
.decode("H4sIAAAAAAAAAPNIzcnJV3DPz0/PSVVwzskvTVEILskvSkxPVQQA/LySchsAAAA=")));
}
};
}
Expand All @@ -308,7 +306,8 @@ public LowLevelHttpResponse execute() {
client, HttpMethods.GET, URI_TEMPLATE, null, String.class);
request.setReturnRawInputStream(true);
InputStream inputStream = request.executeAsInputStream();
assertFalse(inputStream instanceof GZIPInputStream);
// The response will not be wrapped due to setReturnRawInputStream(true)
assertTrue(inputStream instanceof ByteArrayInputStream);
}

private class AssertHeaderTransport extends MockHttpTransport {
Expand Down

0 comments on commit e7d5c83

Please sign in to comment.