### Question:
HttpByteArrayCacheEntrySerializer implements HttpCacheEntrySerializer<byte[]> { @Override public HttpCacheStorageEntry deserialize(final byte[] serializedObject) throws ResourceIOException { try (final InputStream in = makeByteArrayInputStream(serializedObject); final ByteArrayOutputStream bytesOut = new ByteArrayOutputStream(serializedObject.length) ) { final SessionInputBufferImpl inputBuffer = new SessionInputBufferImpl(BUFFER_SIZE); final AbstractMessageParser<ClassicHttpResponse> responseParser = makeHttpResponseParser(); final ClassicHttpResponse response = responseParser.parse(inputBuffer, in); final String storageKey = getCachePseudoHeaderAndRemove(response, SC_HEADER_NAME_STORAGE_KEY); final Date requestDate = getCachePseudoHeaderDateAndRemove(response, SC_HEADER_NAME_REQUEST_DATE); final Date responseDate = getCachePseudoHeaderDateAndRemove(response, SC_HEADER_NAME_RESPONSE_DATE); final boolean noBody = getCachePseudoHeaderBooleanAndRemove(response, SC_HEADER_NAME_NO_CONTENT); final Map<String, String> variantMap = getVariantMapPseudoHeadersAndRemove(response); unescapeHeaders(response); final Resource resource; if (noBody) { resource = null; } else { copyBytes(inputBuffer, in, bytesOut); resource = new HeapResource(bytesOut.toByteArray()); } final HttpCacheEntry httpCacheEntry = new HttpCacheEntry( requestDate, responseDate, response.getCode(), response.getHeaders(), resource, variantMap ); return new HttpCacheStorageEntry(storageKey, httpCacheEntry); } catch (final IOException|HttpException e) { throw new ResourceIOException("Error deserializing cache entry", e); } } HttpByteArrayCacheEntrySerializer(); @Override byte[] serialize(final HttpCacheStorageEntry httpCacheEntry); @Override HttpCacheStorageEntry deserialize(final byte[] serializedObject); static final HttpByteArrayCacheEntrySerializer INSTANCE; }### Answer:
@Test(expected = ResourceIOException.class) public void testDeserializeWithIOException() throws Exception { final AbstractMessageParser<ClassicHttpResponse> throwyParser = Mockito.mock(AbstractMessageParser.class); Mockito. doThrow(new IOException("Test Exception")). when(throwyParser). parse(Mockito.any(SessionInputBuffer.class), Mockito.any(InputStream.class)); final HttpByteArrayCacheEntrySerializer testSerializer = new HttpByteArrayCacheEntrySerializer() { @Override protected AbstractMessageParser<ClassicHttpResponse> makeHttpResponseParser() { return throwyParser; } }; testSerializer.deserialize(new byte[0]); }