static <T> void checkCompat(byte[] json, byte[] jsonFromStream,
            byte[] source, Pipe.Schema<T> pipeSchema, boolean numeric, boolean protostuff)
            throws IOException
    {
        // check compatibilty for JsonOutput and JsonXOutput

        ByteArrayOutputStream out = new ByteArrayOutputStream();
        ByteArrayInputStream in = new ByteArrayInputStream(source);
        LinkedBuffer buffer = buf();
        try
        {
            JsonXIOUtil.writeTo(out,
                    protostuff ? ProtostuffIOUtil.newPipe(in) : ProtobufIOUtil.newPipe(in),
                    pipeSchema, numeric, buffer);
        }
        finally
        {
            buffer.clear();
        }

        byte[] jsonxFromStream = out.toByteArray();

        byte[] jsonx = JsonXIOUtil.toByteArray(
                protostuff ? ProtostuffIOUtil.newPipe(source, 0, source.length) :
                        ProtobufIOUtil.newPipe(source, 0, source.length),
                pipeSchema, numeric, buf());

        assertTrue(jsonx.length == jsonxFromStream.length);
        assertEquals(STRING.deser(jsonx), STRING.deser(jsonxFromStream));
        assertEquals(STRING.deser(json), STRING.deser(jsonx));
    }
Test case for json pipes.

@author David Yu
@created Oct 8, 2010
protostuff-json/src/test/java/io/protostuff/JsonPipeTest.java