Java serialization testing

Does anyone know if there is a library that exists to help check if the object graph is fully serialized? It probably would be as simple as writing it and reading it back, but I figured someone must have distracted it already - I just can't find it.

+3
source share
2 answers

Read this article .

and pay attention to the following highly reliable function:

public void testIsSerializable() 
   throws JaxenException, IOException {

    BaseXPath path = new BaseXPath("//foo", new DocumentNavigator());
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    ObjectOutputStream oos = new ObjectOutputStream(out);
    oos.writeObject(path);
    oos.close();
    assertTrue(out.toByteArray().length > 0);

}

The article also explains how to verify that objects are serialized correctly.

+2
source

It will probably be as simple as writing it down and reading it in

. . , .

+1

Source: https://habr.com/ru/post/1744972/


All Articles