throw new RuntimeException(e);
}
for (int t = 0; t < COMMAND_PER_THREAD_COUNT; t++) {
commandBus.dispatch(asCommandMessage(new ProblematicCommand(aggregateId)),
SilentCallback.INSTANCE);
commandBus.dispatch(asCommandMessage(new UpdateStubAggregateCommand(aggregateId)),
new VoidCallback() {
@Override
protected void onSuccess() {
successCounter.incrementAndGet();
}
@Override
public void onFailure(Throwable cause) {
failCounter.incrementAndGet();
}
});
}
cdl.countDown();
}
});
thread.setUncaughtExceptionHandler(ConcurrentModificationTest_OptimisticLocking.this);
thread.start();
}
starter.countDown();
cdl.await((THREAD_COUNT * COMMAND_PER_THREAD_COUNT) / 4, TimeUnit.SECONDS);
if (uncaughtExceptions.size() > 0) {
System.out.println("*** Uncaught Exceptions ***");
for (Throwable uncaught : uncaughtExceptions) {
uncaught.printStackTrace();
}
}
assertEquals("Got exceptions", 0, uncaughtExceptions.size());
assertEquals(successCounter.get() + 1, registeringEventHandler.getCapturedEvents().size());
assertEquals(THREAD_COUNT * COMMAND_PER_THREAD_COUNT, successCounter.get(), failCounter.get());
reportOutOfSyncEvents();
logger.info("Results: {} successful, {} failed.", successCounter.get(), failCounter.get());
// to prove that all locks are properly cleared, this command must succeed.
commandBus.dispatch(asCommandMessage(new UpdateStubAggregateCommand(aggregateId)), new VoidCallback() {
@Override
protected void onSuccess() {
}