提交 2e98e3f4 authored 作者: Thomas Mueller's avatar Thomas Mueller

More / fixed test cases.

上级 8e7003d9
......@@ -42,12 +42,14 @@ public class TestMemoryUsage extends TestBase {
testCreateIndex();
testClob();
testReconnectOften();
deleteDb("memoryUsage");
reconnect();
insertUpdateSelectDelete();
reconnect();
insertUpdateSelectDelete();
conn.close();
deleteDb("memoryUsage");
}
......@@ -68,21 +70,36 @@ public class TestMemoryUsage extends TestBase {
}
private void testCreateDropLoop() throws SQLException {
deleteDb("memoryUsage");
conn = getConnection("memoryUsage");
deleteDb("memoryUsageCreateDropLoop");
conn = getConnection("memoryUsageCreateDropLoop");
Statement stat = conn.createStatement();
for (int i = 0; i < 100; i++) {
stat.execute("CREATE TABLE TEST(ID INT)");
stat.execute("DROP TABLE TEST");
}
stat.execute("checkpoint");
int used = Utils.getMemoryUsed();
for (int i = 0; i < 1000; i++) {
stat.execute("CREATE TABLE TEST(ID INT PRIMARY KEY)");
stat.execute("DROP TABLE TEST");
}
stat.execute("checkpoint");
int usedNow = Utils.getMemoryUsed();
if (usedNow > used * 1.3) {
assertEquals(used, usedNow);
// try to lower memory usage (because it might be wrong)
// by forcing OOME
for (int i = 1024;; i *= 2) {
try {
byte[] oome = new byte[1024 * 1024 * 256];
oome[0] = (byte) i;
} catch (OutOfMemoryError e) {
break;
}
}
usedNow = Utils.getMemoryUsed();
if (usedNow > used * 1.3) {
assertEquals(used, usedNow);
}
}
conn.close();
}
......@@ -101,8 +118,8 @@ public class TestMemoryUsage extends TestBase {
if (config.memory || !config.big) {
return;
}
deleteDb("memoryUsage");
conn = getConnection("memoryUsage");
deleteDb("memoryUsageClob");
conn = getConnection("memoryUsageClob");
Statement stat = conn.createStatement();
stat.execute("SET MAX_LENGTH_INPLACE_LOB 8192");
stat.execute("SET CACHE_SIZE 8000");
......
......@@ -80,7 +80,7 @@ public class TestOptimizations extends TestBase {
testConvertOrToIn();
deleteDb("optimizations");
}
private void testIdentityIndexUsage() throws Exception {
Connection conn = getConnection("optimizations");
Statement stat = conn.createStatement();
......
......@@ -88,6 +88,7 @@ public class TestSpatial extends TestBase {
testInPlaceUpdate();
testScanIndexOnNonSpatialQuery();
testStoreCorruption();
testExplainSpatialIndexWithPk();
}
private void testHashCode() {
......@@ -881,4 +882,32 @@ public class TestSpatial extends TestBase {
}
deleteDb("spatial");
}
private void testExplainSpatialIndexWithPk() throws SQLException {
deleteDb("spatial");
Connection conn = getConnection(url);
try {
Statement stat = conn.createStatement();
stat.execute("drop table if exists pt_cloud;");
stat.execute("CREATE TABLE PT_CLOUD(id serial, the_geom geometry) AS"
+ " SELECT null, CONCAT('POINT(',A.X,' ',B.X,')')::geometry the_geom "
+ "from system_range(0,120) A,system_range(0,10) B;");
stat.execute("create spatial index on pt_cloud(the_geom);");
ResultSet rs = stat.executeQuery(
"explain select * from PT_CLOUD " +
"where the_geom && 'POINT(1 1)'");
try {
assertTrue(rs.next());
assertFalse("H2 should use spatial index got this explain:\n" +
rs.getString(1), rs.getString(1).contains("tableScan"));
} finally {
rs.close();
}
} finally {
// Close the database
conn.close();
}
deleteDb("spatial");
}
}
......@@ -431,7 +431,7 @@ public class TestMVStore extends TestBase {
header.put("format", "2");
MVMap<Integer, String> m = s.openMap("data");
// this is to ensure the file header is overwritten
for (int i = 0; i < 10; i++) {
for (int i = 0; i < 100; i++) {
m.put(0, "Hello World " + i);
s.commit();
if (i > 5) {
......@@ -445,7 +445,8 @@ public class TestMVStore extends TestBase {
encryptionKey("007".toCharArray()).
fileName(fileName).
open();
fail();
header = s.getStoreHeader();
fail(header.toString());
} catch (IllegalStateException e) {
assertEquals(DataUtils.ERROR_UNSUPPORTED_FORMAT,
DataUtils.getErrorCode(e.getMessage()));
......@@ -480,12 +481,12 @@ public class TestMVStore extends TestBase {
autoCommitDisabled().
open();
MVMap<Integer, String> m;
for (int i = 0; i < 10; i++) {
for (int i = 0; i < 100; i++) {
m = s.openMap("data" + i);
m.put(0, "Hello World");
s.commit();
}
for (int i = 0; i < 10; i += 2) {
for (int i = 0; i < 100; i += 2) {
m = s.openMap("data" + i);
s.removeMap(m);
s.commit();
......
......@@ -93,7 +93,8 @@ public class TestDiskFull extends TestBase {
} catch (SQLException e2) {
if (e2.getErrorCode() != ErrorCode.IO_EXCEPTION_1
&& e2.getErrorCode() != ErrorCode.IO_EXCEPTION_2
&& e2.getErrorCode() != ErrorCode.DATABASE_IS_CLOSED) {
&& e2.getErrorCode() != ErrorCode.DATABASE_IS_CLOSED
&& e2.getErrorCode() != ErrorCode.OBJECT_CLOSED) {
throw e2;
}
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论