@@ -192,7 +192,7 @@ private void doTestStrings(Integer fetchSize, Integer maxRows, Integer queryTime
192192 Object argument , JdbcTemplateCallback jdbcTemplateCallback ) throws Exception {
193193
194194 String sql = "SELECT FORENAME FROM CUSTMR" ;
195- String [] results = { "rod" , "gary" , " portia" };
195+ String [] results = {"rod" , "gary" , " portia" };
196196
197197 class StringHandler implements RowCallbackHandler {
198198 private List <String > list = new LinkedList <>();
@@ -491,8 +491,8 @@ public void testBatchUpdateWithNoBatchSupportAndSelect() throws Exception {
491491 @ Test
492492 public void testBatchUpdateWithPreparedStatement () throws Exception {
493493 final String sql = "UPDATE NOSUCHTABLE SET DATE_DISPATCHED = SYSDATE WHERE ID = ?" ;
494- final int [] ids = new int [] { 100 , 200 };
495- final int [] rowsAffected = new int [] { 1 , 2 };
494+ final int [] ids = new int [] {100 , 200 };
495+ final int [] rowsAffected = new int [] {1 , 2 };
496496
497497 given (this .preparedStatement .executeBatch ()).willReturn (rowsAffected );
498498 mockDatabaseMetaData (true );
@@ -525,8 +525,8 @@ public int getBatchSize() {
525525 @ Test
526526 public void testInterruptibleBatchUpdate () throws Exception {
527527 final String sql = "UPDATE NOSUCHTABLE SET DATE_DISPATCHED = SYSDATE WHERE ID = ?" ;
528- final int [] ids = new int [] { 100 , 200 };
529- final int [] rowsAffected = new int [] { 1 , 2 };
528+ final int [] ids = new int [] {100 , 200 };
529+ final int [] rowsAffected = new int [] {1 , 2 };
530530
531531 given (this .preparedStatement .executeBatch ()).willReturn (rowsAffected );
532532 mockDatabaseMetaData (true );
@@ -566,8 +566,8 @@ public boolean isBatchExhausted(int i) {
566566 @ Test
567567 public void testInterruptibleBatchUpdateWithBaseClass () throws Exception {
568568 final String sql = "UPDATE NOSUCHTABLE SET DATE_DISPATCHED = SYSDATE WHERE ID = ?" ;
569- final int [] ids = new int [] { 100 , 200 };
570- final int [] rowsAffected = new int [] { 1 , 2 };
569+ final int [] ids = new int [] {100 , 200 };
570+ final int [] rowsAffected = new int [] {1 , 2 };
571571
572572 given (this .preparedStatement .executeBatch ()).willReturn (rowsAffected );
573573 mockDatabaseMetaData (true );
@@ -603,8 +603,8 @@ protected boolean setValuesIfAvailable(PreparedStatement ps, int i) throws SQLEx
603603 @ Test
604604 public void testInterruptibleBatchUpdateWithBaseClassAndNoBatchSupport () throws Exception {
605605 final String sql = "UPDATE NOSUCHTABLE SET DATE_DISPATCHED = SYSDATE WHERE ID = ?" ;
606- final int [] ids = new int [] { 100 , 200 };
607- final int [] rowsAffected = new int [] { 1 , 2 };
606+ final int [] ids = new int [] {100 , 200 };
607+ final int [] rowsAffected = new int [] {1 , 2 };
608608
609609 given (this .preparedStatement .executeUpdate ()).willReturn (rowsAffected [0 ], rowsAffected [1 ]);
610610 mockDatabaseMetaData (false );
@@ -640,8 +640,8 @@ protected boolean setValuesIfAvailable(PreparedStatement ps, int i) throws SQLEx
640640 @ Test
641641 public void testBatchUpdateWithPreparedStatementAndNoBatchSupport () throws Exception {
642642 final String sql = "UPDATE NOSUCHTABLE SET DATE_DISPATCHED = SYSDATE WHERE ID = ?" ;
643- final int [] ids = new int [] { 100 , 200 };
644- final int [] rowsAffected = new int [] { 1 , 2 };
643+ final int [] ids = new int [] {100 , 200 };
644+ final int [] rowsAffected = new int [] {1 , 2 };
645645
646646 given (this .preparedStatement .executeUpdate ()).willReturn (rowsAffected [0 ], rowsAffected [1 ]);
647647
@@ -671,7 +671,7 @@ public int getBatchSize() {
671671 @ Test
672672 public void testBatchUpdateFails () throws Exception {
673673 final String sql = "UPDATE NOSUCHTABLE SET DATE_DISPATCHED = SYSDATE WHERE ID = ?" ;
674- final int [] ids = new int [] { 100 , 200 };
674+ final int [] ids = new int [] {100 , 200 };
675675 SQLException sqlException = new SQLException ();
676676
677677 given (this .preparedStatement .executeBatch ()).willThrow (sqlException );
@@ -702,6 +702,15 @@ public int getBatchSize() {
702702 }
703703 }
704704
705+ @ Test
706+ public void testBatchUpdateWithEmptyList () throws Exception {
707+ final String sql = "UPDATE NOSUCHTABLE SET DATE_DISPATCHED = SYSDATE WHERE ID = ?" ;
708+ JdbcTemplate template = new JdbcTemplate (this .dataSource , false );
709+
710+ int [] actualRowsAffected = template .batchUpdate (sql , Collections .emptyList ());
711+ assertTrue ("executed 0 updates" , actualRowsAffected .length == 0 );
712+ }
713+
705714 @ Test
706715 public void testBatchUpdateWithListOfObjectArrays () throws Exception {
707716 final String sql = "UPDATE NOSUCHTABLE SET DATE_DISPATCHED = SYSDATE WHERE ID = ?" ;
@@ -712,11 +721,9 @@ public void testBatchUpdateWithListOfObjectArrays() throws Exception {
712721
713722 given (this .preparedStatement .executeBatch ()).willReturn (rowsAffected );
714723 mockDatabaseMetaData (true );
715-
716724 JdbcTemplate template = new JdbcTemplate (this .dataSource , false );
717725
718726 int [] actualRowsAffected = template .batchUpdate (sql , ids );
719-
720727 assertTrue ("executed 2 updates" , actualRowsAffected .length == 2 );
721728 assertEquals (rowsAffected [0 ], actualRowsAffected [0 ]);
722729 assertEquals (rowsAffected [1 ], actualRowsAffected [1 ]);
@@ -739,10 +746,9 @@ public void testBatchUpdateWithListOfObjectArraysPlusTypeInfo() throws Exception
739746
740747 given (this .preparedStatement .executeBatch ()).willReturn (rowsAffected );
741748 mockDatabaseMetaData (true );
742-
743749 this .template = new JdbcTemplate (this .dataSource , false );
744- int [] actualRowsAffected = this .template .batchUpdate (sql , ids , sqlTypes );
745750
751+ int [] actualRowsAffected = this .template .batchUpdate (sql , ids , sqlTypes );
746752 assertTrue ("executed 2 updates" , actualRowsAffected .length == 2 );
747753 assertEquals (rowsAffected [0 ], actualRowsAffected [0 ]);
748754 assertEquals (rowsAffected [1 ], actualRowsAffected [1 ]);
@@ -757,8 +763,8 @@ public void testBatchUpdateWithListOfObjectArraysPlusTypeInfo() throws Exception
757763 public void testBatchUpdateWithCollectionOfObjects () throws Exception {
758764 final String sql = "UPDATE NOSUCHTABLE SET DATE_DISPATCHED = SYSDATE WHERE ID = ?" ;
759765 final List <Integer > ids = Arrays .asList (100 , 200 , 300 );
760- final int [] rowsAffected1 = new int [] { 1 , 2 };
761- final int [] rowsAffected2 = new int [] { 3 };
766+ final int [] rowsAffected1 = new int [] {1 , 2 };
767+ final int [] rowsAffected2 = new int [] {3 };
762768
763769 given (this .preparedStatement .executeBatch ()).willReturn (rowsAffected1 , rowsAffected2 );
764770 mockDatabaseMetaData (true );
@@ -781,50 +787,52 @@ public void testBatchUpdateWithCollectionOfObjects() throws Exception {
781787 }
782788
783789 @ Test
784- public void testCouldntGetConnectionForOperationOrExceptionTranslator () throws SQLException {
790+ public void testCouldNotGetConnectionForOperationOrExceptionTranslator () throws SQLException {
785791 SQLException sqlException = new SQLException ("foo" , "07xxx" );
786792 this .dataSource = mock (DataSource .class );
787793 given (this .dataSource .getConnection ()).willThrow (sqlException );
788794 JdbcTemplate template = new JdbcTemplate (this .dataSource , false );
789795 RowCountCallbackHandler rcch = new RowCountCallbackHandler ();
796+
790797 this .thrown .expect (CannotGetJdbcConnectionException .class );
791798 this .thrown .expect (exceptionCause (sameInstance (sqlException )));
792799 template .query ("SELECT ID, FORENAME FROM CUSTMR WHERE ID < 3" , rcch );
793800 }
794801
795802 @ Test
796- public void testCouldntGetConnectionForOperationWithLazyExceptionTranslator () throws SQLException {
803+ public void testCouldNotGetConnectionForOperationWithLazyExceptionTranslator () throws SQLException {
797804 SQLException sqlException = new SQLException ("foo" , "07xxx" );
798805 this .dataSource = mock (DataSource .class );
799806 given (this .dataSource .getConnection ()).willThrow (sqlException );
800807 this .template = new JdbcTemplate ();
801808 this .template .setDataSource (this .dataSource );
802809 this .template .afterPropertiesSet ();
803810 RowCountCallbackHandler rcch = new RowCountCallbackHandler ();
811+
804812 this .thrown .expect (CannotGetJdbcConnectionException .class );
805813 this .thrown .expect (exceptionCause (sameInstance (sqlException )));
806814 this .template .query ("SELECT ID, FORENAME FROM CUSTMR WHERE ID < 3" , rcch );
807815 }
808816
809817 @ Test
810- public void testCouldntGetConnectionInOperationWithExceptionTranslatorInitializedViaBeanProperty ()
818+ public void testCouldNotGetConnectionInOperationWithExceptionTranslatorInitializedViaBeanProperty ()
811819 throws SQLException {
812820
813- doTestCouldntGetConnectionInOperationWithExceptionTranslatorInitialized (true );
821+ doTestCouldNotGetConnectionInOperationWithExceptionTranslatorInitialized (true );
814822 }
815823
816824 @ Test
817- public void testCouldntGetConnectionInOperationWithExceptionTranslatorInitializedInAfterPropertiesSet ()
825+ public void testCouldNotGetConnectionInOperationWithExceptionTranslatorInitializedInAfterPropertiesSet ()
818826 throws SQLException {
819827
820- doTestCouldntGetConnectionInOperationWithExceptionTranslatorInitialized (false );
828+ doTestCouldNotGetConnectionInOperationWithExceptionTranslatorInitialized (false );
821829 }
822830
823831 /**
824832 * If beanProperty is true, initialize via exception translator bean property;
825833 * if false, use afterPropertiesSet().
826834 */
827- private void doTestCouldntGetConnectionInOperationWithExceptionTranslatorInitialized (boolean beanProperty )
835+ private void doTestCouldNotGetConnectionInOperationWithExceptionTranslatorInitialized (boolean beanProperty )
828836 throws SQLException {
829837
830838 SQLException sqlException = new SQLException ("foo" , "07xxx" );
@@ -884,7 +892,7 @@ public void testPreparedStatementSetterFails() throws Exception {
884892 }
885893
886894 @ Test
887- public void testCouldntClose () throws Exception {
895+ public void testCouldNotClose () throws Exception {
888896 SQLException sqlException = new SQLException ("bar" );
889897 given (this .connection .createStatement ()).willReturn (this .statement );
890898 given (this .resultSet .next ()).willReturn (false );
0 commit comments