public void testNestedOverflow()
    {
        final int bufSize = 256;
        final Bar bar = new Bar();

        // reserve 3 bytes:
        // 1st: tag
        // 2nd and 3rd: delimited length (greater than 127 takes to more than one byte)
        int repeat = bufSize - 3;
        bar.setSomeString(repeatChar('a', repeat));
        byte[] data = ProtobufIOUtil.toByteArray(bar, bar.cachedSchema(), buf(bufSize));
        assertEquals(bufSize, data.length);

        // additional size will be:
        // 1 (tag)
        // 1 (delimiter)
        // 1 + 1 = tag + value (10)
        // 1 + 1 + 3 = tag + delim + value ("baz")
        // 1 + 1 = tag + value (15)
        // =====
        // 11
        bar.setSomeBaz(new Baz(10, "baz", 15l));
        data = ProtobufIOUtil.toByteArray(bar, bar.cachedSchema(), buf(bufSize));
        assertEquals(bufSize + 11, data.length);

        final Bar parsedBar = new Bar();
        ProtobufIOUtil.mergeFrom(data, parsedBar, parsedBar.cachedSchema());
        assertEquals(bar, parsedBar);
    }
Test the buffering output capability of {@link ProtobufOutput}.

@author David Yu
@created Oct 7, 2010
protostuff-core/src/test/java/io/protostuff/ProtobufBufferedOutputTest.java