// register class def
transferClassDefinition(data, serializationService, serializationService2);
// emulate socket write by writing data to stream
BufferObjectDataOutput out = serializationService.createObjectDataOutput(1024);
out.writeData(data);
byte[] bytes = out.toByteArray();
byte[] header = ((PortableDataOutput) out).getPortableHeader();
// emulate socket read by reading data from stream
BufferObjectDataInput in = serializationService2.createObjectDataInput(new DefaultData(0, bytes, 0, header));