@Test(expectedExceptions = SystemException.class) public void testDecompressShouldThrowExceptionWhenStreamCopyThrowsIOException() throws IOException { given(gzipInputStreamFactory.createInputStream(source)).willReturn(gzipInputStream); given(gzipInputStream.read((byte[]) Mockito.any())).willThrow(new IOException()); underTest.decompress(source); }
@Override public ByteArrayOutputStream decompress(final InputStream inputStream) { OutputStream writer = outputStreamFactory.createByteArrayOutputStream(); try { GZIPInputStream gzipStream = gzipInputStreamFactory.createInputStream(inputStream); IOUtils.copy(gzipStream, writer); } catch (IOException e) { throw new SystemException("Could not ungzip message body!", e); } return (ByteArrayOutputStream) writer; }
GzipCompressionService implements CompressionService { @Override public ByteArrayOutputStream decompress(final InputStream inputStream) { OutputStream writer = outputStreamFactory.createByteArrayOutputStream(); try { GZIPInputStream gzipStream = gzipInputStreamFactory.createInputStream(inputStream); IOUtils.copy(gzipStream, writer); } catch (IOException e) { throw new SystemException("Could not ungzip message body!", e); } return (ByteArrayOutputStream) writer; } }
GzipCompressionService implements CompressionService { @Override public ByteArrayOutputStream decompress(final InputStream inputStream) { OutputStream writer = outputStreamFactory.createByteArrayOutputStream(); try { GZIPInputStream gzipStream = gzipInputStreamFactory.createInputStream(inputStream); IOUtils.copy(gzipStream, writer); } catch (IOException e) { throw new SystemException("Could not ungzip message body!", e); } return (ByteArrayOutputStream) writer; }  }
GzipCompressionService implements CompressionService { @Override public ByteArrayOutputStream decompress(final InputStream inputStream) { OutputStream writer = outputStreamFactory.createByteArrayOutputStream(); try { GZIPInputStream gzipStream = gzipInputStreamFactory.createInputStream(inputStream); IOUtils.copy(gzipStream, writer); } catch (IOException e) { throw new SystemException("Could not ungzip message body!", e); } return (ByteArrayOutputStream) writer; }  @Override ByteArrayOutputStream compress(final InputStream inputStream); @Override ByteArrayOutputStream decompress(final InputStream inputStream); }
GzipCompressionService implements CompressionService { @Override public ByteArrayOutputStream decompress(final InputStream inputStream) { OutputStream writer = outputStreamFactory.createByteArrayOutputStream(); try { GZIPInputStream gzipStream = gzipInputStreamFactory.createInputStream(inputStream); IOUtils.copy(gzipStream, writer); } catch (IOException e) { throw new SystemException("Could not ungzip message body!", e); } return (ByteArrayOutputStream) writer; }  @Override ByteArrayOutputStream compress(final InputStream inputStream); @Override ByteArrayOutputStream decompress(final InputStream inputStream);  }