ChunkedOutputStream extends OutputStream { public void write(int b) throws IOException { assertNotTransfered(); ensureCapacity( 1 ); current.write( b ); } ChunkedOutputStream(int initialCapacity, int extentCapacity); void write(int b); void write( byte b[] ); void write(byte b[], int off, int len); int written(); void transferTo( OutputStream target ); byte[] computeSHA256();  }
@Test public void test1() throws Exception { ChunkedOutputStream chunkedOutputStream = new ChunkedOutputStream( 100, 10 ); assertEquals( 1, chunkedOutputStream.chunks.size() ); chunkedOutputStream.write( new byte[ 100 ] ); assertEquals( 1, chunkedOutputStream.chunks.size() ); chunkedOutputStream.write( (byte) 0x00 ); assertEquals( 2, chunkedOutputStream.chunks.size() ); assertEquals( 100, chunkedOutputStream.chunks.get( 0 ).capacity() ); assertEquals( 10, chunkedOutputStream.chunks.get( 1 ).capacity() ); }