Skip to content

Commit

Permalink
add SetTranscationTest
Browse files Browse the repository at this point in the history
  • Loading branch information
junwen12221 committed Aug 17, 2021
1 parent edf0c54 commit a8490ef
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions example/src/test/java/io/mycat/assemble/SetTranscationTest.java
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"));
}
}

}

0 comments on commit a8490ef

Please sign in to comment.