factory.intersectionInit(null, Integer.MAX_VALUE, false);
sessionContainer = getContainerForFile(testFile);
//factory.setIntersectEnabled(true);
ObjectA objectA = new ObjectA((byte)1,(short)2,null);
ObjectB objectB = new ObjectB();
int[] array = new int[]{10,20,30};
sessionContainer.set(objectB);
//sessionContainer.set(array);
sessionContainer.set(objectA);
sessionContainer.close();
sessionContainer = getContainerForFile(testFile);
factory.setIntersectEnabled(true);
sessionContainer.set(array);
sessionContainer.close();
Vector verificationObjects = new Vector();
verificationObjects.add(objectA);
verificationObjects.add(objectB);
int maxOperationsCount = factory.getCounter();
testFile = new File(testFileDir,SimpleAddTest.class.getSimpleName()+(_testCounter++)+".jdb");
for (int i = 0; i < maxOperationsCount; i++) {
System.err.println("Iteration ="+i);
//System.gc();
// try {
// Thread.sleep(200);
// } catch (InterruptedException e1) {
// }
factory.intersectionInit(null, i, true);
testFile.delete();
if(testFile.exists()){
throw new RuntimeException();
}
sessionContainer = getContainerForFile(testFile);
sessionContainer.set(objectB);
sessionContainer.set(objectA);
sessionContainer.close();
// testFile.delete();
// if(testFile.exists()){
// System.err.println();
// }
factory.setIntersectEnabled(true);
sessionContainer = getContainerForFile(testFile);
sessionContainer.set(array);
try {
sessionContainer.close();
throw new RuntimeException("Test Framework Error");
} catch (Exception e) {
// if(i==25){
// factory.printUnclosedBuffers();
// }
e.printStackTrace();
}
// testFile.delete();
// if(testFile.exists()){
// System.err.println();
// }
factory.setIntersectEnabled(false);
if (factory._bufferedType == BUFFER_TYPE.MAIN) {
byte[] incompleteTransaction = factory.getBuffer();
verifyDataReadable(incompleteTransaction, verificationObjects,2,3);
}
sessionContainer = getContainerForFile(testFile);
List classes = sessionContainer.getAllObjects();
if(classes.size()!=2){
throw new RuntimeException(""+classes.size()+" "+i);
}
// Object arrayObj = null;
// for (int j = 0; j < classes.size(); j++) {
// if(classes.get(j).getClass().isArray()){
// arrayObj = classes.get(j);
// }
// }
// int[] array1 = (int[]) arrayObj;
//
// if(!Arrays.equals(array, array1)){
// throw new RuntimeException();
// }
int index = classes.indexOf(objectA);
if(index == -1){
throw new RuntimeException();
}
ObjectA objectA2 = (ObjectA) classes.get(index);
index = classes.indexOf(objectB);
if(index == -1){
throw new RuntimeException();
}
ObjectB objectB2 = (ObjectB) classes.get(index);
sessionContainer.close();
}
}