@Test
    @SuppressWarnings("deprecation")
    public void testDocumentComparisonDoesNotCorruptStateBug6394548() {
        DocumentTypeManager docMan = new DocumentTypeManager();
        DocumentType docType = new DocumentType("bug2354045");
        docType.addField(new Field("string", 2, DataType.STRING));
        docType.addField(new Field("int", 1, DataType.INT));
        docType.addField(new Field("float", 0, DataType.FLOAT));
        docMan.register(docType);

        Document doc1 = new Document(docType, new DocumentId("id:ns:bug2354045::bug6394548"));
        doc1.setFieldValue("string", new StringFieldValue("hello world"));
        doc1.setFieldValue("int", new IntegerFieldValue(1234));
        doc1.setFieldValue("float", new FloatFieldValue(5.5f));
        String doc1Before = doc1.toXml();

        Document doc2 = new Document(docType, new DocumentId("id:ns:bug2354045::bug6394548"));
        doc2.setFieldValue("string", new StringFieldValue("aardvark"));
        doc2.setFieldValue("int", new IntegerFieldValue(90909));
        doc2.setFieldValue("float", new FloatFieldValue(777.15f));
        String doc2Before = doc2.toXml();

        doc1.compareTo(doc2);

        String doc1After = doc1.toXml();
        String doc2After = doc2.toXml();

        assertEquals(doc1Before, doc1After);
        assertEquals(doc2Before, doc2After);
    }
Test for Document and all its features, including (de)serialization.

@author Thomas Gundersen
@author bratseth
document/src/test/java/com/yahoo/document/DocumentTestCase.java