}
public void testLocalObjectSynchronize() throws Exception {
final ObjectContext child = clientContext.createChildContext();
final ClientMtTable1 committed = clientContext.newObject(ClientMtTable1.class);
final ClientMtTable1 deleted = clientContext.newObject(ClientMtTable1.class);
final ClientMtTable1 modified = clientContext.newObject(ClientMtTable1.class);
clientContext.commitChanges();
clientContext.deleteObjects(deleted);
modified.setGlobalAttribute1("a");
final ClientMtTable1 _new = clientContext.newObject(ClientMtTable1.class);
final ClientMtTable1 hollow = (ClientMtTable1) clientContext.localObject(new ObjectId(
"MtTable1"), null);
assertEquals(PersistenceState.HOLLOW, hollow.getPersistenceState());
assertEquals(PersistenceState.COMMITTED, committed.getPersistenceState());
assertEquals(PersistenceState.MODIFIED, modified.getPersistenceState());
assertEquals(PersistenceState.DELETED, deleted.getPersistenceState());
assertEquals(PersistenceState.NEW, _new.getPersistenceState());
queryInterceptor.runWithQueriesBlocked(new UnitTestClosure() {
public void execute() {
Persistent newPeer = child.localObject(_new.getObjectId(), _new);
assertEquals(_new.getObjectId(), newPeer.getObjectId());
assertEquals(PersistenceState.COMMITTED, newPeer.getPersistenceState());
assertSame(child, newPeer.getObjectContext());
assertSame(clientContext, _new.getObjectContext());
Persistent hollowPeer = child.localObject(hollow.getObjectId(), hollow);
assertEquals(PersistenceState.HOLLOW, hollowPeer.getPersistenceState());
assertEquals(hollow.getObjectId(), hollowPeer.getObjectId());
assertSame(child, hollowPeer.getObjectContext());
assertSame(clientContext, hollow.getObjectContext());
Persistent committedPeer = child.localObject(
committed.getObjectId(),
committed);
assertEquals(PersistenceState.COMMITTED, committedPeer
.getPersistenceState());
assertEquals(committed.getObjectId(), committedPeer.getObjectId());
assertSame(child, committedPeer.getObjectContext());
assertSame(clientContext, committed.getObjectContext());
ClientMtTable1 modifiedPeer = (ClientMtTable1) child.localObject(modified
.getObjectId(), modified);
assertEquals(PersistenceState.COMMITTED, modifiedPeer
.getPersistenceState());
assertEquals(modified.getObjectId(), modifiedPeer.getObjectId());
assertEquals("a", modifiedPeer.getGlobalAttribute1());
assertSame(child, modifiedPeer.getObjectContext());
assertSame(clientContext, modified.getObjectContext());
Persistent deletedPeer = child
.localObject(deleted.getObjectId(), deleted);
assertEquals(PersistenceState.COMMITTED, deletedPeer