DeflateCompressor implements Compressor { @Override public void compress(InputStream uncompressedIn, OutputStream compressedOut) throws IOException { byte[] buffer = new byte[inputBufferSize]; DeflaterOutputStream deflaterOut = new DeflaterOutputStream(compressedOut, createOrResetDeflater(), outputBufferSize); int numRead = 0; while ((numRead = uncompressedIn.read(buffer)) >= 0) { deflaterOut.write(buffer, 0, numRead); } deflaterOut.finish(); deflaterOut.flush(); }  boolean isNowrap(); void setNowrap(boolean nowrap); int getCompressionLevel(); void setCompressionLevel(int compressionLevel); int getStrategy(); void setStrategy(int strategy); int getInputBufferSize(); void setInputBufferSize(int inputBufferSize); int getOutputBufferSize(); void setOutputBufferSize(int outputBufferSize); boolean isCaching(); void setCaching(boolean caching); void release(); @Override void compress(InputStream uncompressedIn, OutputStream compressedOut);  }
@Test public void testCompress() throws IOException { compressor.compress(rawContentIn, compressedContentOut); Assert.assertTrue(compressedContentOut.size() > 0); Assert.assertTrue(compressedContentOut.size() < CONTENT.length); byte[] uncompressed = uncompressWithJavaInflater(compressor.isNowrap(), compressedContentOut.toByteArray()); Assert.assertArrayEquals(CONTENT, uncompressed); }