Painting py = context.newObject(Painting.class);
py.setPaintingTitle("PY");
context.commitChanges();
ObjectContext peer1 = context.createChildContext();
Painting py1 = (Painting) peer1.localObject(py.getObjectId(), py);
Artist a1 = (Artist) peer1.localObject(a.getObjectId(), a);
ObjectContext peer2 = context.createChildContext();
Painting py2 = (Painting) peer2.localObject(py.getObjectId(), py);
Artist a2 = (Artist) peer2.localObject(a.getObjectId(), a);
a1.addToPaintingArray(py1);
assertEquals(1, a2.getPaintingArray().size());
assertFalse(a2.getPaintingArray().contains(py2));
peer1.commitChangesToParent();
assertEquals(2, a2.getPaintingArray().size());
assertTrue(a2.getPaintingArray().contains(py2));
assertFalse("Peer data context became dirty on event processing", peer2
.hasChanges());
}