testStatement(connectionSource, databaseType, sb.toString(), null, rowN, throwExecute, callable);
}
private void testStatement(ConnectionSource connectionSource, DatabaseType databaseType, String statement,
String queryAfter, int rowN, boolean throwExecute, Callable<Integer> callable) throws Exception {
DatabaseConnection conn = createMock(DatabaseConnection.class);
CompiledStatement stmt = createMock(CompiledStatement.class);
DatabaseResults results = null;
final AtomicInteger rowC = new AtomicInteger(1);
if (throwExecute) {
expect(conn.compileStatement(isA(String.class), isA(StatementType.class), isA(FieldType[].class))).andThrow(
new SQLException("you asked us to!!"));
} else {
expect(conn.compileStatement(isA(String.class), isA(StatementType.class), isA(FieldType[].class))).andReturn(
stmt);
expect(stmt.runUpdate()).andReturn(rowN);
stmt.close();
if (queryAfter != null) {
expect(conn.compileStatement(isA(String.class), isA(StatementType.class), isA(FieldType[].class))).andReturn(
stmt);
results = createMock(DatabaseResults.class);
expect(results.next()).andReturn(false);
expect(stmt.runQuery()).andReturn(results);
stmt.close();