@Test public void testWrite() throws Exception { ByteArrayOutputStream compressedData = new ByteArrayOutputStream(); DeflateOutputStream out = new DeflateOutputStream(compressedData, 5); out.write(data); try { out.getStreamMetadata(); fail("Should have thrown IllegalStateException that stream was not closed yet."); } catch(IllegalStateException e) { } out.close(); Map<String, String> m = out.getStreamMetadata(); assertEquals("Uncompressed digest incorrect", "027e997e6b1dfc97b93eb28dc9a6804096d85873", m.get(TransformConstants.META_COMPRESSION_UNCOMP_SHA1)); assertEquals("Compression ratio incorrect", "91.1%", m.get(TransformConstants.META_COMPRESSION_COMP_RATIO)); assertEquals("Uncompressed size incorrect", 2516125, Long.parseLong(m .get(TransformConstants.META_COMPRESSION_UNCOMP_SIZE))); assertEquals("Compressed size incorrect", 223548, Long.parseLong(m .get(TransformConstants.META_COMPRESSION_COMP_SIZE))); }
@Override public void write(int b) throws IOException { digester.write(b); }
DeflateOutputStream extends OutputStream implements CompressionStream { @Override public void write(int b) throws IOException { digester.write(b); } }
DeflateOutputStream extends OutputStream implements CompressionStream { @Override public void write(int b) throws IOException { digester.write(b); } DeflateOutputStream(OutputStream streamToCompress, int level); }
DeflateOutputStream extends OutputStream implements CompressionStream { @Override public void write(int b) throws IOException { digester.write(b); } DeflateOutputStream(OutputStream streamToCompress, int level); @Override Map<String, String> getStreamMetadata(); @Override void write(int b); @Override void close(); @Override void flush(); @Override void write(byte[] b, int off, int len); @Override void write(byte[] b); }
DeflateOutputStream extends OutputStream implements CompressionStream { @Override public void write(int b) throws IOException { digester.write(b); } DeflateOutputStream(OutputStream streamToCompress, int level); @Override Map<String, String> getStreamMetadata(); @Override void write(int b); @Override void close(); @Override void flush(); @Override void write(byte[] b, int off, int len); @Override void write(byte[] b);  }