diff --git a/example/src/test/java/io/mycat/assemble/SetTranscationTest.java b/example/src/test/java/io/mycat/assemble/SetTranscationTest.java new file mode 100644 index 000000000..38d4f8d66 --- /dev/null +++ b/example/src/test/java/io/mycat/assemble/SetTranscationTest.java @@ -0,0 +1,36 @@ +package io.mycat.assemble; + +import io.mycat.hint.CreateDataSourceHint; +import io.mycat.hint.CreateTableHint; +import lombok.SneakyThrows; +import org.junit.Assert; +import org.junit.Test; + +import javax.annotation.concurrent.NotThreadSafe; +import java.sql.Connection; +import java.util.List; +import java.util.Map; + +@NotThreadSafe +@net.jcip.annotations.NotThreadSafe +public class SetTranscationTest implements MycatTest { + + @Test + @SneakyThrows + public void test() { + try (Connection mycat = getMySQLConnection(DB_MYCAT);) { + execute(mycat, RESET_CONFIG); + List> maps; + execute(mycat, "SET SESSION TRANSACTION READ WRITE"); + maps = executeQuery(mycat, " SELECT @@session.transaction_read_only"); + Assert.assertTrue(maps.toString().contains("0")); + execute(mycat, "SET SESSION TRANSACTION READ only"); + maps = executeQuery(mycat, " SELECT @@session.transaction_read_only"); + Assert.assertTrue(maps.toString().contains("1")); + execute(mycat, "SET SESSION TRANSACTION READ WRITE"); + maps = executeQuery(mycat, " SELECT @@session.transaction_read_only"); + Assert.assertTrue(maps.toString().contains("0")); + } + } + +} \ No newline at end of file