提交 af115114 authored 作者: Noel Grandin's avatar Noel Grandin

fix PgServer unit test

when run in memory mode, the initial connection used a memory DB,while
the second connection used a disk DB
上级 6433d2c7
...@@ -1047,6 +1047,7 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1` ...@@ -1047,6 +1047,7 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1`
appendIf(buff, memory, "memory"); appendIf(buff, memory, "memory");
appendIf(buff, codeCoverage, "codeCoverage"); appendIf(buff, codeCoverage, "codeCoverage");
appendIf(buff, mvcc, "mvcc"); appendIf(buff, mvcc, "mvcc");
appendIf(buff, multiThreaded, "multiThreaded");
appendIf(buff, cipher != null, cipher); appendIf(buff, cipher != null, cipher);
appendIf(buff, cacheType != null, cacheType); appendIf(buff, cacheType != null, cacheType);
appendIf(buff, smallLog, "smallLog"); appendIf(buff, smallLog, "smallLog");
......
...@@ -41,6 +41,10 @@ public class TestPgServer extends TestBase { ...@@ -41,6 +41,10 @@ public class TestPgServer extends TestBase {
@Override @Override
public void test() throws Exception { public void test() throws Exception {
config.multiThreaded = true;
config.memory = true;
config.mvStore = true;
config.mvcc = true;
testLowerCaseIdentifiers(); testLowerCaseIdentifiers();
testPgAdapter(); testPgAdapter();
testKeyAlias(); testKeyAlias();
...@@ -54,18 +58,18 @@ public class TestPgServer extends TestBase { ...@@ -54,18 +58,18 @@ public class TestPgServer extends TestBase {
if (!getPgJdbcDriver()) { if (!getPgJdbcDriver()) {
return; return;
} }
deleteDb("test"); deleteDb("pgserver");
Connection conn = getConnection( Connection conn = getConnection(
"test;DATABASE_TO_UPPER=false", "sa", "sa"); "mem:pgserver;DATABASE_TO_UPPER=false", "sa", "sa");
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
stat.execute("create table test(id int, name varchar(255))"); stat.execute("create table test(id int, name varchar(255))");
Server server = Server.createPgServer( Server server = Server.createPgServer(
"-baseDir", getBaseDir(), "-pgPort", "5535", "-pgDaemon"); "-baseDir", getBaseDir(), "-pgPort", "5535", "-pgDaemon", "-key", "pgserver", "mem:pgserver");
server.start(); server.start();
try { try {
Connection conn2; Connection conn2;
conn2 = DriverManager.getConnection( conn2 = DriverManager.getConnection(
"jdbc:postgresql://localhost:5535/test", "sa", "sa"); "jdbc:postgresql://localhost:5535/pgserver", "sa", "sa");
stat = conn2.createStatement(); stat = conn2.createStatement();
stat.execute("select * from test"); stat.execute("select * from test");
conn2.close(); conn2.close();
...@@ -73,7 +77,7 @@ public class TestPgServer extends TestBase { ...@@ -73,7 +77,7 @@ public class TestPgServer extends TestBase {
server.stop(); server.stop();
} }
conn.close(); conn.close();
deleteDb("test"); deleteDb("pgserver");
} }
private boolean getPgJdbcDriver() { private boolean getPgJdbcDriver() {
...@@ -87,7 +91,7 @@ public class TestPgServer extends TestBase { ...@@ -87,7 +91,7 @@ public class TestPgServer extends TestBase {
} }
private void testPgAdapter() throws SQLException { private void testPgAdapter() throws SQLException {
deleteDb("test"); deleteDb("pgserver");
Server server = Server.createPgServer( Server server = Server.createPgServer(
"-baseDir", getBaseDir(), "-pgPort", "5535", "-pgDaemon"); "-baseDir", getBaseDir(), "-pgPort", "5535", "-pgDaemon");
assertEquals(5535, server.getPort()); assertEquals(5535, server.getPort());
...@@ -109,13 +113,13 @@ public class TestPgServer extends TestBase { ...@@ -109,13 +113,13 @@ public class TestPgServer extends TestBase {
} }
Server server = Server.createPgServer( Server server = Server.createPgServer(
"-pgPort", "5535", "-pgDaemon", "-key", "test", "mem:test"); "-pgPort", "5535", "-pgDaemon", "-key", "pgserver", "mem:pgserver");
server.start(); server.start();
ExecutorService executor = Executors.newSingleThreadExecutor(); ExecutorService executor = Executors.newSingleThreadExecutor();
try { try {
Connection conn = DriverManager.getConnection( Connection conn = DriverManager.getConnection(
"jdbc:postgresql://localhost:5535/test", "sa", "sa"); "jdbc:postgresql://localhost:5535/pgserver", "sa", "sa");
final Statement stat = conn.createStatement(); final Statement stat = conn.createStatement();
stat.execute("create alias sleep for \"java.lang.Thread.sleep\""); stat.execute("create alias sleep for \"java.lang.Thread.sleep\"");
...@@ -149,12 +153,12 @@ public class TestPgServer extends TestBase { ...@@ -149,12 +153,12 @@ public class TestPgServer extends TestBase {
server.stop(); server.stop();
executor.shutdown(); executor.shutdown();
} }
deleteDb("test"); deleteDb("pgserver");
} }
private void testPgClient() throws SQLException { private void testPgClient() throws SQLException {
Connection conn = DriverManager.getConnection( Connection conn = DriverManager.getConnection(
"jdbc:postgresql://localhost:5535/test", "sa", "sa"); "jdbc:postgresql://localhost:5535/pgserver", "sa", "sa");
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
assertThrows(SQLException.class, stat). assertThrows(SQLException.class, stat).
execute("select ***"); execute("select ***");
...@@ -166,7 +170,7 @@ public class TestPgServer extends TestBase { ...@@ -166,7 +170,7 @@ public class TestPgServer extends TestBase {
conn.close(); conn.close();
conn = DriverManager.getConnection( conn = DriverManager.getConnection(
"jdbc:postgresql://localhost:5535/test", "test", "test"); "jdbc:postgresql://localhost:5535/pgserver", "test", "test");
stat = conn.createStatement(); stat = conn.createStatement();
ResultSet rs; ResultSet rs;
...@@ -336,11 +340,11 @@ public class TestPgServer extends TestBase { ...@@ -336,11 +340,11 @@ public class TestPgServer extends TestBase {
return; return;
} }
Server server = Server.createPgServer( Server server = Server.createPgServer(
"-pgPort", "5535", "-pgDaemon", "-key", "test", "mem:test"); "-pgPort", "5535", "-pgDaemon", "-key", "pgserver", "mem:pgserver");
server.start(); server.start();
try { try {
Connection conn = DriverManager.getConnection( Connection conn = DriverManager.getConnection(
"jdbc:postgresql://localhost:5535/test", "sa", "sa"); "jdbc:postgresql://localhost:5535/pgserver", "sa", "sa");
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
// confirm that we've got the in memory implementation // confirm that we've got the in memory implementation
...@@ -364,7 +368,7 @@ public class TestPgServer extends TestBase { ...@@ -364,7 +368,7 @@ public class TestPgServer extends TestBase {
} }
Server server = Server.createPgServer( Server server = Server.createPgServer(
"-pgPort", "5535", "-pgDaemon", "-key", "test", "mem:test"); "-pgPort", "5535", "-pgDaemon", "-key", "pgserver", "mem:pgserver");
server.start(); server.start();
try { try {
Properties props = new Properties(); Properties props = new Properties();
...@@ -374,7 +378,7 @@ public class TestPgServer extends TestBase { ...@@ -374,7 +378,7 @@ public class TestPgServer extends TestBase {
props.setProperty("prepareThreshold", "-1"); props.setProperty("prepareThreshold", "-1");
Connection conn = DriverManager.getConnection( Connection conn = DriverManager.getConnection(
"jdbc:postgresql://localhost:5535/test", props); "jdbc:postgresql://localhost:5535/pgserver", props);
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
stat.execute( stat.execute(
...@@ -422,7 +426,7 @@ public class TestPgServer extends TestBase { ...@@ -422,7 +426,7 @@ public class TestPgServer extends TestBase {
} }
Server server = Server.createPgServer( Server server = Server.createPgServer(
"-pgPort", "5535", "-pgDaemon", "-key", "test", "mem:test"); "-pgPort", "5535", "-pgDaemon", "-key", "pgserver", "mem:pgserver");
server.start(); server.start();
try { try {
Properties props = new Properties(); Properties props = new Properties();
...@@ -433,7 +437,7 @@ public class TestPgServer extends TestBase { ...@@ -433,7 +437,7 @@ public class TestPgServer extends TestBase {
props.setProperty("prepareThreshold", "1"); props.setProperty("prepareThreshold", "1");
Connection conn = DriverManager.getConnection( Connection conn = DriverManager.getConnection(
"jdbc:postgresql://localhost:5535/test", props); "jdbc:postgresql://localhost:5535/pgserver", props);
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
stmt.executeUpdate("create table t1 (id integer, value timestamp)"); stmt.executeUpdate("create table t1 (id integer, value timestamp)");
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论