提交 b9de50b7 authored 作者: Thomas Mueller's avatar Thomas Mueller

Tests

上级 4825106c
...@@ -21,6 +21,7 @@ import java.util.List; ...@@ -21,6 +21,7 @@ import java.util.List;
import java.util.Random; import java.util.Random;
import org.h2.api.ErrorCode; import org.h2.api.ErrorCode;
import org.h2.engine.Constants;
import org.h2.store.fs.FileUtils; import org.h2.store.fs.FileUtils;
import org.h2.test.TestBase; import org.h2.test.TestBase;
...@@ -932,20 +933,22 @@ public class TestCases extends TestBase { ...@@ -932,20 +933,22 @@ public class TestCases extends TestBase {
ResultSet rs; ResultSet rs;
// test the default (SIGNED) // test the default (SIGNED)
stat.execute("create table bin( x binary(1) );"); if (Constants.VERSION_MINOR < 4) {
stat.execute("insert into bin(x) values (x'09'),(x'0a'),(x'99'),(x'aa');"); stat.execute("create table bin( x binary(1) );");
rs = stat.executeQuery("select * from bin order by x;"); stat.execute("insert into bin(x) values (x'09'),(x'0a'),(x'99'),(x'aa');");
rs.next(); rs = stat.executeQuery("select * from bin order by x;");
assertEquals("99", rs.getString(1)); rs.next();
rs.next(); assertEquals("99", rs.getString(1));
assertEquals("aa", rs.getString(1)); rs.next();
rs.next(); assertEquals("aa", rs.getString(1));
assertEquals("09", rs.getString(1)); rs.next();
rs.next(); assertEquals("09", rs.getString(1));
assertEquals("0a", rs.getString(1)); rs.next();
assertEquals("0a", rs.getString(1));
stat.execute("drop table bin");
}
// test UNSIGNED mode // test UNSIGNED mode
stat.execute("drop table bin");
stat.execute("SET BINARY_COLLATION UNSIGNED"); stat.execute("SET BINARY_COLLATION UNSIGNED");
stat.execute("create table bin( x binary(1) );"); stat.execute("create table bin( x binary(1) );");
stat.execute("insert into bin(x) values (x'09'),(x'0a'),(x'99'),(x'aa');"); stat.execute("insert into bin(x) values (x'09'),(x'0a'),(x'99'),(x'aa');");
......
...@@ -155,6 +155,7 @@ public class TestFunctions extends TestBase implements AggregateFunction { ...@@ -155,6 +155,7 @@ public class TestFunctions extends TestBase implements AggregateFunction {
/** /**
* This method is called via reflection from the database. * This method is called via reflection from the database.
* *
* @param values the value array
* @return a result set * @return a result set
*/ */
public static ResultSet varArgsFunctionTable(int... values) throws SQLException { public static ResultSet varArgsFunctionTable(int... values) throws SQLException {
......
...@@ -1126,7 +1126,7 @@ public class TestMVStore extends TestBase { ...@@ -1126,7 +1126,7 @@ public class TestMVStore extends TestBase {
map.put(1, "Hi"); map.put(1, "Hi");
map.remove(2); map.remove(2);
// access the old data (before incrementVersion) // access the old data (before the commit)
MVMap<Integer, String> oldMap = MVMap<Integer, String> oldMap =
map.openVersion(oldVersion); map.openVersion(oldVersion);
......
...@@ -713,7 +713,7 @@ public class TestMVTableEngine extends TestBase { ...@@ -713,7 +713,7 @@ public class TestMVTableEngine extends TestBase {
private void testExclusiveLock() throws Exception { private void testExclusiveLock() throws Exception {
FileUtils.deleteRecursive(getBaseDir(), true); FileUtils.deleteRecursive(getBaseDir(), true);
String dbName = "mvstore;MV_STORE=TRUE"; String dbName = "mvstore;MV_STORE=TRUE;MVCC=FALSE";
Connection conn, conn2; Connection conn, conn2;
Statement stat, stat2; Statement stat, stat2;
conn = getConnection(dbName); conn = getConnection(dbName);
...@@ -943,7 +943,7 @@ public class TestMVTableEngine extends TestBase { ...@@ -943,7 +943,7 @@ public class TestMVTableEngine extends TestBase {
private void testLocking() throws Exception { private void testLocking() throws Exception {
FileUtils.deleteRecursive(getBaseDir(), true); FileUtils.deleteRecursive(getBaseDir(), true);
String dbName = "mvstore;MV_STORE=TRUE"; String dbName = "mvstore;MV_STORE=TRUE;MVCC=FALSE";
Connection conn = getConnection(dbName); Connection conn = getConnection(dbName);
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
stat.execute("set lock_timeout 1000"); stat.execute("set lock_timeout 1000");
......
...@@ -79,8 +79,13 @@ public class TestJmx extends TestBase { ...@@ -79,8 +79,13 @@ public class TestJmx extends TestBase {
getAttribute(name, "Mode").toString()); getAttribute(name, "Mode").toString());
assertEquals("false", mbeanServer. assertEquals("false", mbeanServer.
getAttribute(name, "MultiThreaded").toString()); getAttribute(name, "MultiThreaded").toString());
assertEquals("false", mbeanServer. if (config.mvStore) {
getAttribute(name, "Mvcc").toString()); assertEquals("true", mbeanServer.
getAttribute(name, "Mvcc").toString());
} else {
assertEquals("false", mbeanServer.
getAttribute(name, "Mvcc").toString());
}
assertEquals("false", mbeanServer. assertEquals("false", mbeanServer.
getAttribute(name, "ReadOnly").toString()); getAttribute(name, "ReadOnly").toString());
assertEquals("1", mbeanServer. assertEquals("1", mbeanServer.
...@@ -100,7 +105,11 @@ public class TestJmx extends TestBase { ...@@ -100,7 +105,11 @@ public class TestJmx extends TestBase {
result = mbeanServer.invoke(name, "listSessions", null, null).toString(); result = mbeanServer.invoke(name, "listSessions", null, null).toString();
assertTrue(result.indexOf("session id") >= 0); assertTrue(result.indexOf("session id") >= 0);
assertTrue(result.indexOf("write lock") >= 0); if (config.mvcc) {
assertTrue(result.indexOf("read lock") >= 0);
} else {
assertTrue(result.indexOf("write lock") >= 0);
}
assertEquals(2, info.getOperations().length); assertEquals(2, info.getOperations().length);
assertTrue(info.getDescription().indexOf("database") >= 0); assertTrue(info.getDescription().indexOf("database") >= 0);
......
...@@ -116,9 +116,6 @@ public class TestReopen extends TestBase implements Recorder { ...@@ -116,9 +116,6 @@ public class TestReopen extends TestBase implements Recorder {
p.setProperty("password", getPassword()); p.setProperty("password", getPassword());
String url = "jdbc:h2:" + testDatabase + String url = "jdbc:h2:" + testDatabase +
";FILE_LOCK=NO;TRACE_LEVEL_FILE=0"; ";FILE_LOCK=NO;TRACE_LEVEL_FILE=0";
if (config.mvStore) {
url += ";MV_STORE=TRUE";
}
ConnectionInfo ci = new ConnectionInfo(url, p); ConnectionInfo ci = new ConnectionInfo(url, p);
Database database = new Database(ci, null); Database database = new Database(ci, null);
// close the database // close the database
...@@ -170,9 +167,6 @@ public class TestReopen extends TestBase implements Recorder { ...@@ -170,9 +167,6 @@ public class TestReopen extends TestBase implements Recorder {
// avoid using the Engine class to avoid deadlocks // avoid using the Engine class to avoid deadlocks
Properties p = new Properties(); Properties p = new Properties();
String url = "jdbc:h2:" + testDatabase + ";FILE_LOCK=NO"; String url = "jdbc:h2:" + testDatabase + ";FILE_LOCK=NO";
if (config.mvStore) {
url += ";MV_STORE=TRUE";
}
ConnectionInfo ci = new ConnectionInfo(url, p); ConnectionInfo ci = new ConnectionInfo(url, p);
Database database = new Database(ci, null); Database database = new Database(ci, null);
// close the database // close the database
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论