}
writeRequests.addWrite(testTime + key + i, testData[i]);
readRequests.addRead(testTime + key + i);
}
ResultList results = conn.req_list(firstWriteRequests);
// evaluate the first write results:
for (int i = 0; i < firstWriteRequests.size(); ++i) {
results.processWriteAt(i);
}
final RequestList requests = new RequestList(readRequests);
requests.addAll(writeRequests).addCommit();
results = conn.req_list(requests);
assertEquals(requests.size(), results.size());
// now evaluate the read results:
for (int i = 0; i < readRequests.size(); ++i) {
if ((i % 2) == 0) {
final String actual = results.processReadAt(i).stringValue();
assertEquals(testData[i], actual);
} else {
try {
results.processReadAt(i);
// a not found exception must be thrown
assertTrue(false);
} catch (final NotFoundException e) {
}
}
}
// now evaluate the write results:
for (int i = 0; i < writeRequests.size(); ++i) {
final int pos = readRequests.size() + i;
results.processWriteAt(pos);
}
// once again test reads - now all reads should be successful
results = conn.req_list(readRequests);
assertEquals(readRequests.size(), results.size());
// now evaluate the read results:
for (int i = 0; i < readRequests.size(); ++i) {
final String actual = results.processReadAt(i).stringValue();
assertEquals(testData[i], actual);
}
} finally {
conn.closeConnection();
}