|
|
|
|
@ -859,6 +859,7 @@ public class DataSourceTransactionManagerTests {
@@ -859,6 +859,7 @@ public class DataSourceTransactionManagerTests {
|
|
|
|
|
public void testTransactionWithIsolationAndReadOnly() throws Exception { |
|
|
|
|
given(con.getTransactionIsolation()).willReturn(Connection.TRANSACTION_READ_COMMITTED); |
|
|
|
|
given(con.getAutoCommit()).willReturn(true); |
|
|
|
|
given(con.isReadOnly()).willReturn(true); |
|
|
|
|
|
|
|
|
|
TransactionTemplate tt = new TransactionTemplate(tm); |
|
|
|
|
tt.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW); |
|
|
|
|
@ -876,11 +877,13 @@ public class DataSourceTransactionManagerTests {
@@ -876,11 +877,13 @@ public class DataSourceTransactionManagerTests {
|
|
|
|
|
|
|
|
|
|
assertTrue("Hasn't thread connection", !TransactionSynchronizationManager.hasResource(ds)); |
|
|
|
|
InOrder ordered = inOrder(con); |
|
|
|
|
ordered.verify(con).setReadOnly(true); |
|
|
|
|
ordered.verify(con).setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE); |
|
|
|
|
ordered.verify(con).setAutoCommit(false); |
|
|
|
|
ordered.verify(con).commit(); |
|
|
|
|
ordered.verify(con).setAutoCommit(true); |
|
|
|
|
ordered.verify(con).setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED); |
|
|
|
|
ordered.verify(con).setReadOnly(false); |
|
|
|
|
verify(con).close(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -891,6 +894,7 @@ public class DataSourceTransactionManagerTests {
@@ -891,6 +894,7 @@ public class DataSourceTransactionManagerTests {
|
|
|
|
|
given(con.getAutoCommit()).willReturn(true); |
|
|
|
|
Statement stmt = mock(Statement.class); |
|
|
|
|
given(con.createStatement()).willReturn(stmt); |
|
|
|
|
given(con.isReadOnly()).willReturn(true); |
|
|
|
|
|
|
|
|
|
TransactionTemplate tt = new TransactionTemplate(tm); |
|
|
|
|
tt.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW); |
|
|
|
|
@ -907,11 +911,13 @@ public class DataSourceTransactionManagerTests {
@@ -907,11 +911,13 @@ public class DataSourceTransactionManagerTests {
|
|
|
|
|
|
|
|
|
|
assertTrue("Hasn't thread connection", !TransactionSynchronizationManager.hasResource(ds)); |
|
|
|
|
InOrder ordered = inOrder(con, stmt); |
|
|
|
|
ordered.verify(con).setReadOnly(true); |
|
|
|
|
ordered.verify(con).setAutoCommit(false); |
|
|
|
|
ordered.verify(stmt).executeUpdate("SET TRANSACTION READ ONLY"); |
|
|
|
|
ordered.verify(stmt).close(); |
|
|
|
|
ordered.verify(con).commit(); |
|
|
|
|
ordered.verify(con).setAutoCommit(true); |
|
|
|
|
ordered.verify(con).setReadOnly(false); |
|
|
|
|
ordered.verify(con).close(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|