CustomizableByteArrayOutputStream extends OutputStream { @Synchronized public void reset() { this.count = 0; this.buffer = new byte[initialCapacity]; } CustomizableByteArrayOutputStream(int initialCapacity, int maxArraySize, double fillFactorToCopy); @Override @Synchronized void write(int byteToWrite); @Override @Synchronized void write(byte[] buffer, int off, int len); @Synchronized byte[] getBufferOrCopy(); @Synchronized int size(); @Override void close(); @Synchronized void reset();  }
@Test void reset() { tested.write(10); tested.write(20); tested.reset(); assertThat(tested.count).isEqualTo(0); assertThat(tested.buffer).hasSize(INITIAL_CAPACITY); }