private void testByteBufferRoundTrip(short version, Message message, Message expected) throws Exception {
        ObjectSerializationCache cache = new ObjectSerializationCache();
        int size = message.size(cache, version);
        ByteBuffer buf = ByteBuffer.allocate(size);
        ByteBufferAccessor byteBufferAccessor = new ByteBufferAccessor(buf);
        message.write(byteBufferAccessor, cache, version);
        assertEquals(size, buf.position(), "The result of the size function does not match the number of bytes " +
            "written for version " + version);
        Message message2 = message.getClass().getConstructor().newInstance();
        buf.flip();
        message2.read(byteBufferAccessor, version);
        assertEquals(size, buf.position(), "The result of the size function does not match the number of bytes " +
            "read back in for version " + version);
        assertEquals(expected, message2, "The message object created after a round trip did not match for " +
            "version " + version);
        assertEquals(expected.hashCode(), message2.hashCode());
        assertEquals(expected.toString(), message2.toString());
    }
@param startVersion - the version we want to start at, inclusive
@param endVersion - the version we want to end at, exclusive
clients/src/test/java/org/apache/kafka/common/message/MessageTest.java