};
altContext.setDelegate(delegate);
// make sure we have a fully resolved copy of an artist object
// in the second context
Artist altArtist = (Artist) altContext.getObjectStore().getNode(
artist.getObjectId());
assertNotNull(altArtist);
assertFalse(altArtist == artist);
assertEquals(artist.getArtistName(), altArtist.getArtistName());
assertEquals(PersistenceState.COMMITTED, altArtist.getPersistenceState());
// Update and save artist in peer context
context.deleteObject(artist);
context.commitChanges();
// assert that delegate was consulted when an object store
// was refreshed, and actually blocked object expulsion
ThreadedTestHelper helper = new ThreadedTestHelper() {
@Override
protected void assertResult() throws Exception {
assertTrue("Delegate was not consulted", methodInvoked[0]);
}
};
helper.assertWithTimeout(3000);
assertEquals(PersistenceState.COMMITTED, altArtist.getPersistenceState());
assertNotNull(altArtist.getObjectContext());
}