batchQuery.setUsingOptimisticLocking(true);
batchQuery.add(qualifierSnapshot);
DeleteBatchQueryBuilder batchQueryBuilder = new DeleteBatchQueryBuilder(adapter);
MockConnection mockConnection = new MockConnection();
PreparedStatementResultSetHandler preparedStatementResultSetHandler = mockConnection
.getPreparedStatementResultSetHandler();
preparedStatementResultSetHandler.setExactMatch(false);
preparedStatementResultSetHandler.setCaseSensitive(false);
preparedStatementResultSetHandler.prepareUpdateCount("DELETE", 0);
boolean generatesKeys = false;
BatchAction action = new BatchAction(batchQuery, adapter, resolver);
try {
action.runAsIndividualQueries(
mockConnection,
batchQueryBuilder,
new MockOperationObserver(),
generatesKeys);
fail("No OptimisticLockingFailureException thrown.");
}
catch (OptimisticLockException e) {
}
assertEquals(0, mockConnection.getNumberCommits());
assertEquals(0, mockConnection.getNumberRollbacks());
}