@@ -241,11 +241,14 @@ public void testBeginTransactionReadOnly() {
241241 awaitUpdate (1 , sessionB .createStatement (
242242 "INSERT INTO testBeginTransactionReadOnly VALUES ('b')" ));
243243
244- // Begin a READ ONLY transaction with sessionA and expect a query result
245- // having only the committed row, and not the uncomitted row
244+ // Begin a READ ONLY transaction with sessionA. Expect
245+ // getTransactionIsolationLevel to return SERIALIZABLE as read-only
246+ // transactions have the same behavior. Expect a query result
247+ // having only the committed row, and not the uncommitted row
246248 awaitNone (sessionA .commitTransaction ());
247249 awaitNone (sessionA .beginTransaction (transactionDefinition (Map .of (
248250 READ_ONLY , true ))));
251+ assertEquals (SERIALIZABLE , sessionA .getTransactionIsolationLevel ());
249252 awaitQuery (List .of ("a" ), row -> row .get (0 , String .class ),
250253 sessionA .createStatement (
251254 "SELECT value FROM testBeginTransactionReadOnly" ));
@@ -288,6 +291,12 @@ public void testBeginTransactionReadWrite() {
288291 verifyReadCommittedIsolation (connection , () ->
289292 connection .beginTransaction (transactionDefinition (Map .of (
290293 READ_ONLY , false ))));
294+
295+ // Expect read write transactions to have the session's isolation level
296+ awaitNone (connection .setTransactionIsolationLevel (SERIALIZABLE ));
297+ verifySerializableIsolation (connection , () ->
298+ connection .beginTransaction (transactionDefinition (Map .of (
299+ READ_ONLY , false ))));
291300 }
292301 finally {
293302 tryAwaitNone (connection .close ());
@@ -367,6 +376,7 @@ private static void verifyReadCommittedIsolation(
367376 sessionA .isAutoCommit (),
368377 "Unexpected return value from isAutoCommit() after" +
369378 " beginTransaction()" );
379+ assertEquals (READ_COMMITTED , sessionA .getTransactionIsolationLevel ());
370380 awaitUpdate (1 , sessionA .createStatement (
371381 "INSERT INTO verifyReadCommittedIsolation VALUES ('A')" ));
372382
@@ -455,6 +465,7 @@ private static void verifySerializableIsolation(
455465 sessionA .isAutoCommit (),
456466 "Unexpected return value from isAutoCommit() after" +
457467 " beginTransaction()" );
468+ assertEquals (SERIALIZABLE , sessionA .getTransactionIsolationLevel ());
458469 awaitUpdate (1 , sessionA .createStatement (
459470 "INSERT INTO verifySerializableIsolation VALUES ('A')" ));
460471
@@ -1018,7 +1029,25 @@ public void testGetTransactionIsolationLevel() {
10181029 "Unexpected return value of getTransactionIsolationLevel() for a" +
10191030 " newly created connection" );
10201031
1021- // TODO: Verify serializable
1032+
1033+ // Begin a transaction with a different level that what was passed to
1034+ // setTransactionIsolationLevel. Expect the getter to return the level
1035+ // of the current transaction
1036+ awaitNone (connection .beginTransaction (SERIALIZABLE ));
1037+ assertEquals (SERIALIZABLE , connection .getTransactionIsolationLevel ());
1038+
1039+ // End the transaction and expect the getter to return the setter value
1040+ awaitNone (connection .commitTransaction ());
1041+ assertEquals (READ_COMMITTED , connection .getTransactionIsolationLevel ());
1042+
1043+ // Set the level and expect the getter to return it
1044+ awaitNone (connection .setTransactionIsolationLevel (SERIALIZABLE ));
1045+ assertEquals (SERIALIZABLE , connection .getTransactionIsolationLevel ());
1046+
1047+ // Begin a READ ONLY transaction, expect the READ COMMITTED ISOLATION
1048+ // level.
1049+ //TODO
1050+
10221051 }
10231052 finally {
10241053 tryAwaitNone (connection .close ());
0 commit comments