提交 29dc32d9 authored 作者: Thomas Mueller's avatar Thomas Mueller

All tests should now have a main method.

上级 d1516da3
......@@ -33,6 +33,8 @@ import org.h2.util.IOUtils;
*/
public class TestFunctions extends TestBase implements AggregateFunction {
static int count;
/**
* Run just this test.
*
......@@ -44,6 +46,7 @@ public class TestFunctions extends TestBase implements AggregateFunction {
public void test() throws Exception {
deleteDb("functions");
testDeterministic();
testTransactionId();
testPrecision();
testVarArgs();
......@@ -53,6 +56,32 @@ public class TestFunctions extends TestBase implements AggregateFunction {
deleteDb("functions");
}
private void testDeterministic() throws SQLException {
Connection conn = getConnection("functions");
Statement stat = conn.createStatement();
ResultSet rs;
stat.execute("create alias getCount for \""+getClass().getName()+".getCount\"");
setCount(0);
rs = stat.executeQuery("select getCount() from system_range(1, 2)");
rs.next();
assertEquals(0, rs.getInt(1));
rs.next();
assertEquals(1, rs.getInt(1));
stat.execute("drop alias getCount");
stat.execute("create alias getCount deterministic for \""+getClass().getName()+".getCount\"");
setCount(0);
rs = stat.executeQuery("select getCount() from system_range(1, 2)");
rs.next();
assertEquals(0, rs.getInt(1));
rs.next();
assertEquals(0, rs.getInt(1));
stat.execute("drop alias getCount");
conn.close();
}
private void testTransactionId() throws SQLException {
if (config.memory) {
return;
......@@ -516,6 +545,19 @@ public class TestFunctions extends TestBase implements AggregateFunction {
return dec;
}
/**
* This method is called via reflection from the database.
*
* @return the count
*/
public static int getCount() {
return count++;
}
private static void setCount(int newCount) {
count = newCount;
}
/**
* This method is called via reflection from the database.
*
......
......@@ -25,6 +25,15 @@ public class TestIndex extends TestBase {
private Statement stat;
private Random random = new Random();
/**
* Run just this test.
*
* @param a ignored
*/
public static void main(String[] a) throws Exception {
TestBase.createCaller().init().test();
}
public void test() throws SQLException {
testDescIndex();
testHashIndex();
......
......@@ -29,6 +29,15 @@ public class TestListener extends TestBase implements DatabaseEventListener {
start = last = System.currentTimeMillis();
}
/**
* Run just this test.
*
* @param a ignored
*/
public static void main(String[] a) throws Exception {
TestBase.createCaller().init().test();
}
public void test() throws SQLException {
if (config.networked || config.cipher != null) {
return;
......
......@@ -21,6 +21,15 @@ import org.h2.tools.MultiDimension;
*/
public class TestMultiDimension extends TestBase {
/**
* Run just this test.
*
* @param a ignored
*/
public static void main(String[] a) throws Exception {
TestBase.createCaller().init().test();
}
public void test() throws SQLException {
Random rand = new Random(10);
for (int i = 0; i < 1000; i++) {
......@@ -37,11 +46,12 @@ public class TestMultiDimension extends TestBase {
conn = getConnection("multiDimension");
Statement stat = conn.createStatement();
stat.execute("CREATE ALIAS MAP FOR \"" + getClass().getName() + ".interleave\"");
stat
.execute("CREATE TABLE TEST(X INT NOT NULL, Y INT NOT NULL, Z INT NOT NULL, XYZ BIGINT AS MAP(X, Y, Z), DATA VARCHAR)");
stat.execute("CREATE TABLE TEST(X INT NOT NULL, Y INT NOT NULL, Z INT NOT NULL, " +
"XYZ BIGINT AS MAP(X, Y, Z), DATA VARCHAR)");
stat.execute("CREATE INDEX IDX_X ON TEST(X, Y, Z)");
stat.execute("CREATE INDEX IDX_XYZ ON TEST(XYZ)");
PreparedStatement prep = conn.prepareStatement("INSERT INTO TEST(X, Y, Z, DATA) VALUES(?, ?, ?, ?)");
PreparedStatement prep = conn.prepareStatement(
"INSERT INTO TEST(X, Y, Z, DATA) VALUES(?, ?, ?, ?)");
// a reasonable max value to see the performance difference is 60; the
// higher the bigger the difference
int max = getSize(10, 20);
......@@ -69,8 +79,9 @@ public class TestMultiDimension extends TestBase {
}
}
stat.execute("ANALYZE SAMPLE_SIZE 10000");
PreparedStatement prepRegular = conn.prepareStatement("SELECT * FROM TEST WHERE X BETWEEN ? AND ? "
+ "AND Y BETWEEN ? AND ? AND Z BETWEEN ? AND ? ORDER BY X, Y, Z");
PreparedStatement prepRegular = conn.prepareStatement(
"SELECT * FROM TEST WHERE X BETWEEN ? AND ? " +
"AND Y BETWEEN ? AND ? AND Z BETWEEN ? AND ? ORDER BY X, Y, Z");
MultiDimension multi = MultiDimension.getInstance();
String sql = multi.generatePreparedQuery("TEST", "XYZ", new String[] { "X", "Y", "Z" });
sql += " ORDER BY X, Y, Z";
......
......@@ -39,6 +39,15 @@ public class TestMultiThread extends TestBase implements Runnable {
stat = conn.createStatement();
}
/**
* Run just this test.
*
* @param a ignored
*/
public static void main(String[] a) throws Exception {
TestBase.createCaller().init().test();
}
public void test() throws Exception {
Connection conn = getConnection();
......
......@@ -23,6 +23,15 @@ import org.h2.test.TestBase;
*/
public class TestReadOnly extends TestBase {
/**
* Run just this test.
*
* @param a ignored
*/
public static void main(String[] a) throws Exception {
TestBase.createCaller().init().test();
}
public void test() throws Exception {
if (config.memory) {
return;
......
......@@ -19,6 +19,15 @@ import org.h2.util.FileUtils;
*/
public class TestRunscript extends TestBase implements Trigger {
/**
* Run just this test.
*
* @param a ignored
*/
public static void main(String[] a) throws Exception {
TestBase.createCaller().init().test();
}
public void test() throws SQLException {
test(false);
test(true);
......
......@@ -22,6 +22,15 @@ public class TestSQLInjection extends TestBase {
private Connection conn;
private Statement stat;
/**
* Run just this test.
*
* @param a ignored
*/
public static void main(String[] a) throws Exception {
TestBase.createCaller().init().test();
}
public void test() throws SQLException {
deleteDb("sqlInjection");
reconnect("sqlInjection");
......
......@@ -18,6 +18,15 @@ import org.h2.test.TestBase;
*/
public class TestSequence extends TestBase {
/**
* Run just this test.
*
* @param a ignored
*/
public static void main(String[] a) throws Exception {
TestBase.createCaller().init().test();
}
public void test() throws SQLException {
testAlterSequenceColumn();
testAlterSequence();
......
......@@ -18,6 +18,15 @@ import org.h2.test.TestBase;
*/
public class TestSessionsLocks extends TestBase {
/**
* Run just this test.
*
* @param a ignored
*/
public static void main(String[] a) throws Exception {
TestBase.createCaller().init().test();
}
public void test() throws Exception {
if (config.mvcc) {
return;
......
......@@ -18,6 +18,15 @@ import org.h2.test.TestBase;
*/
public class TestSpaceReuse extends TestBase {
/**
* Run just this test.
*
* @param a ignored
*/
public static void main(String[] a) throws Exception {
TestBase.createCaller().init().test();
}
public void test() throws SQLException {
if (config.memory) {
return;
......
......@@ -18,11 +18,14 @@ import org.h2.test.TestBase;
*/
public class TestSpeed extends TestBase {
// java -cp .;..\..\hsqldb\lib\hsqldb.jar -Xrunhprof:heap=sites,depth=6
// org.h2.test.TestAll
// java -Xrunhprof:heap=sites org.h2.test.TestAll
// TODO test: here is more code, currently untested!
/**
* Run just this test.
*
* @param a ignored
*/
public static void main(String[] a) throws Exception {
TestBase.createCaller().init().test();
}
public void test() throws SQLException {
......
......@@ -23,6 +23,15 @@ import org.h2.test.TestBase;
*/
public class TestTransaction extends TestBase {
/**
* Run just this test.
*
* @param a ignored
*/
public static void main(String[] a) throws Exception {
TestBase.createCaller().init().test();
}
public void test() throws SQLException {
testSetTransaction();
testReferential();
......
......@@ -22,9 +22,17 @@ import org.h2.test.TestBase;
public class TestTriggersConstraints extends TestBase implements Trigger {
private static boolean mustNotCallTrigger;
private String triggerName;
/**
* Run just this test.
*
* @param a ignored
*/
public static void main(String[] a) throws Exception {
TestBase.createCaller().init().test();
}
public void test() throws SQLException {
deleteDb("trigger");
testTriggerAlterTable();
......
......@@ -18,6 +18,16 @@ import org.h2.test.TestBase;
* Tests for the two-phase-commit feature.
*/
public class TestTwoPhaseCommit extends TestBase {
/**
* Run just this test.
*
* @param a ignored
*/
public static void main(String[] a) throws Exception {
TestBase.createCaller().init().test();
}
public void test() throws SQLException {
if (config.memory || config.networked || config.logMode == 0) {
return;
......
......@@ -43,6 +43,15 @@ public class TestBatchUpdates extends TestBase {
private Statement stat;
private PreparedStatement prep;
/**
* Run just this test.
*
* @param a ignored
*/
public static void main(String[] a) throws Exception {
TestBase.createCaller().init().test();
}
public void test() throws SQLException {
testExecuteCall();
testException();
......
......@@ -19,6 +19,15 @@ import org.h2.test.TestBase;
*/
public class TestCallableStatement extends TestBase {
/**
* Run just this test.
*
* @param a ignored
*/
public static void main(String[] a) throws Exception {
TestBase.createCaller().init().test();
}
public void test() throws SQLException {
deleteDb("callableStatement");
Connection conn = getConnection("preparedStatement");
......
......@@ -22,6 +22,15 @@ public class TestDatabaseEventListener extends TestBase implements DatabaseEvent
private boolean calledOpened, calledClosingDatabase, calledScan;
/**
* Run just this test.
*
* @param a ignored
*/
public static void main(String[] a) throws Exception {
TestBase.createCaller().init().test();
}
public void test() throws SQLException {
testCalled();
testCloseLog0(false);
......
......@@ -55,6 +55,15 @@ public class TestNativeSQL extends TestBase {
private Connection conn;
/**
* Run just this test.
*
* @param a ignored
*/
public static void main(String[] a) throws Exception {
TestBase.createCaller().init().test();
}
public void test() throws SQLException {
deleteDb("nativeSql");
conn = getConnection("nativeSql");
......
......@@ -29,6 +29,15 @@ public class TestPreparedStatement extends TestBase {
private static final int LOB_SIZE = 4000, LOB_SIZE_BIG = 512 * 1024;
/**
* Run just this test.
*
* @param a ignored
*/
public static void main(String[] a) throws Exception {
TestBase.createCaller().init().test();
}
public void test() throws Exception {
deleteDb("preparedStatement");
......
......@@ -18,6 +18,15 @@ public class TestTransactionIsolation extends TestBase {
private Connection conn1, conn2;
/**
* Run just this test.
*
* @param a ignored
*/
public static void main(String[] a) throws Exception {
TestBase.createCaller().init().test();
}
public void test() throws SQLException {
if (config.mvcc) {
// no tests yet
......
......@@ -27,6 +27,15 @@ import org.h2.test.TestBase;
*/
public class TestUpdatableResultSet extends TestBase {
/**
* Run just this test.
*
* @param a ignored
*/
public static void main(String[] a) throws Exception {
TestBase.createCaller().init().test();
}
public void test() throws SQLException {
testUpdateLob();
testScroll();
......
......@@ -20,6 +20,15 @@ import org.h2.test.TestBase;
*/
public class TestZloty extends TestBase {
/**
* Run just this test.
*
* @param a ignored
*/
public static void main(String[] a) throws Exception {
TestBase.createCaller().init().test();
}
public void test() throws SQLException {
testZloty();
testModifyBytes();
......
......@@ -19,6 +19,15 @@ import org.h2.test.TestBase;
*/
public class TestConnectionPool extends TestBase {
/**
* Run just this test.
*
* @param a ignored
*/
public static void main(String[] a) throws Exception {
TestBase.createCaller().init().test();
}
public void test() throws Exception {
deleteDb("connectionPool");
testConnect();
......
......@@ -22,11 +22,21 @@ import org.h2.util.JdbcUtils;
* Basic XA tests.
*/
public class TestXA extends TestBase {
private static final String DB_NAME1 = "xadb1";
private static final String DB_NAME2 = "xadb2";
private static final String DB_URL1 = "jdbc:h2:file:" + baseDir + "/" + DB_NAME1;
private static final String DB_URL2 = "jdbc:h2:file:" + baseDir + "/" + DB_NAME2;
/**
* Run just this test.
*
* @param a ignored
*/
public static void main(String[] a) throws Exception {
TestBase.createCaller().init().test();
}
public void test() throws Exception {
testXAAutoCommit();
deleteDb(baseDir, "xa");
......
......@@ -19,6 +19,15 @@ import org.h2.test.TestBase;
*/
public class TestXASimple extends TestBase {
/**
* Run just this test.
*
* @param a ignored
*/
public static void main(String[] a) throws Exception {
TestBase.createCaller().init().test();
}
public void test() throws SQLException {
deleteDb("xaSimple1");
......
......@@ -23,6 +23,15 @@ public class TestMvcc1 extends TestBase {
private Connection c1, c2;
private Statement s1, s2;
/**
* Run just this test.
*
* @param a ignored
*/
public static void main(String[] a) throws Exception {
TestBase.createCaller().init().test();
}
public void test() throws SQLException {
testSetMode();
testCases();
......
......@@ -22,6 +22,15 @@ public class TestMvcc2 extends TestBase {
private static final String INSERT = "INSERT INTO EMPLOYEE (id, version, NAME) VALUES (1, 1, 'Jones')";
private static final String UPDATE = "UPDATE EMPLOYEE SET NAME = 'Miller' WHERE version = 1";
/**
* Run just this test.
*
* @param a ignored
*/
public static void main(String[] a) throws Exception {
TestBase.createCaller().init().test();
}
public void test() throws SQLException {
if (!config.mvcc) {
return;
......
......@@ -18,6 +18,15 @@ import org.h2.test.TestBase;
*/
public class TestMvcc3 extends TestBase {
/**
* Run just this test.
*
* @param a ignored
*/
public static void main(String[] a) throws Exception {
TestBase.createCaller().init().test();
}
public void test() throws SQLException {
testCreateTableAsSelect();
testSequence();
......
......@@ -17,6 +17,15 @@ import org.h2.test.TestBase;
*/
public class TestMvccMultiThreaded extends TestBase {
/**
* Run just this test.
*
* @param a ignored
*/
public static void main(String[] a) throws Exception {
TestBase.createCaller().init().test();
}
public void test() throws Exception {
if (!config.mvcc) {
return;
......
......@@ -19,6 +19,15 @@ import org.h2.test.TestBase;
*/
public class TestNestedLoop extends TestBase {
/**
* Run just this test.
*
* @param a ignored
*/
public static void main(String[] a) throws Exception {
TestBase.createCaller().init().test();
}
public void test() throws SQLException {
deleteDb("nestedLoop");
Connection conn = getConnection("nestedLoop");
......
......@@ -22,6 +22,15 @@ import org.h2.tools.DeleteDbFiles;
*/
public class TestBtreeIndex extends TestBase {
/**
* Run just this test.
*
* @param a ignored
*/
public static void main(String[] a) throws Exception {
TestBase.createCaller().init().test();
}
public void test() throws SQLException {
Random random = new Random();
while (true) {
......
......@@ -57,6 +57,15 @@ public class TestCrashAPI extends TestBase {
private int openCount;
private long callCount;
/**
* Run just this test.
*
* @param a ignored
*/
public static void main(String[] a) throws Exception {
TestBase.createCaller().init().test();
}
private void deleteDb() {
try {
deleteDb(baseDir + "/" + DIR, null);
......
......@@ -31,6 +31,15 @@ public class TestJoin extends TestBase {
private int paramCount;
private StringBuffer buff;
/**
* Run just this test.
*
* @param a ignored
*/
public static void main(String[] a) throws Exception {
TestBase.createCaller().init().test();
}
public void test() throws Exception {
String old = baseDir;
baseDir = TestBase.getTestDir("join");
......
......@@ -30,6 +30,15 @@ public class TestKill extends TestBase {
private int accounts = 10;
private Random random = new Random(1);
/**
* Run just this test.
*
* @param a ignored
*/
public static void main(String[] a) throws Exception {
TestBase.createCaller().init().test();
}
public void test() throws Exception {
String connect = "";
......
......@@ -33,6 +33,15 @@ public class TestRandomSQL extends TestBase {
private Bnf bnf;
private int success, total;
/**
* Run just this test.
*
* @param a ignored
*/
public static void main(String[] a) throws Exception {
TestBase.createCaller().init().test();
}
private void processException(String sql, SQLException e) {
if (e.getSQLState().equals("HY000")) {
TestBase.logError("new TestRandomSQL().init(test).testCase(" + seed + "); // FAIL: " + e.toString() + " sql: " + sql, e);
......
......@@ -24,6 +24,15 @@ public class TestSimpleIndex extends TestBase {
private Statement stat;
private RandomGen random;
/**
* Run just this test.
*
* @param a ignored
*/
public static void main(String[] a) throws Exception {
TestBase.createCaller().init().test();
}
public void test() throws SQLException {
deleteDb("simpleIndex");
conn = getConnection("simpleIndex");
......
......@@ -43,6 +43,15 @@ public class TestThreads extends TestBase implements Runnable {
this.table = table;
}
/**
* Run just this test.
*
* @param a ignored
*/
public static void main(String[] a) throws Exception {
TestBase.createCaller().init().test();
}
public void test() throws Exception {
deleteDb("threads");
Connection conn = getConnection("threads;MAX_LOG_SIZE=1");
......
......@@ -24,6 +24,15 @@ import org.h2.tools.DeleteDbFiles;
*/
public class TestTimer extends TestBase {
/**
* Run just this test.
*
* @param a ignored
*/
public static void main(String[] a) throws Exception {
TestBase.createCaller().init().test();
}
public void test() throws SQLException {
validateOld();
DeleteDbFiles.execute(baseDir, "timer", true);
......
......@@ -55,6 +55,15 @@ public class TestSynth extends TestBase {
private boolean stopImmediately;
private int mode;
/**
* Run just this test.
*
* @param a ignored
*/
public static void main(String[] a) throws Exception {
TestBase.createCaller().init().test();
}
/**
* Check whether this database is of the specified type.
*
......
......@@ -22,6 +22,15 @@ public class TestMulti extends TestBase {
*/
public volatile boolean stop;
/**
* Run just this test.
*
* @param a ignored
*/
public static void main(String[] a) throws Exception {
TestBase.createCaller().init().test();
}
public void test() throws Exception {
org.h2.Driver.load();
deleteDb(baseDir, "openClose");
......
......@@ -17,6 +17,15 @@ import org.h2.tools.CompressTool;
*/
public class TestCompress extends TestBase {
/**
* Run just this test.
*
* @param a ignored
*/
public static void main(String[] a) throws Exception {
TestBase.createCaller().init().test();
}
public void test() throws SQLException {
if (config.big) {
for (int i = 0; i < 100; i++) {
......
......@@ -28,6 +28,15 @@ import org.h2.value.ValueString;
*/
public class TestDataPage extends TestBase implements DataHandler {
/**
* Run just this test.
*
* @param a ignored
*/
public static void main(String[] a) throws Exception {
TestBase.createCaller().init().test();
}
public void test() throws SQLException {
testAll();
}
......
......@@ -23,6 +23,15 @@ import org.h2.value.Value;
*/
public class TestFile extends TestBase implements DataHandler {
/**
* Run just this test.
*
* @param a ignored
*/
public static void main(String[] a) throws Exception {
TestBase.createCaller().init().test();
}
public void test() throws Exception {
doTest(false);
doTest(true);
......
......@@ -19,6 +19,15 @@ public class TestFtp extends TestBase implements FtpEventListener {
private FtpEvent lastEvent;
/**
* Run just this test.
*
* @param a ignored
*/
public static void main(String[] a) throws Exception {
TestBase.createCaller().init().test();
}
public void test() throws Exception {
test(baseDir);
}
......
......@@ -18,6 +18,15 @@ public class TestIntIntHashMap extends TestBase {
private Random rand = new Random();
/**
* Run just this test.
*
* @param a ignored
*/
public static void main(String[] a) throws Exception {
TestBase.createCaller().init().test();
}
public void test() {
rand.setSeed(10);
test(true);
......
......@@ -23,6 +23,15 @@ public class TestMultiThreadedKernel extends TestBase implements Runnable {
private TestMultiThreadedKernel master;
private volatile boolean stop;
/**
* Run just this test.
*
* @param a ignored
*/
public static void main(String[] a) throws Exception {
TestBase.createCaller().init().test();
}
public void test() throws Exception {
if (config.networked || config.mvcc) {
return;
......
......@@ -18,6 +18,15 @@ import org.h2.util.ScriptReader;
*/
public class TestScriptReader extends TestBase {
/**
* Run just this test.
*
* @param a ignored
*/
public static void main(String[] a) throws Exception {
TestBase.createCaller().init().test();
}
public void test() throws SQLException {
testCommon();
testRandom();
......
......@@ -19,6 +19,15 @@ import org.h2.util.ByteUtils;
*/
public class TestSecurity extends TestBase {
/**
* Run just this test.
*
* @param a ignored
*/
public static void main(String[] a) throws Exception {
TestBase.createCaller().init().test();
}
public void test() throws SQLException {
testSHA();
testAES();
......
......@@ -31,6 +31,15 @@ import org.h2.test.TestBase;
*/
public class TestServlet extends TestBase {
/**
* Run just this test.
*
* @param a ignored
*/
public static void main(String[] a) throws Exception {
TestBase.createCaller().init().test();
}
/**
* Minimum ServletContext implementation.
* Most methods are not implemented.
......
......@@ -37,6 +37,15 @@ public class TestShell extends TestBase {
private PipedInputStream testIn;
private LineNumberReader lineReader;
/**
* Run just this test.
*
* @param a ignored
*/
public static void main(String[] a) throws Exception {
TestBase.createCaller().init().test();
}
public void test() throws IOException {
testIn = new PipedInputStream();
PipedOutputStream out = new PipedOutputStream(testIn);
......
......@@ -20,6 +20,15 @@ import org.h2.test.TestBase;
*/
public class TestStreams extends TestBase {
/**
* Run just this test.
*
* @param a ignored
*/
public static void main(String[] a) throws Exception {
TestBase.createCaller().init().test();
}
public void test() throws IOException {
testLZFStreams();
}
......
......@@ -22,6 +22,15 @@ import org.h2.util.StringUtils;
*/
public class TestStringUtils extends TestBase {
/**
* Run just this test.
*
* @param a ignored
*/
public static void main(String[] a) throws Exception {
TestBase.createCaller().init().test();
}
public void test() throws Exception {
testHex();
testXML();
......
......@@ -19,6 +19,15 @@ import org.h2.value.ValueUuid;
*/
public class TestValue extends TestBase {
/**
* Run just this test.
*
* @param a ignored
*/
public static void main(String[] a) throws Exception {
TestBase.createCaller().init().test();
}
public void test() throws SQLException {
testUUID();
testDouble(false);
......
......@@ -31,6 +31,15 @@ public class TestValueHashMap extends TestBase implements DataHandler {
CompareMode compareMode = new CompareMode(null, null, 0);
/**
* Run just this test.
*
* @param a ignored
*/
public static void main(String[] a) throws Exception {
TestBase.createCaller().init().test();
}
public void test() throws SQLException {
ValueHashMap map = new ValueHashMap(this);
HashMap hash = new HashMap();
......
......@@ -57,6 +57,15 @@ public class TestValueMemory extends TestBase implements DataHandler {
private Random random = new Random(1);
private SmallLRUCache lobFileListCache = new SmallLRUCache(128);
/**
* Run just this test.
*
* @param a ignored
*/
public static void main(String[] a) throws Exception {
TestBase.createCaller().init().test();
}
public void test() throws SQLException {
for (int i = 0; i < Value.TYPE_COUNT; i++) {
testType(i);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论