@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
/ *
* Copyright 2002 - 2020 the original author or authors .
* Copyright 2002 - 2022 the original author or authors .
*
* Licensed under the Apache License , Version 2 . 0 ( the "License" ) ;
* you may not use this file except in compliance with the License .
@ -58,6 +58,7 @@ import org.springframework.transaction.support.TransactionTemplate;
@@ -58,6 +58,7 @@ import org.springframework.transaction.support.TransactionTemplate;
import static org.assertj.core.api.Assertions.assertThat ;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType ;
import static org.assertj.core.api.Assertions.assertThatIllegalStateException ;
import static org.assertj.core.api.Assertions.assertThatRuntimeException ;
import static org.assertj.core.api.Assertions.fail ;
import static org.mockito.BDDMockito.given ;
import static org.mockito.BDDMockito.willThrow ;
@ -144,10 +145,8 @@ public class JdbcTransactionManagerTests {
@@ -144,10 +145,8 @@ public class JdbcTransactionManagerTests {
final DataSource dsToUse = ( lazyConnection ? new LazyConnectionDataSourceProxy ( ds ) : ds ) ;
tm = new JdbcTransactionManager ( dsToUse ) ;
TransactionTemplate tt = new TransactionTemplate ( tm ) ;
boolean condition3 = ! TransactionSynchronizationManager . hasResource ( dsToUse ) ;
assertThat ( condition3 ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
boolean condition2 = ! TransactionSynchronizationManager . isSynchronizationActive ( ) ;
assertThat ( condition2 ) . as ( "Synchronization not active" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( dsToUse ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . isSynchronizationActive ( ) ) . as ( "Synchronization not active" ) . isTrue ( ) ;
tt . execute ( new TransactionCallbackWithoutResult ( ) {
@Override
@ -173,10 +172,8 @@ public class JdbcTransactionManagerTests {
@@ -173,10 +172,8 @@ public class JdbcTransactionManagerTests {
}
} ) ;
boolean condition1 = ! TransactionSynchronizationManager . hasResource ( dsToUse ) ;
assertThat ( condition1 ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
boolean condition = ! TransactionSynchronizationManager . isSynchronizationActive ( ) ;
assertThat ( condition ) . as ( "Synchronization not active" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( dsToUse ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . isSynchronizationActive ( ) ) . as ( "Synchronization not active" ) . isTrue ( ) ;
if ( autoCommit & & ( ! lazyConnection | | createStatement ) ) {
InOrder ordered = inOrder ( con ) ;
@ -237,13 +234,11 @@ public class JdbcTransactionManagerTests {
@@ -237,13 +234,11 @@ public class JdbcTransactionManagerTests {
final DataSource dsToUse = ( lazyConnection ? new LazyConnectionDataSourceProxy ( ds ) : ds ) ;
tm = new JdbcTransactionManager ( dsToUse ) ;
TransactionTemplate tt = new TransactionTemplate ( tm ) ;
boolean condition3 = ! TransactionSynchronizationManager . hasResource ( dsToUse ) ;
assertThat ( condition3 ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
boolean condition2 = ! TransactionSynchronizationManager . isSynchronizationActive ( ) ;
assertThat ( condition2 ) . as ( "Synchronization not active" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( dsToUse ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . isSynchronizationActive ( ) ) . as ( "Synchronization not active" ) . isTrue ( ) ;
final RuntimeException ex = new RuntimeException ( "Application exception" ) ;
assertThatExceptionOfType ( RuntimeException . class ) . isThrownBy ( ( ) - >
assertThatRuntimeException ( ) . isThrownBy ( ( ) - >
tt . execute ( new TransactionCallbackWithoutResult ( ) {
@Override
protected void doInTransactionWithoutResult ( TransactionStatus status ) throws RuntimeException {
@ -264,10 +259,8 @@ public class JdbcTransactionManagerTests {
@@ -264,10 +259,8 @@ public class JdbcTransactionManagerTests {
} ) )
. isEqualTo ( ex ) ;
boolean condition1 = ! TransactionSynchronizationManager . hasResource ( ds ) ;
assertThat ( condition1 ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
boolean condition = ! TransactionSynchronizationManager . isSynchronizationActive ( ) ;
assertThat ( condition ) . as ( "Synchronization not active" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . isSynchronizationActive ( ) ) . as ( "Synchronization not active" ) . isTrue ( ) ;
if ( autoCommit & & ( ! lazyConnection | | createStatement ) ) {
InOrder ordered = inOrder ( con ) ;
@ -287,10 +280,8 @@ public class JdbcTransactionManagerTests {
@@ -287,10 +280,8 @@ public class JdbcTransactionManagerTests {
public void testTransactionRollbackOnly ( ) throws Exception {
tm . setTransactionSynchronization ( JdbcTransactionManager . SYNCHRONIZATION_NEVER ) ;
TransactionTemplate tt = new TransactionTemplate ( tm ) ;
boolean condition2 = ! TransactionSynchronizationManager . hasResource ( ds ) ;
assertThat ( condition2 ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
boolean condition1 = ! TransactionSynchronizationManager . isSynchronizationActive ( ) ;
assertThat ( condition1 ) . as ( "Synchronization not active" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . isSynchronizationActive ( ) ) . as ( "Synchronization not active" ) . isTrue ( ) ;
ConnectionHolder conHolder = new ConnectionHolder ( con , true ) ;
TransactionSynchronizationManager . bindResource ( ds , conHolder ) ;
@ -300,10 +291,8 @@ public class JdbcTransactionManagerTests {
@@ -300,10 +291,8 @@ public class JdbcTransactionManagerTests {
@Override
protected void doInTransactionWithoutResult ( TransactionStatus status ) throws RuntimeException {
assertThat ( TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Has thread connection" ) . isTrue ( ) ;
boolean condition1 = ! TransactionSynchronizationManager . isSynchronizationActive ( ) ;
assertThat ( condition1 ) . as ( "Synchronization not active" ) . isTrue ( ) ;
boolean condition = ! status . isNewTransaction ( ) ;
assertThat ( condition ) . as ( "Is existing transaction" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . isSynchronizationActive ( ) ) . as ( "Synchronization not active" ) . isTrue ( ) ;
assertThat ( ! status . isNewTransaction ( ) ) . as ( "Is existing transaction" ) . isTrue ( ) ;
throw ex ;
}
} ) ;
@ -311,16 +300,14 @@ public class JdbcTransactionManagerTests {
@@ -311,16 +300,14 @@ public class JdbcTransactionManagerTests {
}
catch ( RuntimeException ex2 ) {
// expected
boolean condition = ! TransactionSynchronizationManager . isSynchronizationActive ( ) ;
assertThat ( condition ) . as ( "Synchronization not active" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . isSynchronizationActive ( ) ) . as ( "Synchronization not active" ) . isTrue ( ) ;
assertThat ( ex2 ) . as ( "Correct exception thrown" ) . isEqualTo ( ex ) ;
}
finally {
TransactionSynchronizationManager . unbindResource ( ds ) ;
}
boolean condition = ! TransactionSynchronizationManager . hasResource ( ds ) ;
assertThat ( condition ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
}
@Test
@ -338,10 +325,8 @@ public class JdbcTransactionManagerTests {
@@ -338,10 +325,8 @@ public class JdbcTransactionManagerTests {
if ( failEarly ) {
tm . setFailEarlyOnGlobalRollbackOnly ( true ) ;
}
boolean condition2 = ! TransactionSynchronizationManager . hasResource ( ds ) ;
assertThat ( condition2 ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
boolean condition1 = ! TransactionSynchronizationManager . isSynchronizationActive ( ) ;
assertThat ( condition1 ) . as ( "Synchronization not active" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . isSynchronizationActive ( ) ) . as ( "Synchronization not active" ) . isTrue ( ) ;
TransactionStatus ts = tm . getTransaction ( new DefaultTransactionDefinition ( ) ) ;
TestTransactionSynchronization synch =
@ -356,21 +341,18 @@ public class JdbcTransactionManagerTests {
@@ -356,21 +341,18 @@ public class JdbcTransactionManagerTests {
tt . execute ( new TransactionCallbackWithoutResult ( ) {
@Override
protected void doInTransactionWithoutResult ( TransactionStatus status ) throws RuntimeException {
boolean condition1 = ! status . isNewTransaction ( ) ;
assertThat ( condition1 ) . as ( "Is existing transaction" ) . isTrue ( ) ;
assertThat ( ! status . isNewTransaction ( ) ) . as ( "Is existing transaction" ) . isTrue ( ) ;
assertThat ( status . isRollbackOnly ( ) ) . as ( "Is not rollback-only" ) . isFalse ( ) ;
tt . execute ( new TransactionCallbackWithoutResult ( ) {
@Override
protected void doInTransactionWithoutResult ( TransactionStatus status ) throws RuntimeException {
assertThat ( TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Has thread connection" ) . isTrue ( ) ;
assertThat ( TransactionSynchronizationManager . isSynchronizationActive ( ) ) . as ( "Synchronization active" ) . isTrue ( ) ;
boolean condition = ! status . isNewTransaction ( ) ;
assertThat ( condition ) . as ( "Is existing transaction" ) . isTrue ( ) ;
assertThat ( ! status . isNewTransaction ( ) ) . as ( "Is existing transaction" ) . isTrue ( ) ;
status . setRollbackOnly ( ) ;
}
} ) ;
boolean condition = ! status . isNewTransaction ( ) ;
assertThat ( condition ) . as ( "Is existing transaction" ) . isTrue ( ) ;
assertThat ( ! status . isNewTransaction ( ) ) . as ( "Is existing transaction" ) . isTrue ( ) ;
assertThat ( status . isRollbackOnly ( ) ) . as ( "Is rollback-only" ) . isTrue ( ) ;
}
} ) ;
@ -393,8 +375,7 @@ public class JdbcTransactionManagerTests {
@@ -393,8 +375,7 @@ public class JdbcTransactionManagerTests {
}
}
boolean condition = ! TransactionSynchronizationManager . hasResource ( ds ) ;
assertThat ( condition ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( synch . beforeCommitCalled ) . isFalse ( ) ;
assertThat ( synch . beforeCompletionCalled ) . isTrue ( ) ;
assertThat ( synch . afterCommitCalled ) . isFalse ( ) ;
@ -407,10 +388,8 @@ public class JdbcTransactionManagerTests {
@@ -407,10 +388,8 @@ public class JdbcTransactionManagerTests {
public void testParticipatingTransactionWithIncompatibleIsolationLevel ( ) throws Exception {
tm . setValidateExistingTransaction ( true ) ;
boolean condition2 = ! TransactionSynchronizationManager . hasResource ( ds ) ;
assertThat ( condition2 ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
boolean condition1 = ! TransactionSynchronizationManager . isSynchronizationActive ( ) ;
assertThat ( condition1 ) . as ( "Synchronization not active" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . isSynchronizationActive ( ) ) . as ( "Synchronization not active" ) . isTrue ( ) ;
assertThatExceptionOfType ( IllegalTransactionStateException . class ) . isThrownBy ( ( ) - > {
final TransactionTemplate tt = new TransactionTemplate ( tm ) ;
@ -432,8 +411,7 @@ public class JdbcTransactionManagerTests {
@@ -432,8 +411,7 @@ public class JdbcTransactionManagerTests {
} ) ;
} ) ;
boolean condition = ! TransactionSynchronizationManager . hasResource ( ds ) ;
assertThat ( condition ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
verify ( con ) . rollback ( ) ;
verify ( con ) . close ( ) ;
}
@ -443,10 +421,8 @@ public class JdbcTransactionManagerTests {
@@ -443,10 +421,8 @@ public class JdbcTransactionManagerTests {
willThrow ( new SQLException ( "read-only not supported" ) ) . given ( con ) . setReadOnly ( true ) ;
tm . setValidateExistingTransaction ( true ) ;
boolean condition2 = ! TransactionSynchronizationManager . hasResource ( ds ) ;
assertThat ( condition2 ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
boolean condition1 = ! TransactionSynchronizationManager . isSynchronizationActive ( ) ;
assertThat ( condition1 ) . as ( "Synchronization not active" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . isSynchronizationActive ( ) ) . as ( "Synchronization not active" ) . isTrue ( ) ;
assertThatExceptionOfType ( IllegalTransactionStateException . class ) . isThrownBy ( ( ) - > {
final TransactionTemplate tt = new TransactionTemplate ( tm ) ;
@ -469,18 +445,15 @@ public class JdbcTransactionManagerTests {
@@ -469,18 +445,15 @@ public class JdbcTransactionManagerTests {
} ) ;
} ) ;
boolean condition = ! TransactionSynchronizationManager . hasResource ( ds ) ;
assertThat ( condition ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
verify ( con ) . rollback ( ) ;
verify ( con ) . close ( ) ;
}
@Test
public void testParticipatingTransactionWithTransactionStartedFromSynch ( ) throws Exception {
boolean condition2 = ! TransactionSynchronizationManager . hasResource ( ds ) ;
assertThat ( condition2 ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
boolean condition1 = ! TransactionSynchronizationManager . isSynchronizationActive ( ) ;
assertThat ( condition1 ) . as ( "Synchronization not active" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . isSynchronizationActive ( ) ) . as ( "Synchronization not active" ) . isTrue ( ) ;
final TransactionTemplate tt = new TransactionTemplate ( tm ) ;
tt . setPropagationBehavior ( TransactionDefinition . PROPAGATION_REQUIRES_NEW ) ;
@ -506,14 +479,12 @@ public class JdbcTransactionManagerTests {
@@ -506,14 +479,12 @@ public class JdbcTransactionManagerTests {
}
} ) ;
boolean condition = ! TransactionSynchronizationManager . hasResource ( ds ) ;
assertThat ( condition ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( synch . beforeCommitCalled ) . isTrue ( ) ;
assertThat ( synch . beforeCompletionCalled ) . isTrue ( ) ;
assertThat ( synch . afterCommitCalled ) . isTrue ( ) ;
assertThat ( synch . afterCompletionCalled ) . isTrue ( ) ;
boolean condition3 = synch . afterCompletionException instanceof IllegalStateException ;
assertThat ( condition3 ) . isTrue ( ) ;
assertThat ( synch . afterCompletionException instanceof IllegalStateException ) . isTrue ( ) ;
verify ( con , times ( 2 ) ) . commit ( ) ;
verify ( con , times ( 2 ) ) . close ( ) ;
}
@ -524,10 +495,8 @@ public class JdbcTransactionManagerTests {
@@ -524,10 +495,8 @@ public class JdbcTransactionManagerTests {
final Connection con2 = mock ( Connection . class ) ;
given ( ds2 . getConnection ( ) ) . willReturn ( con2 ) ;
boolean condition2 = ! TransactionSynchronizationManager . hasResource ( ds ) ;
assertThat ( condition2 ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
boolean condition1 = ! TransactionSynchronizationManager . isSynchronizationActive ( ) ;
assertThat ( condition1 ) . as ( "Synchronization not active" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . isSynchronizationActive ( ) ) . as ( "Synchronization not active" ) . isTrue ( ) ;
final TransactionTemplate tt = new TransactionTemplate ( tm ) ;
@ -548,8 +517,7 @@ public class JdbcTransactionManagerTests {
@@ -548,8 +517,7 @@ public class JdbcTransactionManagerTests {
}
} ) ;
boolean condition = ! TransactionSynchronizationManager . hasResource ( ds ) ;
assertThat ( condition ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( synch . beforeCommitCalled ) . isTrue ( ) ;
assertThat ( synch . beforeCompletionCalled ) . isTrue ( ) ;
assertThat ( synch . afterCommitCalled ) . isTrue ( ) ;
@ -566,10 +534,8 @@ public class JdbcTransactionManagerTests {
@@ -566,10 +534,8 @@ public class JdbcTransactionManagerTests {
JdbcTransactionManager tm2 = new JdbcTransactionManager ( ds ) ;
// tm has no synch enabled (used at outer level), tm2 has synch enabled (inner level)
boolean condition2 = ! TransactionSynchronizationManager . hasResource ( ds ) ;
assertThat ( condition2 ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
boolean condition1 = ! TransactionSynchronizationManager . isSynchronizationActive ( ) ;
assertThat ( condition1 ) . as ( "Synchronization not active" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . isSynchronizationActive ( ) ) . as ( "Synchronization not active" ) . isTrue ( ) ;
TransactionStatus ts = tm . getTransaction ( new DefaultTransactionDefinition ( ) ) ;
final TestTransactionSynchronization synch =
@ -581,21 +547,18 @@ public class JdbcTransactionManagerTests {
@@ -581,21 +547,18 @@ public class JdbcTransactionManagerTests {
tt . execute ( new TransactionCallbackWithoutResult ( ) {
@Override
protected void doInTransactionWithoutResult ( TransactionStatus status ) throws RuntimeException {
boolean condition1 = ! status . isNewTransaction ( ) ;
assertThat ( condition1 ) . as ( "Is existing transaction" ) . isTrue ( ) ;
assertThat ( ! status . isNewTransaction ( ) ) . as ( "Is existing transaction" ) . isTrue ( ) ;
assertThat ( status . isRollbackOnly ( ) ) . as ( "Is not rollback-only" ) . isFalse ( ) ;
tt . execute ( new TransactionCallbackWithoutResult ( ) {
@Override
protected void doInTransactionWithoutResult ( TransactionStatus status ) throws RuntimeException {
assertThat ( TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Has thread connection" ) . isTrue ( ) ;
assertThat ( TransactionSynchronizationManager . isSynchronizationActive ( ) ) . as ( "Synchronization active" ) . isTrue ( ) ;
boolean condition = ! status . isNewTransaction ( ) ;
assertThat ( condition ) . as ( "Is existing transaction" ) . isTrue ( ) ;
assertThat ( ! status . isNewTransaction ( ) ) . as ( "Is existing transaction" ) . isTrue ( ) ;
status . setRollbackOnly ( ) ;
}
} ) ;
boolean condition = ! status . isNewTransaction ( ) ;
assertThat ( condition ) . as ( "Is existing transaction" ) . isTrue ( ) ;
assertThat ( ! status . isNewTransaction ( ) ) . as ( "Is existing transaction" ) . isTrue ( ) ;
assertThat ( status . isRollbackOnly ( ) ) . as ( "Is rollback-only" ) . isTrue ( ) ;
TransactionSynchronizationManager . registerSynchronization ( synch ) ;
}
@ -604,8 +567,7 @@ public class JdbcTransactionManagerTests {
@@ -604,8 +567,7 @@ public class JdbcTransactionManagerTests {
tm . commit ( ts ) ;
} ) ;
boolean condition = ! TransactionSynchronizationManager . hasResource ( ds ) ;
assertThat ( condition ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( synch . beforeCommitCalled ) . isFalse ( ) ;
assertThat ( synch . beforeCompletionCalled ) . isTrue ( ) ;
assertThat ( synch . afterCommitCalled ) . isFalse ( ) ;
@ -618,10 +580,8 @@ public class JdbcTransactionManagerTests {
@@ -618,10 +580,8 @@ public class JdbcTransactionManagerTests {
public void testPropagationRequiresNewWithExistingTransaction ( ) throws Exception {
final TransactionTemplate tt = new TransactionTemplate ( tm ) ;
tt . setPropagationBehavior ( TransactionDefinition . PROPAGATION_REQUIRES_NEW ) ;
boolean condition2 = ! TransactionSynchronizationManager . hasResource ( ds ) ;
assertThat ( condition2 ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
boolean condition1 = ! TransactionSynchronizationManager . isSynchronizationActive ( ) ;
assertThat ( condition1 ) . as ( "Synchronization not active" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . isSynchronizationActive ( ) ) . as ( "Synchronization not active" ) . isTrue ( ) ;
tt . execute ( new TransactionCallbackWithoutResult ( ) {
@Override
@ -647,8 +607,7 @@ public class JdbcTransactionManagerTests {
@@ -647,8 +607,7 @@ public class JdbcTransactionManagerTests {
}
} ) ;
boolean condition = ! TransactionSynchronizationManager . hasResource ( ds ) ;
assertThat ( condition ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
verify ( con ) . rollback ( ) ;
verify ( con ) . commit ( ) ;
verify ( con , times ( 2 ) ) . close ( ) ;
@ -667,12 +626,9 @@ public class JdbcTransactionManagerTests {
@@ -667,12 +626,9 @@ public class JdbcTransactionManagerTests {
final TransactionTemplate tt2 = new TransactionTemplate ( tm2 ) ;
tt2 . setPropagationBehavior ( TransactionDefinition . PROPAGATION_REQUIRES_NEW ) ;
boolean condition4 = ! TransactionSynchronizationManager . hasResource ( ds ) ;
assertThat ( condition4 ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
boolean condition3 = ! TransactionSynchronizationManager . hasResource ( ds2 ) ;
assertThat ( condition3 ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
boolean condition2 = ! TransactionSynchronizationManager . isSynchronizationActive ( ) ;
assertThat ( condition2 ) . as ( "Synchronization not active" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( ds2 ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . isSynchronizationActive ( ) ) . as ( "Synchronization not active" ) . isTrue ( ) ;
tt . execute ( new TransactionCallbackWithoutResult ( ) {
@Override
@ -698,10 +654,8 @@ public class JdbcTransactionManagerTests {
@@ -698,10 +654,8 @@ public class JdbcTransactionManagerTests {
}
} ) ;
boolean condition1 = ! TransactionSynchronizationManager . hasResource ( ds ) ;
assertThat ( condition1 ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
boolean condition = ! TransactionSynchronizationManager . hasResource ( ds2 ) ;
assertThat ( condition ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( ds2 ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
verify ( con ) . commit ( ) ;
verify ( con ) . close ( ) ;
verify ( con2 ) . rollback ( ) ;
@ -722,12 +676,9 @@ public class JdbcTransactionManagerTests {
@@ -722,12 +676,9 @@ public class JdbcTransactionManagerTests {
final TransactionTemplate tt2 = new TransactionTemplate ( tm2 ) ;
tt2 . setPropagationBehavior ( TransactionDefinition . PROPAGATION_REQUIRES_NEW ) ;
boolean condition4 = ! TransactionSynchronizationManager . hasResource ( ds ) ;
assertThat ( condition4 ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
boolean condition3 = ! TransactionSynchronizationManager . hasResource ( ds2 ) ;
assertThat ( condition3 ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
boolean condition2 = ! TransactionSynchronizationManager . isSynchronizationActive ( ) ;
assertThat ( condition2 ) . as ( "Synchronization not active" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( ds2 ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . isSynchronizationActive ( ) ) . as ( "Synchronization not active" ) . isTrue ( ) ;
assertThatExceptionOfType ( CannotCreateTransactionException . class ) . isThrownBy ( ( ) - >
tt . execute ( new TransactionCallbackWithoutResult ( ) {
@ -746,10 +697,8 @@ public class JdbcTransactionManagerTests {
@@ -746,10 +697,8 @@ public class JdbcTransactionManagerTests {
}
} ) ) . withCause ( failure ) ;
boolean condition1 = ! TransactionSynchronizationManager . hasResource ( ds ) ;
assertThat ( condition1 ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
boolean condition = ! TransactionSynchronizationManager . hasResource ( ds2 ) ;
assertThat ( condition ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( ds2 ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
verify ( con ) . rollback ( ) ;
verify ( con ) . close ( ) ;
}
@ -758,10 +707,8 @@ public class JdbcTransactionManagerTests {
@@ -758,10 +707,8 @@ public class JdbcTransactionManagerTests {
public void testPropagationNotSupportedWithExistingTransaction ( ) throws Exception {
final TransactionTemplate tt = new TransactionTemplate ( tm ) ;
tt . setPropagationBehavior ( TransactionDefinition . PROPAGATION_REQUIRES_NEW ) ;
boolean condition2 = ! TransactionSynchronizationManager . hasResource ( ds ) ;
assertThat ( condition2 ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
boolean condition1 = ! TransactionSynchronizationManager . isSynchronizationActive ( ) ;
assertThat ( condition1 ) . as ( "Synchronization not active" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . isSynchronizationActive ( ) ) . as ( "Synchronization not active" ) . isTrue ( ) ;
tt . execute ( new TransactionCallbackWithoutResult ( ) {
@Override
@ -773,11 +720,9 @@ public class JdbcTransactionManagerTests {
@@ -773,11 +720,9 @@ public class JdbcTransactionManagerTests {
tt . execute ( new TransactionCallbackWithoutResult ( ) {
@Override
protected void doInTransactionWithoutResult ( TransactionStatus status ) throws RuntimeException {
boolean condition1 = ! TransactionSynchronizationManager . hasResource ( ds ) ;
assertThat ( condition1 ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( TransactionSynchronizationManager . isSynchronizationActive ( ) ) . as ( "Synchronization active" ) . isTrue ( ) ;
boolean condition = ! status . isNewTransaction ( ) ;
assertThat ( condition ) . as ( "Isn't new transaction" ) . isTrue ( ) ;
assertThat ( ! status . isNewTransaction ( ) ) . as ( "Isn't new transaction" ) . isTrue ( ) ;
assertThat ( TransactionSynchronizationManager . isCurrentTransactionReadOnly ( ) ) . isFalse ( ) ;
assertThat ( TransactionSynchronizationManager . isActualTransactionActive ( ) ) . isFalse ( ) ;
status . setRollbackOnly ( ) ;
@ -789,8 +734,7 @@ public class JdbcTransactionManagerTests {
@@ -789,8 +734,7 @@ public class JdbcTransactionManagerTests {
}
} ) ;
boolean condition = ! TransactionSynchronizationManager . hasResource ( ds ) ;
assertThat ( condition ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
verify ( con ) . commit ( ) ;
verify ( con ) . close ( ) ;
}
@ -799,10 +743,8 @@ public class JdbcTransactionManagerTests {
@@ -799,10 +743,8 @@ public class JdbcTransactionManagerTests {
public void testPropagationNeverWithExistingTransaction ( ) throws Exception {
final TransactionTemplate tt = new TransactionTemplate ( tm ) ;
tt . setPropagationBehavior ( TransactionDefinition . PROPAGATION_REQUIRES_NEW ) ;
boolean condition2 = ! TransactionSynchronizationManager . hasResource ( ds ) ;
assertThat ( condition2 ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
boolean condition1 = ! TransactionSynchronizationManager . isSynchronizationActive ( ) ;
assertThat ( condition1 ) . as ( "Synchronization not active" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . isSynchronizationActive ( ) ) . as ( "Synchronization not active" ) . isTrue ( ) ;
assertThatExceptionOfType ( IllegalTransactionStateException . class ) . isThrownBy ( ( ) - >
tt . execute ( new TransactionCallbackWithoutResult ( ) {
@ -820,8 +762,7 @@ public class JdbcTransactionManagerTests {
@@ -820,8 +762,7 @@ public class JdbcTransactionManagerTests {
}
} ) ) ;
boolean condition = ! TransactionSynchronizationManager . hasResource ( ds ) ;
assertThat ( condition ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
verify ( con ) . rollback ( ) ;
verify ( con ) . close ( ) ;
}
@ -830,10 +771,8 @@ public class JdbcTransactionManagerTests {
@@ -830,10 +771,8 @@ public class JdbcTransactionManagerTests {
public void testPropagationSupportsAndRequiresNew ( ) throws Exception {
TransactionTemplate tt = new TransactionTemplate ( tm ) ;
tt . setPropagationBehavior ( TransactionDefinition . PROPAGATION_SUPPORTS ) ;
boolean condition2 = ! TransactionSynchronizationManager . hasResource ( ds ) ;
assertThat ( condition2 ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
boolean condition1 = ! TransactionSynchronizationManager . isSynchronizationActive ( ) ;
assertThat ( condition1 ) . as ( "Synchronization not active" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . isSynchronizationActive ( ) ) . as ( "Synchronization not active" ) . isTrue ( ) ;
tt . execute ( new TransactionCallbackWithoutResult ( ) {
@Override
@ -854,8 +793,7 @@ public class JdbcTransactionManagerTests {
@@ -854,8 +793,7 @@ public class JdbcTransactionManagerTests {
}
} ) ;
boolean condition = ! TransactionSynchronizationManager . hasResource ( ds ) ;
assertThat ( condition ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
verify ( con ) . commit ( ) ;
verify ( con ) . close ( ) ;
}
@ -869,10 +807,8 @@ public class JdbcTransactionManagerTests {
@@ -869,10 +807,8 @@ public class JdbcTransactionManagerTests {
final
TransactionTemplate tt = new TransactionTemplate ( tm ) ;
tt . setPropagationBehavior ( TransactionDefinition . PROPAGATION_SUPPORTS ) ;
boolean condition2 = ! TransactionSynchronizationManager . hasResource ( ds ) ;
assertThat ( condition2 ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
boolean condition1 = ! TransactionSynchronizationManager . isSynchronizationActive ( ) ;
assertThat ( condition1 ) . as ( "Synchronization not active" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . isSynchronizationActive ( ) ) . as ( "Synchronization not active" ) . isTrue ( ) ;
tt . execute ( new TransactionCallbackWithoutResult ( ) {
@Override
@ -896,8 +832,7 @@ public class JdbcTransactionManagerTests {
@@ -896,8 +832,7 @@ public class JdbcTransactionManagerTests {
}
} ) ;
boolean condition = ! TransactionSynchronizationManager . hasResource ( ds ) ;
assertThat ( condition ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
verify ( con1 ) . close ( ) ;
verify ( con2 ) . commit ( ) ;
verify ( con2 ) . close ( ) ;
@ -912,8 +847,7 @@ public class JdbcTransactionManagerTests {
@@ -912,8 +847,7 @@ public class JdbcTransactionManagerTests {
tt . setPropagationBehavior ( TransactionDefinition . PROPAGATION_REQUIRES_NEW ) ;
tt . setIsolationLevel ( TransactionDefinition . ISOLATION_SERIALIZABLE ) ;
tt . setReadOnly ( true ) ;
boolean condition1 = ! TransactionSynchronizationManager . hasResource ( ds ) ;
assertThat ( condition1 ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
tt . execute ( new TransactionCallbackWithoutResult ( ) {
@Override
protected void doInTransactionWithoutResult ( TransactionStatus status ) {
@ -923,8 +857,7 @@ public class JdbcTransactionManagerTests {
@@ -923,8 +857,7 @@ public class JdbcTransactionManagerTests {
}
} ) ;
boolean condition = ! TransactionSynchronizationManager . hasResource ( ds ) ;
assertThat ( condition ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
InOrder ordered = inOrder ( con ) ;
ordered . verify ( con ) . setReadOnly ( true ) ;
ordered . verify ( con ) . setTransactionIsolation ( Connection . TRANSACTION_SERIALIZABLE ) ;
@ -947,8 +880,7 @@ public class JdbcTransactionManagerTests {
@@ -947,8 +880,7 @@ public class JdbcTransactionManagerTests {
TransactionTemplate tt = new TransactionTemplate ( tm ) ;
tt . setPropagationBehavior ( TransactionDefinition . PROPAGATION_REQUIRES_NEW ) ;
tt . setReadOnly ( true ) ;
boolean condition1 = ! TransactionSynchronizationManager . hasResource ( ds ) ;
assertThat ( condition1 ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
tt . execute ( new TransactionCallbackWithoutResult ( ) {
@Override
protected void doInTransactionWithoutResult ( TransactionStatus status ) {
@ -958,8 +890,7 @@ public class JdbcTransactionManagerTests {
@@ -958,8 +890,7 @@ public class JdbcTransactionManagerTests {
}
} ) ;
boolean condition = ! TransactionSynchronizationManager . hasResource ( ds ) ;
assertThat ( condition ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
InOrder ordered = inOrder ( con , stmt ) ;
ordered . verify ( con ) . setReadOnly ( true ) ;
ordered . verify ( con ) . setAutoCommit ( false ) ;
@ -981,8 +912,7 @@ public class JdbcTransactionManagerTests {
@@ -981,8 +912,7 @@ public class JdbcTransactionManagerTests {
TransactionTemplate tt = new TransactionTemplate ( tm ) ;
tt . setTimeout ( timeout ) ;
boolean condition1 = ! TransactionSynchronizationManager . hasResource ( ds ) ;
assertThat ( condition1 ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
try {
tt . execute ( new TransactionCallbackWithoutResult ( ) {
@ -1016,8 +946,7 @@ public class JdbcTransactionManagerTests {
@@ -1016,8 +946,7 @@ public class JdbcTransactionManagerTests {
}
}
boolean condition = ! TransactionSynchronizationManager . hasResource ( ds ) ;
assertThat ( condition ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
if ( timeout > 1 ) {
verify ( ps ) . setQueryTimeout ( timeout - 1 ) ;
verify ( con ) . commit ( ) ;
@ -1037,8 +966,7 @@ public class JdbcTransactionManagerTests {
@@ -1037,8 +966,7 @@ public class JdbcTransactionManagerTests {
given ( con . getWarnings ( ) ) . willThrow ( new SQLException ( ) ) ;
TransactionTemplate tt = new TransactionTemplate ( tm ) ;
boolean condition1 = ! TransactionSynchronizationManager . hasResource ( ds ) ;
assertThat ( condition1 ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
tt . execute ( new TransactionCallbackWithoutResult ( ) {
@Override
protected void doInTransactionWithoutResult ( TransactionStatus status ) {
@ -1059,8 +987,7 @@ public class JdbcTransactionManagerTests {
@@ -1059,8 +987,7 @@ public class JdbcTransactionManagerTests {
}
} ) ;
boolean condition = ! TransactionSynchronizationManager . hasResource ( ds ) ;
assertThat ( condition ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
InOrder ordered = inOrder ( con ) ;
ordered . verify ( con ) . setAutoCommit ( false ) ;
ordered . verify ( con ) . commit ( ) ;
@ -1074,8 +1001,7 @@ public class JdbcTransactionManagerTests {
@@ -1074,8 +1001,7 @@ public class JdbcTransactionManagerTests {
final TransactionTemplate tt = new TransactionTemplate ( tm ) ;
tt . setPropagationBehavior ( TransactionTemplate . PROPAGATION_REQUIRES_NEW ) ;
boolean condition1 = ! TransactionSynchronizationManager . hasResource ( ds ) ;
assertThat ( condition1 ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
tt . execute ( new TransactionCallbackWithoutResult ( ) {
@Override
@ -1119,8 +1045,7 @@ public class JdbcTransactionManagerTests {
@@ -1119,8 +1045,7 @@ public class JdbcTransactionManagerTests {
}
} ) ;
boolean condition = ! TransactionSynchronizationManager . hasResource ( ds ) ;
assertThat ( condition ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
InOrder ordered = inOrder ( con ) ;
ordered . verify ( con ) . setAutoCommit ( false ) ;
ordered . verify ( con ) . commit ( ) ;
@ -1134,8 +1059,7 @@ public class JdbcTransactionManagerTests {
@@ -1134,8 +1059,7 @@ public class JdbcTransactionManagerTests {
final TransactionTemplate tt = new TransactionTemplate ( tm ) ;
tt . setPropagationBehavior ( TransactionTemplate . PROPAGATION_REQUIRES_NEW ) ;
boolean condition1 = ! TransactionSynchronizationManager . hasResource ( ds ) ;
assertThat ( condition1 ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
tt . execute ( new TransactionCallbackWithoutResult ( ) {
@Override
@ -1180,8 +1104,7 @@ public class JdbcTransactionManagerTests {
@@ -1180,8 +1104,7 @@ public class JdbcTransactionManagerTests {
}
} ) ;
boolean condition = ! TransactionSynchronizationManager . hasResource ( ds ) ;
assertThat ( condition ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
InOrder ordered = inOrder ( con ) ;
ordered . verify ( con ) . setAutoCommit ( false ) ;
ordered . verify ( con ) . commit ( ) ;
@ -1205,8 +1128,7 @@ public class JdbcTransactionManagerTests {
@@ -1205,8 +1128,7 @@ public class JdbcTransactionManagerTests {
}
} ) ) ;
boolean condition = ! TransactionSynchronizationManager . hasResource ( ds ) ;
assertThat ( condition ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
verify ( con ) . close ( ) ;
}
@ -1223,8 +1145,7 @@ public class JdbcTransactionManagerTests {
@@ -1223,8 +1145,7 @@ public class JdbcTransactionManagerTests {
}
} ) ) ;
boolean condition = ! TransactionSynchronizationManager . hasResource ( ds ) ;
assertThat ( condition ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
verify ( con ) . close ( ) ;
}
@ -1242,8 +1163,7 @@ public class JdbcTransactionManagerTests {
@@ -1242,8 +1163,7 @@ public class JdbcTransactionManagerTests {
}
} ) ) ;
boolean condition = ! TransactionSynchronizationManager . hasResource ( ds ) ;
assertThat ( condition ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
verify ( con ) . close ( ) ;
}
@ -1260,8 +1180,7 @@ public class JdbcTransactionManagerTests {
@@ -1260,8 +1180,7 @@ public class JdbcTransactionManagerTests {
}
} ) ) ;
boolean condition = ! TransactionSynchronizationManager . hasResource ( ds ) ;
assertThat ( condition ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
verify ( con ) . close ( ) ;
}
@ -1279,8 +1198,7 @@ public class JdbcTransactionManagerTests {
@@ -1279,8 +1198,7 @@ public class JdbcTransactionManagerTests {
}
} ) ) ;
boolean condition = ! TransactionSynchronizationManager . hasResource ( ds ) ;
assertThat ( condition ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
verify ( con ) . rollback ( ) ;
verify ( con ) . close ( ) ;
}
@ -1299,8 +1217,7 @@ public class JdbcTransactionManagerTests {
@@ -1299,8 +1217,7 @@ public class JdbcTransactionManagerTests {
}
} ) ) ;
boolean condition = ! TransactionSynchronizationManager . hasResource ( ds ) ;
assertThat ( condition ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
InOrder ordered = inOrder ( con ) ;
ordered . verify ( con ) . setAutoCommit ( false ) ;
ordered . verify ( con ) . rollback ( ) ;
@ -1323,8 +1240,7 @@ public class JdbcTransactionManagerTests {
@@ -1323,8 +1240,7 @@ public class JdbcTransactionManagerTests {
}
} ) ) ;
boolean condition = ! TransactionSynchronizationManager . hasResource ( ds ) ;
assertThat ( condition ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
InOrder ordered = inOrder ( con ) ;
ordered . verify ( con ) . setAutoCommit ( false ) ;
ordered . verify ( con ) . rollback ( ) ;
@ -1346,8 +1262,7 @@ public class JdbcTransactionManagerTests {
@@ -1346,8 +1262,7 @@ public class JdbcTransactionManagerTests {
}
} ) ) ;
boolean condition = ! TransactionSynchronizationManager . hasResource ( ds ) ;
assertThat ( condition ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
InOrder ordered = inOrder ( con ) ;
ordered . verify ( con ) . setAutoCommit ( false ) ;
ordered . verify ( con ) . rollback ( ) ;
@ -1359,65 +1274,53 @@ public class JdbcTransactionManagerTests {
@@ -1359,65 +1274,53 @@ public class JdbcTransactionManagerTests {
public void testTransactionWithPropagationSupports ( ) throws Exception {
TransactionTemplate tt = new TransactionTemplate ( tm ) ;
tt . setPropagationBehavior ( TransactionDefinition . PROPAGATION_SUPPORTS ) ;
boolean condition1 = ! TransactionSynchronizationManager . hasResource ( ds ) ;
assertThat ( condition1 ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
tt . execute ( new TransactionCallbackWithoutResult ( ) {
@Override
protected void doInTransactionWithoutResult ( TransactionStatus status ) throws RuntimeException {
boolean condition1 = ! TransactionSynchronizationManager . hasResource ( ds ) ;
assertThat ( condition1 ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
boolean condition = ! status . isNewTransaction ( ) ;
assertThat ( condition ) . as ( "Is not new transaction" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! status . isNewTransaction ( ) ) . as ( "Is not new transaction" ) . isTrue ( ) ;
assertThat ( TransactionSynchronizationManager . isCurrentTransactionReadOnly ( ) ) . isFalse ( ) ;
assertThat ( TransactionSynchronizationManager . isActualTransactionActive ( ) ) . isFalse ( ) ;
}
} ) ;
boolean condition = ! TransactionSynchronizationManager . hasResource ( ds ) ;
assertThat ( condition ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
}
@Test
public void testTransactionWithPropagationNotSupported ( ) throws Exception {
TransactionTemplate tt = new TransactionTemplate ( tm ) ;
tt . setPropagationBehavior ( TransactionDefinition . PROPAGATION_NOT_SUPPORTED ) ;
boolean condition1 = ! TransactionSynchronizationManager . hasResource ( ds ) ;
assertThat ( condition1 ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
tt . execute ( new TransactionCallbackWithoutResult ( ) {
@Override
protected void doInTransactionWithoutResult ( TransactionStatus status ) throws RuntimeException {
boolean condition1 = ! TransactionSynchronizationManager . hasResource ( ds ) ;
assertThat ( condition1 ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
boolean condition = ! status . isNewTransaction ( ) ;
assertThat ( condition ) . as ( "Is not new transaction" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! status . isNewTransaction ( ) ) . as ( "Is not new transaction" ) . isTrue ( ) ;
}
} ) ;
boolean condition = ! TransactionSynchronizationManager . hasResource ( ds ) ;
assertThat ( condition ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
}
@Test
public void testTransactionWithPropagationNever ( ) throws Exception {
TransactionTemplate tt = new TransactionTemplate ( tm ) ;
tt . setPropagationBehavior ( TransactionDefinition . PROPAGATION_NEVER ) ;
boolean condition1 = ! TransactionSynchronizationManager . hasResource ( ds ) ;
assertThat ( condition1 ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
tt . execute ( new TransactionCallbackWithoutResult ( ) {
@Override
protected void doInTransactionWithoutResult ( TransactionStatus status ) throws RuntimeException {
boolean condition1 = ! TransactionSynchronizationManager . hasResource ( ds ) ;
assertThat ( condition1 ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
boolean condition = ! status . isNewTransaction ( ) ;
assertThat ( condition ) . as ( "Is not new transaction" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! status . isNewTransaction ( ) ) . as ( "Is not new transaction" ) . isTrue ( ) ;
}
} ) ;
boolean condition = ! TransactionSynchronizationManager . hasResource ( ds ) ;
assertThat ( condition ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
}
@Test
@ -1442,37 +1345,31 @@ public class JdbcTransactionManagerTests {
@@ -1442,37 +1345,31 @@ public class JdbcTransactionManagerTests {
final TransactionTemplate tt = new TransactionTemplate ( tm ) ;
tt . setPropagationBehavior ( TransactionDefinition . PROPAGATION_NESTED ) ;
boolean condition2 = ! TransactionSynchronizationManager . hasResource ( ds ) ;
assertThat ( condition2 ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
boolean condition1 = ! TransactionSynchronizationManager . isSynchronizationActive ( ) ;
assertThat ( condition1 ) . as ( "Synchronization not active" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . isSynchronizationActive ( ) ) . as ( "Synchronization not active" ) . isTrue ( ) ;
tt . execute ( new TransactionCallbackWithoutResult ( ) {
@Override
protected void doInTransactionWithoutResult ( TransactionStatus status ) throws RuntimeException {
assertThat ( status . isNewTransaction ( ) ) . as ( "Is new transaction" ) . isTrue ( ) ;
boolean condition1 = ! status . hasSavepoint ( ) ;
assertThat ( condition1 ) . as ( "Isn't nested transaction" ) . isTrue ( ) ;
assertThat ( ! status . hasSavepoint ( ) ) . as ( "Isn't nested transaction" ) . isTrue ( ) ;
for ( int i = 0 ; i < count ; i + + ) {
tt . execute ( new TransactionCallbackWithoutResult ( ) {
@Override
protected void doInTransactionWithoutResult ( TransactionStatus status ) throws RuntimeException {
assertThat ( TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Has thread connection" ) . isTrue ( ) ;
assertThat ( TransactionSynchronizationManager . isSynchronizationActive ( ) ) . as ( "Synchronization active" ) . isTrue ( ) ;
boolean condition = ! status . isNewTransaction ( ) ;
assertThat ( condition ) . as ( "Isn't new transaction" ) . isTrue ( ) ;
assertThat ( ! status . isNewTransaction ( ) ) . as ( "Isn't new transaction" ) . isTrue ( ) ;
assertThat ( status . hasSavepoint ( ) ) . as ( "Is nested transaction" ) . isTrue ( ) ;
}
} ) ;
}
assertThat ( status . isNewTransaction ( ) ) . as ( "Is new transaction" ) . isTrue ( ) ;
boolean condition = ! status . hasSavepoint ( ) ;
assertThat ( condition ) . as ( "Isn't nested transaction" ) . isTrue ( ) ;
assertThat ( ! status . hasSavepoint ( ) ) . as ( "Isn't nested transaction" ) . isTrue ( ) ;
}
} ) ;
boolean condition = ! TransactionSynchronizationManager . hasResource ( ds ) ;
assertThat ( condition ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
verify ( con , times ( count ) ) . releaseSavepoint ( sp ) ;
verify ( con ) . commit ( ) ;
verify ( con ) . close ( ) ;
@ -1489,36 +1386,30 @@ public class JdbcTransactionManagerTests {
@@ -1489,36 +1386,30 @@ public class JdbcTransactionManagerTests {
final TransactionTemplate tt = new TransactionTemplate ( tm ) ;
tt . setPropagationBehavior ( TransactionDefinition . PROPAGATION_NESTED ) ;
boolean condition2 = ! TransactionSynchronizationManager . hasResource ( ds ) ;
assertThat ( condition2 ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
boolean condition1 = ! TransactionSynchronizationManager . isSynchronizationActive ( ) ;
assertThat ( condition1 ) . as ( "Synchronization not active" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . isSynchronizationActive ( ) ) . as ( "Synchronization not active" ) . isTrue ( ) ;
tt . execute ( new TransactionCallbackWithoutResult ( ) {
@Override
protected void doInTransactionWithoutResult ( TransactionStatus status ) throws RuntimeException {
assertThat ( status . isNewTransaction ( ) ) . as ( "Is new transaction" ) . isTrue ( ) ;
boolean condition1 = ! status . hasSavepoint ( ) ;
assertThat ( condition1 ) . as ( "Isn't nested transaction" ) . isTrue ( ) ;
assertThat ( ! status . hasSavepoint ( ) ) . as ( "Isn't nested transaction" ) . isTrue ( ) ;
tt . execute ( new TransactionCallbackWithoutResult ( ) {
@Override
protected void doInTransactionWithoutResult ( TransactionStatus status ) throws RuntimeException {
assertThat ( TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Has thread connection" ) . isTrue ( ) ;
assertThat ( TransactionSynchronizationManager . isSynchronizationActive ( ) ) . as ( "Synchronization active" ) . isTrue ( ) ;
boolean condition = ! status . isNewTransaction ( ) ;
assertThat ( condition ) . as ( "Isn't new transaction" ) . isTrue ( ) ;
assertThat ( ! status . isNewTransaction ( ) ) . as ( "Isn't new transaction" ) . isTrue ( ) ;
assertThat ( status . hasSavepoint ( ) ) . as ( "Is nested transaction" ) . isTrue ( ) ;
status . setRollbackOnly ( ) ;
}
} ) ;
assertThat ( status . isNewTransaction ( ) ) . as ( "Is new transaction" ) . isTrue ( ) ;
boolean condition = ! status . hasSavepoint ( ) ;
assertThat ( condition ) . as ( "Isn't nested transaction" ) . isTrue ( ) ;
assertThat ( ! status . hasSavepoint ( ) ) . as ( "Isn't nested transaction" ) . isTrue ( ) ;
}
} ) ;
boolean condition = ! TransactionSynchronizationManager . hasResource ( ds ) ;
assertThat ( condition ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
verify ( con ) . rollback ( sp ) ;
verify ( con ) . releaseSavepoint ( sp ) ;
verify ( con ) . commit ( ) ;
@ -1536,25 +1427,21 @@ public class JdbcTransactionManagerTests {
@@ -1536,25 +1427,21 @@ public class JdbcTransactionManagerTests {
final TransactionTemplate tt = new TransactionTemplate ( tm ) ;
tt . setPropagationBehavior ( TransactionDefinition . PROPAGATION_NESTED ) ;
boolean condition2 = ! TransactionSynchronizationManager . hasResource ( ds ) ;
assertThat ( condition2 ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
boolean condition1 = ! TransactionSynchronizationManager . isSynchronizationActive ( ) ;
assertThat ( condition1 ) . as ( "Synchronization not active" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . isSynchronizationActive ( ) ) . as ( "Synchronization not active" ) . isTrue ( ) ;
tt . execute ( new TransactionCallbackWithoutResult ( ) {
@Override
protected void doInTransactionWithoutResult ( TransactionStatus status ) throws RuntimeException {
assertThat ( status . isNewTransaction ( ) ) . as ( "Is new transaction" ) . isTrue ( ) ;
boolean condition1 = ! status . hasSavepoint ( ) ;
assertThat ( condition1 ) . as ( "Isn't nested transaction" ) . isTrue ( ) ;
assertThat ( ! status . hasSavepoint ( ) ) . as ( "Isn't nested transaction" ) . isTrue ( ) ;
assertThatIllegalStateException ( ) . isThrownBy ( ( ) - >
tt . execute ( new TransactionCallbackWithoutResult ( ) {
@Override
protected void doInTransactionWithoutResult ( TransactionStatus status ) throws RuntimeException {
assertThat ( TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Has thread connection" ) . isTrue ( ) ;
assertThat ( TransactionSynchronizationManager . isSynchronizationActive ( ) ) . as ( "Synchronization active" ) . isTrue ( ) ;
boolean condition = ! status . isNewTransaction ( ) ;
assertThat ( condition ) . as ( "Isn't new transaction" ) . isTrue ( ) ;
assertThat ( ! status . isNewTransaction ( ) ) . as ( "Isn't new transaction" ) . isTrue ( ) ;
assertThat ( status . hasSavepoint ( ) ) . as ( "Is nested transaction" ) . isTrue ( ) ;
TransactionTemplate ntt = new TransactionTemplate ( tm ) ;
ntt . execute ( new TransactionCallbackWithoutResult ( ) {
@ -1562,23 +1449,19 @@ public class JdbcTransactionManagerTests {
@@ -1562,23 +1449,19 @@ public class JdbcTransactionManagerTests {
protected void doInTransactionWithoutResult ( TransactionStatus status ) throws RuntimeException {
assertThat ( TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Has thread connection" ) . isTrue ( ) ;
assertThat ( TransactionSynchronizationManager . isSynchronizationActive ( ) ) . as ( "Synchronization active" ) . isTrue ( ) ;
boolean condition1 = ! status . isNewTransaction ( ) ;
assertThat ( condition1 ) . as ( "Isn't new transaction" ) . isTrue ( ) ;
boolean condition = ! status . hasSavepoint ( ) ;
assertThat ( condition ) . as ( "Is regular transaction" ) . isTrue ( ) ;
assertThat ( ! status . isNewTransaction ( ) ) . as ( "Isn't new transaction" ) . isTrue ( ) ;
assertThat ( ! status . hasSavepoint ( ) ) . as ( "Is regular transaction" ) . isTrue ( ) ;
throw new IllegalStateException ( ) ;
}
} ) ;
}
} ) ) ;
assertThat ( status . isNewTransaction ( ) ) . as ( "Is new transaction" ) . isTrue ( ) ;
boolean condition = ! status . hasSavepoint ( ) ;
assertThat ( condition ) . as ( "Isn't nested transaction" ) . isTrue ( ) ;
assertThat ( ! status . hasSavepoint ( ) ) . as ( "Isn't nested transaction" ) . isTrue ( ) ;
}
} ) ;
boolean condition = ! TransactionSynchronizationManager . hasResource ( ds ) ;
assertThat ( condition ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
verify ( con ) . rollback ( sp ) ;
verify ( con ) . releaseSavepoint ( sp ) ;
verify ( con ) . commit ( ) ;
@ -1596,25 +1479,21 @@ public class JdbcTransactionManagerTests {
@@ -1596,25 +1479,21 @@ public class JdbcTransactionManagerTests {
final TransactionTemplate tt = new TransactionTemplate ( tm ) ;
tt . setPropagationBehavior ( TransactionDefinition . PROPAGATION_NESTED ) ;
boolean condition2 = ! TransactionSynchronizationManager . hasResource ( ds ) ;
assertThat ( condition2 ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
boolean condition1 = ! TransactionSynchronizationManager . isSynchronizationActive ( ) ;
assertThat ( condition1 ) . as ( "Synchronization not active" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . isSynchronizationActive ( ) ) . as ( "Synchronization not active" ) . isTrue ( ) ;
tt . execute ( new TransactionCallbackWithoutResult ( ) {
@Override
protected void doInTransactionWithoutResult ( TransactionStatus status ) throws RuntimeException {
assertThat ( status . isNewTransaction ( ) ) . as ( "Is new transaction" ) . isTrue ( ) ;
boolean condition1 = ! status . hasSavepoint ( ) ;
assertThat ( condition1 ) . as ( "Isn't nested transaction" ) . isTrue ( ) ;
assertThat ( ! status . hasSavepoint ( ) ) . as ( "Isn't nested transaction" ) . isTrue ( ) ;
assertThatExceptionOfType ( UnexpectedRollbackException . class ) . isThrownBy ( ( ) - >
tt . execute ( new TransactionCallbackWithoutResult ( ) {
@Override
protected void doInTransactionWithoutResult ( TransactionStatus status ) throws RuntimeException {
assertThat ( TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Has thread connection" ) . isTrue ( ) ;
assertThat ( TransactionSynchronizationManager . isSynchronizationActive ( ) ) . as ( "Synchronization active" ) . isTrue ( ) ;
boolean condition = ! status . isNewTransaction ( ) ;
assertThat ( condition ) . as ( "Isn't new transaction" ) . isTrue ( ) ;
assertThat ( ! status . isNewTransaction ( ) ) . as ( "Isn't new transaction" ) . isTrue ( ) ;
assertThat ( status . hasSavepoint ( ) ) . as ( "Is nested transaction" ) . isTrue ( ) ;
TransactionTemplate ntt = new TransactionTemplate ( tm ) ;
ntt . execute ( new TransactionCallbackWithoutResult ( ) {
@ -1622,23 +1501,19 @@ public class JdbcTransactionManagerTests {
@@ -1622,23 +1501,19 @@ public class JdbcTransactionManagerTests {
protected void doInTransactionWithoutResult ( TransactionStatus status ) throws RuntimeException {
assertThat ( TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Has thread connection" ) . isTrue ( ) ;
assertThat ( TransactionSynchronizationManager . isSynchronizationActive ( ) ) . as ( "Synchronization active" ) . isTrue ( ) ;
boolean condition1 = ! status . isNewTransaction ( ) ;
assertThat ( condition1 ) . as ( "Isn't new transaction" ) . isTrue ( ) ;
boolean condition = ! status . hasSavepoint ( ) ;
assertThat ( condition ) . as ( "Is regular transaction" ) . isTrue ( ) ;
assertThat ( ! status . isNewTransaction ( ) ) . as ( "Isn't new transaction" ) . isTrue ( ) ;
assertThat ( ! status . hasSavepoint ( ) ) . as ( "Is regular transaction" ) . isTrue ( ) ;
status . setRollbackOnly ( ) ;
}
} ) ;
}
} ) ) ;
assertThat ( status . isNewTransaction ( ) ) . as ( "Is new transaction" ) . isTrue ( ) ;
boolean condition = ! status . hasSavepoint ( ) ;
assertThat ( condition ) . as ( "Isn't nested transaction" ) . isTrue ( ) ;
assertThat ( ! status . hasSavepoint ( ) ) . as ( "Isn't nested transaction" ) . isTrue ( ) ;
}
} ) ;
boolean condition = ! TransactionSynchronizationManager . hasResource ( ds ) ;
assertThat ( condition ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
verify ( con ) . rollback ( sp ) ;
verify ( con ) . releaseSavepoint ( sp ) ;
verify ( con ) . commit ( ) ;
@ -1656,10 +1531,8 @@ public class JdbcTransactionManagerTests {
@@ -1656,10 +1531,8 @@ public class JdbcTransactionManagerTests {
final TransactionTemplate tt = new TransactionTemplate ( tm ) ;
tt . setPropagationBehavior ( TransactionDefinition . PROPAGATION_NESTED ) ;
boolean condition2 = ! TransactionSynchronizationManager . hasResource ( ds ) ;
assertThat ( condition2 ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
boolean condition1 = ! TransactionSynchronizationManager . isSynchronizationActive ( ) ;
assertThat ( condition1 ) . as ( "Synchronization not active" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . isSynchronizationActive ( ) ) . as ( "Synchronization not active" ) . isTrue ( ) ;
tt . execute ( new TransactionCallbackWithoutResult ( ) {
@Override
@ -1671,8 +1544,7 @@ public class JdbcTransactionManagerTests {
@@ -1671,8 +1544,7 @@ public class JdbcTransactionManagerTests {
}
} ) ;
boolean condition = ! TransactionSynchronizationManager . hasResource ( ds ) ;
assertThat ( condition ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
verify ( con ) . releaseSavepoint ( sp ) ;
verify ( con ) . commit ( ) ;
verify ( con ) . close ( ) ;
@ -1690,10 +1562,8 @@ public class JdbcTransactionManagerTests {
@@ -1690,10 +1562,8 @@ public class JdbcTransactionManagerTests {
final TransactionTemplate tt = new TransactionTemplate ( tm ) ;
tt . setPropagationBehavior ( TransactionDefinition . PROPAGATION_NESTED ) ;
boolean condition2 = ! TransactionSynchronizationManager . hasResource ( ds ) ;
assertThat ( condition2 ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
boolean condition1 = ! TransactionSynchronizationManager . isSynchronizationActive ( ) ;
assertThat ( condition1 ) . as ( "Synchronization not active" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . isSynchronizationActive ( ) ) . as ( "Synchronization not active" ) . isTrue ( ) ;
tt . execute ( new TransactionCallbackWithoutResult ( ) {
@Override
@ -1705,8 +1575,7 @@ public class JdbcTransactionManagerTests {
@@ -1705,8 +1575,7 @@ public class JdbcTransactionManagerTests {
}
} ) ;
boolean condition = ! TransactionSynchronizationManager . hasResource ( ds ) ;
assertThat ( condition ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
verify ( con ) . rollback ( sp ) ;
verify ( con ) . commit ( ) ;
verify ( con ) . close ( ) ;
@ -1716,10 +1585,8 @@ public class JdbcTransactionManagerTests {
@@ -1716,10 +1585,8 @@ public class JdbcTransactionManagerTests {
public void testTransactionWithPropagationNested ( ) throws Exception {
final TransactionTemplate tt = new TransactionTemplate ( tm ) ;
tt . setPropagationBehavior ( TransactionDefinition . PROPAGATION_NESTED ) ;
boolean condition2 = ! TransactionSynchronizationManager . hasResource ( ds ) ;
assertThat ( condition2 ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
boolean condition1 = ! TransactionSynchronizationManager . isSynchronizationActive ( ) ;
assertThat ( condition1 ) . as ( "Synchronization not active" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . isSynchronizationActive ( ) ) . as ( "Synchronization not active" ) . isTrue ( ) ;
tt . execute ( new TransactionCallbackWithoutResult ( ) {
@Override
@ -1728,8 +1595,7 @@ public class JdbcTransactionManagerTests {
@@ -1728,8 +1595,7 @@ public class JdbcTransactionManagerTests {
}
} ) ;
boolean condition = ! TransactionSynchronizationManager . hasResource ( ds ) ;
assertThat ( condition ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
verify ( con ) . commit ( ) ;
verify ( con ) . close ( ) ;
}
@ -1738,10 +1604,8 @@ public class JdbcTransactionManagerTests {
@@ -1738,10 +1604,8 @@ public class JdbcTransactionManagerTests {
public void testTransactionWithPropagationNestedAndRollback ( ) throws Exception {
final TransactionTemplate tt = new TransactionTemplate ( tm ) ;
tt . setPropagationBehavior ( TransactionDefinition . PROPAGATION_NESTED ) ;
boolean condition2 = ! TransactionSynchronizationManager . hasResource ( ds ) ;
assertThat ( condition2 ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
boolean condition1 = ! TransactionSynchronizationManager . isSynchronizationActive ( ) ;
assertThat ( condition1 ) . as ( "Synchronization not active" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . isSynchronizationActive ( ) ) . as ( "Synchronization not active" ) . isTrue ( ) ;
tt . execute ( new TransactionCallbackWithoutResult ( ) {
@Override
@ -1751,8 +1615,7 @@ public class JdbcTransactionManagerTests {
@@ -1751,8 +1615,7 @@ public class JdbcTransactionManagerTests {
}
} ) ;
boolean condition = ! TransactionSynchronizationManager . hasResource ( ds ) ;
assertThat ( condition ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
assertThat ( ! TransactionSynchronizationManager . hasResource ( ds ) ) . as ( "Hasn't thread connection" ) . isTrue ( ) ;
verify ( con ) . rollback ( ) ;
verify ( con ) . close ( ) ;
}