when(inputStream.read()).thenThrow(expectedException);
when(inputStream.read(any(byte[].class))).thenThrow(expectedException);
when(inputStream.read(any(byte[].class), anyInt(), anyInt())).thenThrow(expectedException);
try {
handler.handle(null, new TestingResponse(OK, contentType(MEDIA_TYPE_SMILE), inputStream));
fail("expected exception");
}
catch (RuntimeException e) {
assertEquals(e.getMessage(), "Error reading SMILE response from server");
assertSame(e.getCause(), expectedException);