throws Exception
{
testCon.add(bob, name, nameBob);
testCon.add(alice, name, nameAlice);
Model model;
ModelResult statements = testCon.match(null, null, null, true);
try {
model = new LinkedHashModel(statements.asList());
}
finally {
statements.close();
}
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream(baos);
out.writeObject(model);
out.close();
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
ObjectInputStream in = new ObjectInputStream(bais);
Model deserializedGraph = (Model)in.readObject();
in.close();
assertFalse(deserializedGraph.isEmpty());
for (Statement st : deserializedGraph) {
assertTrue(model.contains(st));
assertTrue(testCon.hasStatement(st, true));
}