@Test
public void testSharedBufferSerialization() throws IOException, ClassNotFoundException {

	SharedBuffer<String, Event> sharedBuffer = new SharedBuffer<>(Event.createTypeSerializer());
	int numberEvents = 8;
	Event[] events = new Event[numberEvents];
	final long timestamp = 1L;
	for (int i = 0; i < numberEvents; i++) {
		events[i] = new Event(i + 1, "e" + (i + 1), i);
	}
	sharedBuffer.put("a1", events[0], timestamp, null, null, 0, 0, DeweyNumber.fromString("1"));
	sharedBuffer.put("a[]", events[1], timestamp, "a1", events[0], timestamp, 0, DeweyNumber.fromString("1.0"));
	sharedBuffer.put("a1", events[2], timestamp, null, null, 0, 0, DeweyNumber.fromString("2"));
	sharedBuffer.put("a[]", events[2], timestamp, "a[]", events[1], timestamp, 1, DeweyNumber.fromString("1.0"));
	sharedBuffer.put("a[]", events[3], timestamp, "a[]", events[2], timestamp, 2, DeweyNumber.fromString("1.0"));
	sharedBuffer.put("a[]", events[3], timestamp, "a1", events[2], timestamp, 0, DeweyNumber.fromString("2.0"));
	sharedBuffer.put("a[]", events[4], timestamp, "a[]", events[3], timestamp, 3, DeweyNumber.fromString("1.0"));
	sharedBuffer.put("b", events[5], timestamp, "a[]", events[4], timestamp, 4, DeweyNumber.fromString("1.0.0"));
	sharedBuffer.put("a[]", events[5], timestamp, "a[]", events[4], timestamp, 4, DeweyNumber.fromString("1.1"));
	sharedBuffer.put("b", events[5], timestamp, "a[]", events[3], timestamp, 1, DeweyNumber.fromString("2.0.0"));
	sharedBuffer.put("a[]", events[6], timestamp, "a[]", events[5], timestamp, 5, DeweyNumber.fromString("1.1"));
	sharedBuffer.put("b", events[7], timestamp, "a[]", events[6], timestamp, 6, DeweyNumber.fromString("1.1.0"));
	SharedBuffer.SharedBufferSerializer serializer = new SharedBuffer.SharedBufferSerializer(
			StringSerializer.INSTANCE, Event.createTypeSerializer());
	ByteArrayOutputStream baos = new ByteArrayOutputStream();
	serializer.serialize(sharedBuffer, new DataOutputViewStreamWrapper(baos));
	ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
	SharedBuffer<String, Event> copy = serializer.duplicate().deserialize(new DataInputViewStreamWrapper(bais));
	assertEquals(sharedBuffer, copy);
}