public void testSerializeCommitted() throws Exception {

    Artist artist = (Artist) context.newObject("Artist");
    artist.setArtistName("artist1");
    assertNotNull(artist.getObjectId());
    context.commitChanges();

    DataContext deserializedContext = Util.cloneViaSerialization(context);

    assertSame(context.getParentDataDomain(), deserializedContext.getParentDataDomain());

    // there should be only one object registered
    Artist deserializedArtist =
        (Artist) deserializedContext.getObjectStore().getObjectIterator().next();

    assertNotNull(deserializedArtist);

    // deserialized as hollow...
    assertEquals(PersistenceState.HOLLOW, deserializedArtist.getPersistenceState());
    assertFalse(deserializedArtist.getObjectId().isTemporary());
    assertEquals("artist1", deserializedArtist.getArtistName());
    assertSame(deserializedContext, deserializedArtist.getObjectContext());

    // test that to-many relationships are initialized
    List<?> paintings = deserializedArtist.getPaintingArray();
    assertNotNull(paintings);
    assertEquals(0, paintings.size());
  }
  public void testSerializeNew() throws Exception {

    Artist artist = (Artist) context.newObject("Artist");
    artist.setArtistName("artist1");
    assertNotNull(artist.getObjectId());

    DataContext deserializedContext = Util.cloneViaSerialization(context);
    assertSame(context.getParentDataDomain(), deserializedContext.getParentDataDomain());

    // there should be only one object registered
    Artist deserializedArtist =
        (Artist) deserializedContext.getObjectStore().getObjectIterator().next();

    assertNotNull(deserializedArtist);
    assertEquals(PersistenceState.NEW, deserializedArtist.getPersistenceState());
    assertTrue(deserializedArtist.getObjectId().isTemporary());
    assertEquals("artist1", deserializedArtist.getArtistName());
    assertSame(deserializedContext, deserializedArtist.getObjectContext());
  }
  public void testSerializeModified() throws Exception {

    Artist artist = (Artist) context.newObject("Artist");
    artist.setArtistName("artist1");
    assertNotNull(artist.getObjectId());
    context.commitChanges();
    artist.setArtistName("artist2");

    DataContext deserializedContext = Util.cloneViaSerialization(context);

    assertSame(context.getParentDataDomain(), deserializedContext.getParentDataDomain());

    // there should be only one object registered
    Artist deserializedArtist =
        (Artist) deserializedContext.getObjectStore().getObjectIterator().next();

    assertNotNull(deserializedArtist);

    // deserialized as hollow...
    assertEquals(PersistenceState.MODIFIED, deserializedArtist.getPersistenceState());
    assertFalse(deserializedArtist.getObjectId().isTemporary());
    assertEquals("artist2", deserializedArtist.getArtistName());
    assertSame(deserializedContext, deserializedArtist.getObjectContext());
  }