Skip to content

Commit e7d5c83

Browse files
authored
fix: future test breakage (#1457)
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.
1 parent b79be2d commit e7d5c83

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

google-api-client/src/test/java/com/google/api/client/googleapis/services/AbstractGoogleClientRequestTest.java

+7-8
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,8 @@ public LowLevelHttpResponse execute() {
281281
MockGoogleClientRequest<String> request = new MockGoogleClientRequest<String>(
282282
client, HttpMethods.GET, URI_TEMPLATE, null, String.class);
283283
InputStream inputStream = request.executeAsInputStream();
284-
assertTrue(inputStream instanceof GZIPInputStream);
284+
// The response will be wrapped because of gzip encoding
285+
assertFalse(inputStream instanceof ByteArrayInputStream);
285286
}
286287

287288
public void testReturnRawInputStream_True() throws Exception {
@@ -291,12 +292,9 @@ public LowLevelHttpRequest buildRequest(final String method, final String url) {
291292
return new MockLowLevelHttpRequest() {
292293
@Override
293294
public LowLevelHttpResponse execute() {
294-
byte[] data = BaseEncoding.base64().decode(
295-
"H4sIAAAAAAAAAPNIzcnJV3DPz0/PSVVwzskvTVEILskvSkxPVQQA/LySchsAAAA=");
296-
ByteArrayInputStream content = new ByteArrayInputStream(data);
297-
return new MockLowLevelHttpResponse()
298-
.setContentEncoding("gzip")
299-
.setContent(content);
295+
return new MockLowLevelHttpResponse().setContentEncoding("gzip").setContent(new ByteArrayInputStream(
296+
BaseEncoding.base64()
297+
.decode("H4sIAAAAAAAAAPNIzcnJV3DPz0/PSVVwzskvTVEILskvSkxPVQQA/LySchsAAAA=")));
300298
}
301299
};
302300
}
@@ -308,7 +306,8 @@ public LowLevelHttpResponse execute() {
308306
client, HttpMethods.GET, URI_TEMPLATE, null, String.class);
309307
request.setReturnRawInputStream(true);
310308
InputStream inputStream = request.executeAsInputStream();
311-
assertFalse(inputStream instanceof GZIPInputStream);
309+
// The response will not be wrapped due to setReturnRawInputStream(true)
310+
assertTrue(inputStream instanceof ByteArrayInputStream);
312311
}
313312

314313
private class AssertHeaderTransport extends MockHttpTransport {

0 commit comments

Comments
 (0)