@@ -859,6 +859,7 @@ protected void doInTransactionWithoutResult(TransactionStatus status) throws Run
859859 public void testTransactionWithIsolationAndReadOnly () throws Exception {
860860 given (con .getTransactionIsolation ()).willReturn (Connection .TRANSACTION_READ_COMMITTED );
861861 given (con .getAutoCommit ()).willReturn (true );
862+ given (con .isReadOnly ()).willReturn (true );
862863
863864 TransactionTemplate tt = new TransactionTemplate (tm );
864865 tt .setPropagationBehavior (TransactionDefinition .PROPAGATION_REQUIRES_NEW );
@@ -876,11 +877,13 @@ protected void doInTransactionWithoutResult(TransactionStatus status) {
876877
877878 assertTrue ("Hasn't thread connection" , !TransactionSynchronizationManager .hasResource (ds ));
878879 InOrder ordered = inOrder (con );
880+ ordered .verify (con ).setReadOnly (true );
879881 ordered .verify (con ).setTransactionIsolation (Connection .TRANSACTION_SERIALIZABLE );
880882 ordered .verify (con ).setAutoCommit (false );
881883 ordered .verify (con ).commit ();
882884 ordered .verify (con ).setAutoCommit (true );
883885 ordered .verify (con ).setTransactionIsolation (Connection .TRANSACTION_READ_COMMITTED );
886+ ordered .verify (con ).setReadOnly (false );
884887 verify (con ).close ();
885888 }
886889
@@ -891,6 +894,7 @@ public void testTransactionWithEnforceReadOnly() throws Exception {
891894 given (con .getAutoCommit ()).willReturn (true );
892895 Statement stmt = mock (Statement .class );
893896 given (con .createStatement ()).willReturn (stmt );
897+ given (con .isReadOnly ()).willReturn (true );
894898
895899 TransactionTemplate tt = new TransactionTemplate (tm );
896900 tt .setPropagationBehavior (TransactionDefinition .PROPAGATION_REQUIRES_NEW );
@@ -907,11 +911,13 @@ protected void doInTransactionWithoutResult(TransactionStatus status) {
907911
908912 assertTrue ("Hasn't thread connection" , !TransactionSynchronizationManager .hasResource (ds ));
909913 InOrder ordered = inOrder (con , stmt );
914+ ordered .verify (con ).setReadOnly (true );
910915 ordered .verify (con ).setAutoCommit (false );
911916 ordered .verify (stmt ).executeUpdate ("SET TRANSACTION READ ONLY" );
912917 ordered .verify (stmt ).close ();
913918 ordered .verify (con ).commit ();
914919 ordered .verify (con ).setAutoCommit (true );
920+ ordered .verify (con ).setReadOnly (false );
915921 ordered .verify (con ).close ();
916922 }
917923
0 commit comments