@Test
public void testJavaSerialization() {
PartitionedEvent partitionedEvent = new PartitionedEvent();
partitionedEvent.setPartitionKey(partitionedEvent.hashCode());
partitionedEvent.setPartition(createSampleStreamGroupbyPartition("sampleStream", Arrays.asList("name", "host")));
StreamEvent event = new StreamEvent();
event.setStreamId("sampleStream");
event.setTimestamp(System.currentTimeMillis());
event.setData(new Object[] {"CPU", "LOCALHOST", true, Long.MAX_VALUE, 60.0});
partitionedEvent.setEvent(event);
int javaSerializationLength = SerializationUtils.serialize(partitionedEvent).length;
LOG.info("Java serialization length: {}, event: {}", javaSerializationLength, partitionedEvent);
int compactLength = 0;
compactLength += "sampleStream".getBytes().length;
compactLength += ByteUtils.intToBytes(partitionedEvent.getPartition().hashCode()).length;
compactLength += ByteUtils.longToBytes(partitionedEvent.getTimestamp()).length;
compactLength += "CPU".getBytes().length;
compactLength += "LOCALHOST".getBytes().length;
compactLength += 1;
compactLength += ByteUtils.longToBytes(Long.MAX_VALUE).length;
compactLength += ByteUtils.doubleToBytes(60.0).length;
LOG.info("Compact serialization length: {}, event: {}", compactLength, partitionedEvent);
Assert.assertTrue(compactLength * 20 < javaSerializationLength);
}