-
Notifications
You must be signed in to change notification settings - Fork 479
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
edf0c54
commit a8490ef
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
example/src/test/java/io/mycat/assemble/SetTranscationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Map<String, Object>> 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")); | ||
} | ||
} | ||
|
||
} |