@Test
    public void testSerialize() {
        docUp.addFieldUpdate(assignSingle);
        docUp.addFieldUpdate(addMultiList);

        GrowableByteBuffer buf = new GrowableByteBuffer();
        docUp.serialize(DocumentSerializerFactory.createHead(buf));
        buf.flip();

        try {
            FileOutputStream fos = new FileOutputStream("src/test/files/updateser.dat");
            fos.write(buf.array(), 0, buf.remaining());
            fos.close();
        } catch (Exception e) {
        }

        assertEquals((17 + 1) //docid id:ns:foobar:bar\0
                     + (6 + 1 + 2) //doctype foobar\0\0\0
                     + 4 //num field updates

                     //field update 1:
                     + (4 //field id
                        + 4 //num valueupdates

                        + (4 //valueUpdateClassID
                           + 1 //valuepresent
                           + (1 + 1 + 9 + 1)) //value

                        //field update 2
                        + (4 //field id
                           + 4 //num valueupdates

                           + (4  //valueUpdateClassID
                              + (4 + 4 + 4 + (1 + 1 + 2 + 1) + 4 + (1 + 1 + 2 + 1) + 4 + (1 + 1 + 2 + 1))))) //value
                        + 4 //num field path updates
                , buf.remaining());

        DocumentUpdate docUpDeser = new DocumentUpdate(DocumentDeserializerFactory.createHead(docMan, buf));
        assertEquals(docUp.getDocumentType(), docUpDeser.getDocumentType());
        assertEquals(docUp, docUpDeser);
    }
Tests applying and serializing document updates.

@author Einar M R Rosenvinge
document/src/test/java/com/yahoo/document/DocumentUpdateTestCase.java