@Test
    public void testNoSpuriousWrite() throws IOException {
        OutputStream grumpy = new CurmudgeonlyStream();
        ByteWriter bw = new ByteWriter(grumpy, encoder);
        final int SINGLE_BUFFER = 500;
        final int APPENDS = 500;
        assertTrue("Code has been changed making constants in this test meaningless, review test.",
                BufferChain.BUFFERSIZE * BufferChain.MAXBUFFERS < SINGLE_BUFFER * APPENDS);
        assertTrue("Code has been changed making constants in this test meaningless, review test.",
                BufferChain.WATERMARK > SINGLE_BUFFER);
        stream.reset();
        byte[] c = new byte[SINGLE_BUFFER];
        for (int i = APPENDS; i > 0; --i) {
            try {
                bw.append(c);
            } catch (IOException e) {
                if (e.getMessage() == CurmudgeonlyStream.ZERO_LENGTH_WRITE) {
                    fail(CurmudgeonlyStream.ZERO_LENGTH_WRITE);
                } else {
                    throw e;
                }
            }
        }
        try {
            bw.close();
        } catch (IOException e) {
            if (e.getMessage() == CurmudgeonlyStream.ZERO_LENGTH_WRITE) {
                fail(CurmudgeonlyStream.ZERO_LENGTH_WRITE);
            } else {
                throw e;
            }
        }
    }
A stream which does nothing, but complains if it is called and asked to
do nothing.
vespajlib/src/test/java/com/yahoo/io/ByteWriterTestCase.java