提交 5dc54122 authored 作者: Andrei Tokar's avatar Andrei Tokar

test case added

上级 3b946e53
...@@ -21,6 +21,7 @@ import org.h2.test.auth.TestAuthentication; ...@@ -21,6 +21,7 @@ import org.h2.test.auth.TestAuthentication;
import org.h2.test.bench.TestPerformance; import org.h2.test.bench.TestPerformance;
import org.h2.test.db.TestAlter; import org.h2.test.db.TestAlter;
import org.h2.test.db.TestAlterSchemaRename; import org.h2.test.db.TestAlterSchemaRename;
import org.h2.test.db.TestAnalyzeTableTx;
import org.h2.test.db.TestAutoRecompile; import org.h2.test.db.TestAutoRecompile;
import org.h2.test.db.TestBackup; import org.h2.test.db.TestBackup;
import org.h2.test.db.TestBigDb; import org.h2.test.db.TestBigDb;
...@@ -845,6 +846,7 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1` ...@@ -845,6 +846,7 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1`
addTest(new TestMvccMultiThreaded()); addTest(new TestMvccMultiThreaded());
addTest(new TestMvccMultiThreaded2()); addTest(new TestMvccMultiThreaded2());
addTest(new TestRowLocks()); addTest(new TestRowLocks());
addTest(new TestAnalyzeTableTx());
// synth // synth
addTest(new TestBtreeIndex()); addTest(new TestBtreeIndex());
......
/*
* Copyright 2004-2017 H2 Group. Multiple-Licensed under the MPL 2.0,
* and the EPL 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.test.db;
import org.h2.test.TestBase;
import org.h2.test.TestDb;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
public class TestAnalyzeTableTx extends TestDb {
static final int C = 100_000;
/**
* Run just this test.
*
* @param a ignored
*/
public static void main(String... a) throws Exception {
TestBase.createCaller().init().test();
}
@Override
public void test() throws Exception {
deleteDb(getTestName());
Connection shared = getConnection(getTestName());
Statement statement = shared.createStatement();
statement.executeUpdate("DROP TABLE IF EXISTS TEST");
statement.executeUpdate("CREATE TABLE TEST(ID INT PRIMARY KEY)");
Connection[] connections = new Connection[C];
for (int i = 0; i < C; i++) {
Connection c = getConnection(getTestName());
c.createStatement().executeUpdate("INSERT INTO TEST VALUES (" + i + ')');
connections[i] = c;
}
try (ResultSet rs = statement.executeQuery("SELECT * FROM TEST")) {
for (int i = 0; i < C; i++) {
if (!rs.next())
throw new Exception("next");
if (rs.getInt(1) != i)
throw new Exception(Integer.toString(i));
}
}
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论