BlockStream extends OutputStream { public BlockStream() { this(Block.DEFAULT_BLOCK_SIZE); } BlockStream();  BlockStream(int blockCapacity); @Override void write(byte[] data); @Override void write(int b); @Override void write(byte[] data, final int offset, final int length); long size(); long capacity(); Slice toSlice(); void reset(); void release();  }
@Test public void testBlockStream() { BlockStream bs = new BlockStream(); List<byte[]> totalList = Lists.newArrayList(); List<Slice> slices = Lists.newArrayList(); for (int tryTime = 0; tryTime < 10; ++tryTime) { List<byte[]> list = generateList(); totalList.addAll(list); writeToBlockStream(bs, list, slices); if (tryTime % 2 != 0) { verify(totalList, slices); bs.reset(); totalList.clear(); slices.clear(); } } }