@@ -0,0 +1,3274 @@
+package com.github.ferstl.spring.jdbc.oracle;%0A%0Aimport java.sql.SQLException;%0A%0Aimport oracle.jdbc.OraclePreparedStatement;%0A%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0Aimport org.springframework.jdbc.core.BatchPreparedStatementSetter;%0A%0Aimport com.github.ferstl.spring.jdbc.oracle.OracleJdbcTemplate.BatchingPreparedStatementCallback;%0A%0Aimport static org.junit.Assert.assertEquals;%0Aimport static org.mockito.Mockito.mock;%0Aimport static org.mockito.Mockito.times;%0Aimport static org.mockito.Mockito.verify;%0Aimport static org.mockito.Mockito.when;%0A%0A/**%0A * JUnit tests for %7B@link BatchingPreparedStatementCallback%7D.%0A */%0Apublic class BatchingPreparedStatementCallbackTest %7B%0A%0A  private OraclePreparedStatement ops;%0A%0A  @Before%0A  public void before() throws Exception %7B%0A    this.ops = OracleJdbcGuru.createOraclePS();%0A  %7D%0A%0A  @Test%0A  public void completeBatches() throws Exception %7B%0A    testDoInPreparedStatement(3, 6);%0A  %7D%0A%0A  @Test%0A  public void incompleteBatch() throws Exception %7B%0A    testDoInPreparedStatement(5, 2);%0A  %7D%0A%0A  @Test%0A  public void completeAndIncompleteBatches() throws Exception %7B%0A    testDoInPreparedStatement(3, 8);%0A  %7D%0A%0A  @Test%0A  public void emptyPreparedStatementSetter() throws Exception %7B%0A    testDoInPreparedStatement(3, 0);%0A  %7D%0A%0A  private void testDoInPreparedStatement(int sendBatchSize, int pssBatchSize) throws SQLException %7B%0A    BatchPreparedStatementSetter pss = mock(BatchPreparedStatementSetter.class);%0A    when(pss.getBatchSize()).thenReturn(pssBatchSize);%0A%0A    BatchingPreparedStatementCallback psc = new BatchingPreparedStatementCallback(sendBatchSize, pss);%0A%0A    int%5B%5D result = psc.doInPreparedStatement(this.ops);%0A%0A    verifyRowCounts(result, sendBatchSize, pssBatchSize);%0A    verifyPreparedStatementCalls(pssBatchSize, pss);%0A  %7D%0A%0A  private void verifyRowCounts(int%5B%5D result, int sendBatchSize, int pssBatchSize) %7B%0A    // Check the number of row counts%0A    assertEquals(%22Wrong number of executed statements%22, pssBatchSize, result.length);%0A%0A    // Check for correct execution of complete batches%0A    int sizeOfCompleteBatches = (pssBatchSize / sendBatchSize) * sendBatchSize;%0A    for (int i = 1; i %3C= sizeOfCompleteBatches; i++) %7B%0A      if (i %25 sendBatchSize != 0) %7B%0A        assertEquals(%22An unexpected update occurred in a complete batch. Position: %22 + (i - 1), 0, result%5Bi - 1%5D);%0A      %7D else %7B%0A        assertEquals(%22Wrong row count at the end of a complete batch%22, sendBatchSize, result%5Bi - 1%5D);%0A      %7D%0A    %7D%0A%0A    // Check for correct execution of a possibly last incomplete batch.%0A    int sizeOfLastBatch = pssBatchSize %25 sendBatchSize;%0A    if (sizeOfLastBatch != 0) %7B%0A      for (int i = sizeOfCompleteBatches + 1; i %3C sizeOfCompleteBatches + sizeOfLastBatch; i++) %7B%0A        if (i %25 sendBatchSize != 0) %7B%0A          assertEquals(%22An unexpected update occurred in the last batch. Position: %22 + (i - 1), 0, result%5Bi - 1%5D);%0A        %7D%0A      %7D%0A%0A      assertEquals(%22Wrong row count at the end of the last batch.%22, sizeOfLastBatch, result%5Bresult.length -1%5D);%0A    %7D%0A  %7D%0A%0A  private void verifyPreparedStatementCalls(int pssBatchSize, BatchPreparedStatementSetter pss) throws SQLException %7B%0A    for (int i = 0; i %3C pssBatchSize; i++) %7B%0A      verify(pss).setValues(this.ops, i);%0A      verify(this.ops, times(pssBatchSize)).executeUpdate();%0A    %7D%0A  %7D%0A%0A%7D%0A

Add test