Code example for ByteArrayDataOutput

Methods: toByteArray

0
    public void testSerialization() throws Exception {
        final Broker broker = new Broker("127.0.0.1", 9092, 1);
        final Partition partition = new Partition("topic_name", 0, broker);
        final KafkaInputSplit split = new KafkaInputSplit(partition, 0, 10l, false);
        final ByteArrayDataOutput out = ByteStreams.newDataOutput();
        split.write(out);
 
        final KafkaInputSplit actual = new KafkaInputSplit();
        actual.readFields(ByteStreams.newDataInput(out.toByteArray()));
 
        assertEquals(split, actual);
    } 
}