@Test
    public void testSerializationRoundtrip() throws IOException, ClassNotFoundException {
        //assert TopicPartition is serializable and deserialization renders the clone of original properly
        TopicPartition origTp = new TopicPartition(topicName, partNum);
        byte[] byteArray = Serializer.serialize(origTp);

        //deserialize the byteArray and check if the values are same as original
        Object deserializedObject = Serializer.deserialize(byteArray);
        assertInstanceOf(TopicPartition.class, deserializedObject);
        checkValues((TopicPartition) deserializedObject);
    }
This test ensures TopicPartition class is serializable and is serialization compatible.
Note: this ensures that the current code can deserialize data serialized with older versions of the code, but not the reverse.
That is, older code won't necessarily be able to deserialize data serialized with newer code.
clients/src/test/java/org/apache/kafka/common/TopicPartitionTest.java