File testFileDir = new File(TEST_DATA_DIR);
testFileDir.mkdirs();
File testFile = new File(testFileDir,SimpleAddTest.class.getSimpleName()+(_testCounter++)+".jdb");
testFile.delete();
JODBSessionContainer sessionContainer = getContainerForFile(testFile);
ObjectWithString objectA1 = new ObjectWithString();
objectA1._val1 = "a";
ObjectWithString objectA2 = new ObjectWithString();
objectA2._val1 = "c";
ObjectWithString objectA3 = new ObjectWithString();
objectA3._val1 = "b";
sessionContainer.set(objectA1);
sessionContainer.set(objectA2);
sessionContainer.set(objectA3);
sessionContainer.commit();
if(reopen){
sessionContainer.close();
sessionContainer = getContainerForFile(testFile);
}
Query query = sessionContainer.query();
if(ascending){
query.descend("_val0").orderAscending();
}else{
query.descend("_val0").orderDescending();
}
if(ascending){
query.descend("_val1").orderAscending();
}else{
query.descend("_val1").orderDescending();
}
JODBConfig.setCacheOnSortOperations(false);
List list = query.execute();
ObjectWithString prev = null;
if(list.size() == 0){
throw new RuntimeException();
}
for (int i = 0; i < list.size(); i++) {
ObjectWithString current = (ObjectWithString) list.get(i);
if(prev!=null){
if(ascending){
if( prev._val1.charAt(0) > current._val1.charAt(0) ){
throw new RuntimeException();
}
}else if(prev._val1.charAt(0) < current._val1.charAt(0) ){
throw new RuntimeException();
}
}
prev = current;
}
if(reopen){
sessionContainer.close();
sessionContainer = getContainerForFile(testFile);
query = sessionContainer.query();
if(ascending){
query.descend("_val1").orderAscending();
}else{
query.descend("_val1").orderDescending();
}
}
JODBConfig.setCacheOnSortOperations(true);
list = query.execute();
if(list.size() == 0){
throw new RuntimeException();
}
prev = null;
for (int i = 0; i < list.size(); i++) {
ObjectWithString current = (ObjectWithString) list.get(i);
if(prev!=null){
if(ascending){
if( prev._val1.charAt(0) > current._val1.charAt(0) ){
throw new RuntimeException();
}