}
}
private void execute() {
//test concurrent loading in the same transaction
BasicA ba = ((BasicA) pm.getObjectById(oids[NB_OBJECT-1], false));
ba.readF1_F2();
ba = ((BasicA) pm.getObjectById(oids[threadId], false));
ba.writeF1(ba.readF1() + "modifiedBy" + threadId);
for(int j=0; j<NB_MODIF; j++) {
// Choose an object: alternativly on each side
// of the threadId
int id = j;
if (j % 2 == 0) {
id = Math.min(NB_OBJECT-1, threadId + j);
} else {
id = Math.max(0, threadId - j);
}
ba = ((BasicA) pm.getObjectById(oids[id], false));
s[id].P();
try {
ba.writeF1(ba.readF1() + "modifiedBy" + threadId);
} finally {
s[id].V();
}
}
for(int j=0; j<NB_QUERY; j++) {
final int min = Math.max(0, threadId - (INTERVAL/2));
final int max = Math.min(NB_OBJECT-1, threadId + (INTERVAL/2));
Query q = pm.newQuery(BasicA.class);
q.declareParameters("int pmin, int pmax");
q.setFilter("(f2 >= pmin) && (f2 <= pmax)");
Collection c = (Collection) q.execute(
new Integer(min), new Integer(max));
Collection expected = new ArrayList();
for(int id=min; id<=max; id++) {
expected.add(new Integer(id));
}
st.getLogger().log(BasicLevel.DEBUG, "Thread " + threadId + " expect: " + expected);
Collection found = new ArrayList();
for (Iterator iter = c.iterator(); iter.hasNext();) {
ba = (BasicA) iter.next();
int f2 = ba.readF2();
found.add(new Integer(f2));
}
q.closeAll();
st.getLogger().log(BasicLevel.DEBUG, "Thread " + threadId + " found: " + found);
st.assertSameCollection("Bad query result"