Skip to content

Commit

Permalink
Fixed update count tests (#2033)
Browse files Browse the repository at this point in the history
  • Loading branch information
tkyc authored Jan 3, 2023
1 parent 5be07c7 commit f653891
Showing 1 changed file with 3 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public class BatchExecutionTest extends AbstractTest {
@Test
public void testBatchUpdateCountFalseOnFirstPstmtPrepexec() throws Exception {
long[] expectedUpdateCount = {1, 1, 1, 1, -3, -3, -3, -3, -3, -3};
testBatchUpdateCountWith(10, 6, false, "prepexec", expectedUpdateCount);
testBatchUpdateCountWith(10, 6, false, expectedUpdateCount);
}

/**
Expand All @@ -74,29 +74,7 @@ public void testBatchUpdateCountFalseOnFirstPstmtPrepexec() throws Exception {
@Test
public void testBatchUpdateCountTrueOnFirstPstmtPrepexec() throws Exception {
long[] expectedUpdateCount = {1, 1, -3, -3, -3};
testBatchUpdateCountWith(5, 4, true, "prepexec", expectedUpdateCount);
}

/**
* This tests the updateCount when the error query does cause a SQL state HY008.
*
* @throws Exception
*/
@Test
public void testBatchUpdateCountFalseOnFirstPstmtSpPrepare() throws Exception {
long[] expectedUpdateCount = {1, 1, 1, 1, -3, -3, -3, -3, -3, -3};
testBatchUpdateCountWith(10, 6, false, "prepare", expectedUpdateCount);
}

/**
* This tests the updateCount when the error query does cause a SQL state HY008.
*
* @throws Exception
*/
@Test
public void testBatchUpdateCountTrueOnFirstPstmtSpPrepare() throws Exception {
long[] expectedUpdateCount = {1, 1, -3, -3, -3};
testBatchUpdateCountWith(5, 4, true, "prepare", expectedUpdateCount);
testBatchUpdateCountWith(5, 4, true, expectedUpdateCount);
}

/**
Expand Down Expand Up @@ -214,11 +192,9 @@ public void testExecuteBatch1UseBulkCopyAPI() {
}

private void testBatchUpdateCountWith(int numOfInserts, int errorQueryIndex,
boolean prepareOnFirstPreparedStatement, String prepareMethod,
long[] expectedUpdateCount) throws Exception {
boolean prepareOnFirstPreparedStatement, long[] expectedUpdateCount) throws Exception {
try (SQLServerConnection connection = PrepUtil.getConnection(connectionString)) {
connection.setEnablePrepareOnFirstPreparedStatementCall(prepareOnFirstPreparedStatement);
connection.setPrepareMethod(prepareMethod);
try (CallableStatement cstmt = connection.prepareCall(
AbstractSQLGenerator.escapeIdentifier(ctstable3Procedure1) + " @duration=?, @value=?")) {
cstmt.setQueryTimeout(7);
Expand Down

0 comments on commit f653891

Please sign in to comment.