private void serializeAndAssert(AlternateSpanList alternateSpanList) {
        GrowableByteBuffer buffer;
        {
            buffer = new GrowableByteBuffer(1024);
            DocumentSerializer serializer = DocumentSerializerFactory.createHead(buffer);
            StringFieldValue value = new StringFieldValue("lkj lkj lkj lkj lkj lkj lkj lkj lkj lkj lkj lkj lkj lkj lk");
            SpanTree tree = new SpanTree("bababa", alternateSpanList);
            value.setSpanTree(tree);
            serializer.write(null, value);
            buffer.flip();
        }
        AlternateSpanList alternateSpanList2;
        {
            DocumentDeserializer deserializer = DocumentDeserializerFactory.createHead(man, buffer);
            StringFieldValue value = new StringFieldValue();
            deserializer.read(null, value);
            alternateSpanList2 = (AlternateSpanList)value.getSpanTree("bababa").getRoot();
        }

        assertEquals(alternateSpanList, alternateSpanList2);
        assertNotSame(alternateSpanList, alternateSpanList2);
    }
@author <a href="mailto:einarmr@yahoo-inc.com">Einar M R Rosenvinge</a>
document/src/test/java/com/yahoo/document/annotation/AlternateSpanListTestCase.java