public void testConcurrentAdd() throws Exception {
// create workers
List<Callable<String>> cs = new LinkedList<Callable<String>>();
for (int i = 0; i < NB_THREADS; i++) {
// each callable has its own microkernel
final MicroKernel mk = createMicroKernel();
// diff for adding one node and one child node
final List<String> stmts = new LinkedList<String>();
stmts.add("+\"node" + i + "\":{}");
stmts.add("+\"node" + i + "/child\":{}");
// create callable
Callable<String> c = new Callable<String>() {
@Override
public String call() throws Exception {
// commit all statements, one at a time
String r = null;
for (String stmt : stmts) {
r = mk.commit("/", stmt, null, "msg");
}
return r;
}
};
cs.add(c);