@Override
    protected <T> void roundTrip(T message, Schema<T> schema,
            Pipe.Schema<T> pipeSchema) throws Exception
    {
        byte[] protobuf = ProtobufIOUtil.toByteArray(message, schema, buf());

        ByteArrayInputStream protobufStream = new ByteArrayInputStream(protobuf);

        byte[] protostuff = ProtostuffIOUtil.toByteArray(
                ProtobufIOUtil.newPipe(protobuf, 0, protobuf.length),
                pipeSchema, buf());

        byte[] protostuffFromStream = ProtostuffIOUtil.toByteArray(
                ProtobufIOUtil.newPipe(protobufStream), pipeSchema, buf());

        assertTrue(protostuff.length == protostuffFromStream.length);
        assertEquals(STRING.deser(protostuff),
                STRING.deser(protostuffFromStream));

        T parsedMessage = schema.newMessage();
        ProtostuffIOUtil.mergeFrom(protostuff, parsedMessage, schema);
        SerializableObjects.assertEquals(message, parsedMessage);

        ByteArrayInputStream protostuffStream = new ByteArrayInputStream(
                protostuff);

        byte[] protobufRoundTrip = ProtobufIOUtil.toByteArray(
                ProtostuffIOUtil.newPipe(protostuff, 0, protostuff.length),
                pipeSchema, buf());

        byte[] protobufRoundTripFromStream = ProtobufIOUtil.toByteArray(
                ProtostuffIOUtil.newPipe(protostuffStream), pipeSchema, buf());

        assertTrue(protobufRoundTrip.length == protobufRoundTripFromStream.length);

        String strProtobufRoundTrip = STRING.deser(protobufRoundTrip);

        assertEquals(strProtobufRoundTrip,
                STRING.deser(protobufRoundTripFromStream));

        assertTrue(protobufRoundTrip.length == protobuf.length);

        assertEquals(strProtobufRoundTrip, STRING.deser(protobuf));
    }
Test runtime collection fields with {@link CollectionSchema} via protobuf ser/deser.

@author David Yu
@created Jan 26, 2011
protostuff-runtime/src/test/java/io/protostuff/runtime/ProtobufRuntimeCollectionSchemaTest.java