testFileDir.mkdirs();
File testFile = new File(testFileDir,SimpleAddTest.class.getSimpleName()+(_testCounter++)+".jdb");
testFile.delete();
JODBSessionContainer sessionContainer = getContainerForFile(testFile);
ObjectB objectB = new ObjectB();
ObjectA objectA = new ObjectA((byte)1,(short)2,objectB);
objectB._val3 = objectA;
sessionContainer.set(objectA);
sessionContainer.commit();
sessionContainer.close();
sessionContainer = getContainerForFile(testFile);
sessionContainer.printFileMap();
List classes = sessionContainer.getAllObjects();
if(classes.size()!=2){
throw new RuntimeException(""+classes.size());
}
int index = classes.indexOf(objectA);
if(index == -1){
throw new RuntimeException();
}
Object obj = classes.get(index);
if(obj.getClass() != objectA.getClass()){
throw new RuntimeException();
}
ObjectA objA = (ObjectA) obj;
if(objA.getVal1() != objectA.getVal1() || objA.getVal2() != objectA.getVal2()){
throw new RuntimeException();
}
if(objA.getVal3().getClass() != objectB.getClass()){
throw new RuntimeException();
}
int bIndex = classes.indexOf(objectB);
if(bIndex == -1){
throw new RuntimeException();
}
ObjectB objectB2 = (ObjectB) classes.get(bIndex);
if(objectB2._val3 != objA){
throw new RuntimeException();
}
objectB2 = new ObjectB();
objA.setVal3(objectB2);
sessionContainer.set(objA);
sessionContainer.commit();