File testFileDir = new File(_testPath+"/testData/");
testFileDir.mkdirs();
File testFile = new File(testFileDir,SimpleAddTest.class.getSimpleName()+(_testCounter++)+".jdb");
testFile.delete();
JODBSessionContainer sessionContainer = getContainerForFile(testFile);
ObjectWithPrimitiveWrappers initialObject = new ObjectWithPrimitiveWrappers();
initialObject._boolean = true;
initialObject._byte = Byte.MAX_VALUE;
initialObject._character = Character.MAX_VALUE;
initialObject._double = Double.MAX_VALUE;
initialObject._float = Float.MAX_VALUE;
initialObject._integer = Integer.MAX_VALUE;
initialObject._long = Long.MAX_VALUE;
initialObject._short = Short.MAX_VALUE;
sessionContainer.set(initialObject);
sessionContainer.commit();
if (reopen) {
sessionContainer.close();
sessionContainer = getContainerForFile(testFile);
}
// List classes = sessionContainer.getAllObjects();
Query query = sessionContainer.query();
query.constrain(initialObject.getClass());
List classes = query.execute();
if (classes.size() != 1) {
throw new RuntimeException();
}
Object obj = classes.get(0);
if(obj.getClass() != initialObject.getClass()){
throw new RuntimeException();
}
ObjectWithPrimitiveWrappers persistedObject = (ObjectWithPrimitiveWrappers) obj;
if(!initialObject._boolean.equals(persistedObject._boolean)){
throw new RuntimeException();
}
if(!initialObject._byte.equals(persistedObject._byte)){
throw new RuntimeException();
}
if(!initialObject._character.equals(persistedObject._character)){
throw new RuntimeException();
}
if(!initialObject._double.equals(persistedObject._double)){
throw new RuntimeException();
}
if(!initialObject._float.equals(persistedObject._float)){
throw new RuntimeException();
}
if(!initialObject._integer.equals(persistedObject._integer)){
throw new RuntimeException();
}
if(!initialObject._long.equals(persistedObject._long)){
throw new RuntimeException();
}
if(!initialObject._short.equals(persistedObject._short)){
throw new RuntimeException();
}
sessionContainer.close();
}