From a8490ef349abb7ff746803b2209be16df381fea4 Mon Sep 17 00:00:00 2001 From: jamie Date: Tue, 17 Aug 2021 22:53:38 +0800 Subject: [PATCH] add SetTranscationTest --- .../io/mycat/assemble/SetTranscationTest.java | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 example/src/test/java/io/mycat/assemble/SetTranscationTest.java 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