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

        ByteArrayInputStream smileStream = new ByteArrayInputStream(smile);

        byte[] protostuff = ProtostuffIOUtil.toByteArray(
                SmileIOUtil.newPipe(smile, 0, smile.length, false), pipeSchema, buf());

        byte[] protostuffFromStream = ProtostuffIOUtil.toByteArray(
                SmileIOUtil.newPipe(smileStream, false), pipeSchema, buf());

        assertTrue(Arrays.equals(protostuff, protostuffFromStream));

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

        ByteArrayInputStream protostuffStream = new ByteArrayInputStream(protostuff);

        byte[] smileRoundTrip = SmileIOUtil.toByteArray(
                ProtostuffIOUtil.newPipe(protostuff, 0, protostuff.length), pipeSchema, false);

        byte[] smileRoundTripFromStream = SmileIOUtil.toByteArray(
                ProtostuffIOUtil.newPipe(protostuffStream), pipeSchema, false);

        assertTrue(Arrays.equals(smileRoundTrip, smileRoundTripFromStream));

        assertTrue(smileRoundTrip.length == smile.length);

        // comment out since smile encodes strings differently when using direct
        // SmileGenerator.writeUTF8String() ... (w/c is only used when the pipe source
        // is binary and the utf8 is intact (e.g protostuff,protobuf)

        // THE reason is that even if the string provided is ascii, smile encodes it
        // as unicode. See line 1043 of SmileGenerator.
        // assertEquals(strSmileRoundTrip, STRING.deser(smile));

        // This will fail on some messages.
        T messageSmile = schema.newMessage();
        SmileIOUtil.mergeFrom(smile, messageSmile, schema, false);
        T messageSmileRoundTrip = schema.newMessage();
        SmileIOUtil.mergeFrom(smileRoundTrip, messageSmileRoundTrip, schema, false);

        assertEquals(messageSmile, messageSmileRoundTrip);
    }
Test smile ser/deser for runtime {@link Object} fields.

@author David Yu
@created Feb 11, 2011
protostuff-json/src/test/java/io/protostuff/SmileRuntimeObjectSchemaTest.java