@@ -125,6 +125,7 @@ private void doTestTransactionCommitRestoringAutoCommit(
125
125
if (lazyConnection ) {
126
126
given (con .getAutoCommit ()).willReturn (autoCommit );
127
127
given (con .getTransactionIsolation ()).willReturn (Connection .TRANSACTION_READ_COMMITTED );
128
+ given (con .getWarnings ()).willThrow (new SQLException ());
128
129
}
129
130
130
131
if (!lazyConnection || createStatement ) {
@@ -152,6 +153,10 @@ protected void doInTransactionWithoutResult(TransactionStatus status) throws Run
152
153
if (createStatement ) {
153
154
tCon .createStatement ();
154
155
}
156
+ else {
157
+ tCon .getWarnings ();
158
+ tCon .clearWarnings ();
159
+ }
155
160
}
156
161
catch (SQLException ex ) {
157
162
throw new UncategorizedSQLException ("" , "" , ex );
@@ -703,7 +708,6 @@ public void testPropagationRequiresNewWithExistingTransactionAndUnrelatedFailing
703
708
SQLException failure = new SQLException ();
704
709
given (ds2 .getConnection ()).willThrow (failure );
705
710
706
-
707
711
final TransactionTemplate tt = new TransactionTemplate (tm );
708
712
tt .setPropagationBehavior (TransactionDefinition .PROPAGATION_REQUIRES_NEW );
709
713
@@ -1024,12 +1028,12 @@ protected void doInTransactionWithoutResult(TransactionStatus status) {
1024
1028
ordered .verify (con ).setAutoCommit (false );
1025
1029
ordered .verify (con ).setAutoCommit (true );
1026
1030
verify (con ).close ();
1027
-
1028
1031
}
1029
1032
1030
1033
@ Test
1031
1034
public void testTransactionAwareDataSourceProxy () throws Exception {
1032
1035
given (con .getAutoCommit ()).willReturn (true );
1036
+ given (con .getWarnings ()).willThrow (new SQLException ());
1033
1037
1034
1038
TransactionTemplate tt = new TransactionTemplate (tm );
1035
1039
boolean condition1 = !TransactionSynchronizationManager .hasResource (ds );
@@ -1041,6 +1045,9 @@ protected void doInTransactionWithoutResult(TransactionStatus status) {
1041
1045
assertThat (DataSourceUtils .getConnection (ds )).isEqualTo (con );
1042
1046
TransactionAwareDataSourceProxy dsProxy = new TransactionAwareDataSourceProxy (ds );
1043
1047
try {
1048
+ Connection tCon = dsProxy .getConnection ();
1049
+ tCon .getWarnings ();
1050
+ tCon .clearWarnings ();
1044
1051
assertThat (((ConnectionProxy ) dsProxy .getConnection ()).getTargetConnection ()).isEqualTo (con );
1045
1052
// should be ignored
1046
1053
dsProxy .getConnection ().close ();
@@ -1286,7 +1293,8 @@ protected void doInTransactionWithoutResult(TransactionStatus status) throws Run
1286
1293
assertThat (condition ).as ("Hasn't thread connection" ).isTrue ();
1287
1294
}
1288
1295
1289
- @ Test public void testTransactionWithPropagationNotSupported () throws Exception {
1296
+ @ Test
1297
+ public void testTransactionWithPropagationNotSupported () throws Exception {
1290
1298
TransactionTemplate tt = new TransactionTemplate (tm );
1291
1299
tt .setPropagationBehavior (TransactionDefinition .PROPAGATION_NOT_SUPPORTED );
1292
1300
boolean condition1 = !TransactionSynchronizationManager .hasResource (ds );
0 commit comments