@Test
public void readToBufferWithArrayOffsetFailsWithInvalidMessageChecksum() throws Exception {

  fakeService.setReturnIncorrectMessageChecksum();
  GoogleCloudStorageReadOptions options =
      GoogleCloudStorageReadOptions.builder().setGrpcChecksumsEnabled(true).build();
  GoogleCloudStorageGrpcReadChannel readChannel = newReadChannel(options);
  byte[] array = new byte[OBJECT_SIZE + 100];
  // `ByteBuffer.slice` generates a ByteBuffer with a non-zero `arrayOffset`.
  ByteBuffer buffer = ByteBuffer.wrap(array, 50, OBJECT_SIZE).slice();
  IOException thrown = assertThrows(IOException.class, () -> readChannel.read(buffer));
  assertTrue(
      thrown.getMessage() + " should have contained 'checksum'",
      thrown.getMessage().contains("checksum"));
}