final IDataAccessSession session = filePersistence
.createDataAccessSession();
session.open();
BobContainer bobContainer = new BobContainer();
SubstitutedBob bob = new SubstitutedBob(1);
bob.setObject1(HELLO);
bobContainer.setObject1(bob);
session.setObject(KEY, bobContainer);
session.close(EnumFilePersistenceCloseAction.SAVE);
session.open();
bobContainer = (BobContainer) session.getObject(KEY);
assertNotNull(BAD_BOB_CONTAINER_OBJECT1, bobContainer.getObject1());
bob = (SubstitutedBob) bobContainer.getObject1();
assertEquals(BAD_BOB_IDENTIFIER, 1, bob.getIdentifier());
assertEquals(BAD_BOB_OBJECT, HELLO, bob.getObject1());
assertNull(BAD_BOB_CONTAINER_OBJECT2, bobContainer.getObject2());
if (!javaAgentTransformerInstalled()) {
assertFalse("must not be proxied",
ProxyManager2.isProxyOrEnhanced(bob));
}
bobContainer.setObject2("abracadaba");
session.close(EnumFilePersistenceCloseAction.SAVE);
session.open();
bobContainer = (BobContainer) session.getObject(KEY);
assertNotNull(BAD_BOB_CONTAINER_OBJECT1, bobContainer.getObject1());
bob = (SubstitutedBob) bobContainer.getObject1();
assertEquals(BAD_BOB_IDENTIFIER, 1, bob.getIdentifier());
assertEquals(BAD_BOB_OBJECT, HELLO, bob.getObject1());
assertNotNull(BAD_BOB_CONTAINER_OBJECT2, bobContainer.getObject2());
assertEquals(BAD_BOB_CONTAINER_OBJECT2, "abracadaba",
bobContainer.getObject2());
SubstitutedBob substitutedBob = new SubstitutedBob(2);
substitutedBob.setObject1(BONJOUR);
bobContainer.setObject2(substitutedBob);
session.close(EnumFilePersistenceCloseAction.SAVE);
session.open();
bobContainer = (BobContainer) session.getObject(KEY);
assertNotNull(BAD_BOB_CONTAINER_OBJECT1, bobContainer.getObject1());
bob = (SubstitutedBob) bobContainer.getObject1();
assertEquals(BAD_BOB_IDENTIFIER, 1, bob.getIdentifier());
assertEquals(BAD_BOB_OBJECT, HELLO, bob.getObject1());
assertNotNull(BAD_BOB_CONTAINER_OBJECT2, bobContainer.getObject2());
bob = (SubstitutedBob) bobContainer.getObject2();
assertEquals(BAD_BOB_IDENTIFIER, 2, bob.getIdentifier());
assertEquals(BAD_BOB_OBJECT, "bonjour", bob.getObject1());
substitutedBob = new SubstitutedBob(2);
substitutedBob.setObject1(BONJOUR);
bobContainer.setObject2(substitutedBob);
session.close(EnumFilePersistenceCloseAction.SAVE);
filePersistence.close();
}