@Test(expected = TransportException.class)
public void testGzipErrorsResponse() throws TransportException, IOException {

  byte[] respPayload = "gzip resp".getBytes(StandardCharsets.UTF_8);
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  GZIPOutputStream os = new GZIPOutputStream(baos);
  os.write(respPayload);
  os.close();
  byte[] compressedResponse = baos.toByteArray();
  HttpClient client = getMockClientWithResponse(compressedResponse, ContentType.DEFAULT_BINARY,
      HttpStatus.SC_INTERNAL_SERVER_ERROR, true);
  HttpTransport transport = new HttpTransport(client, "", true, 1, 1);
  try {
    transport.sendBatch("foo".getBytes());
  } catch (Exception e) {
    assertEquals(
        "http transport call failed because \"expected failure\" payload response \"gzip resp\"",
        e.getCause().getMessage());
    throw e;
  }
}