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

--no commit message

--no commit message
上级 e299cfc2
...@@ -161,7 +161,7 @@ ...@@ -161,7 +161,7 @@
<fileset dir="src/docsrc" includes="index.html"/> <fileset dir="src/docsrc" includes="index.html"/>
<fileset dir="src/docsrc" includes="html/**/*" excludes="**/*.jsp" /> <fileset dir="src/docsrc" includes="html/**/*" excludes="**/*.jsp" />
</copy> </copy>
<java classname="org.h2.tools.code.CheckPackageHtml" classpath="bin"/> <java classname="org.h2.tools.code.CheckJavadoc" classpath="bin"/>
<java classname="org.h2.tools.code.CheckTextFiles" classpath="bin"/> <java classname="org.h2.tools.code.CheckTextFiles" classpath="bin"/>
<java classname="org.h2.tools.doc.GenerateDoc" classpath="bin"> <java classname="org.h2.tools.doc.GenerateDoc" classpath="bin">
<arg line="-in src/docsrc/html -out docs/html"/> <arg line="-in src/docsrc/html -out docs/html"/>
......
...@@ -126,4 +126,6 @@ public class SysProperties { ...@@ -126,4 +126,6 @@ public class SysProperties {
public static String getBaseDir() { public static String getBaseDir() {
return baseDir; return baseDir;
} }
public static final int CACHE_SIZE_INDEX_DEFAULT = CACHE_SIZE_DEFAULT >> CACHE_SIZE_INDEX_SHIFT;
} }
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
*/ */
package org.h2.engine; package org.h2.engine;
import org.h2.constant.SysProperties;
/* /*
* Release checklist * Release checklist
...@@ -176,5 +175,4 @@ public class Constants { ...@@ -176,5 +175,4 @@ public class Constants {
public static final int ENCRYPTION_KEY_HASH_ITERATIONS = 1024; public static final int ENCRYPTION_KEY_HASH_ITERATIONS = 1024;
public static final String SCRIPT_SQL = "script.sql"; public static final String SCRIPT_SQL = "script.sql";
public static final int CACHE_MIN_RECORDS = 16; public static final int CACHE_MIN_RECORDS = 16;
public static final int CACHE_SIZE_INDEX_DEFAULT = SysProperties.CACHE_SIZE_DEFAULT >> SysProperties.CACHE_SIZE_INDEX_SHIFT;
} }
...@@ -390,7 +390,7 @@ public class Database implements DataHandler { ...@@ -390,7 +390,7 @@ public class Database implements DataHandler {
private void openFileIndex() throws SQLException { private void openFileIndex() throws SQLException {
fileIndex = new DiskFile(this, databaseName + Constants.SUFFIX_INDEX_FILE, accessModeData, false, fileIndex = new DiskFile(this, databaseName + Constants.SUFFIX_INDEX_FILE, accessModeData, false,
logIndexChanges, Constants.CACHE_SIZE_INDEX_DEFAULT); logIndexChanges, SysProperties.CACHE_SIZE_INDEX_DEFAULT);
} }
public DataPage getDataPage() { public DataPage getDataPage() {
......
...@@ -9,10 +9,13 @@ import java.io.PrintWriter; ...@@ -9,10 +9,13 @@ import java.io.PrintWriter;
import java.sql.BatchUpdateException; import java.sql.BatchUpdateException;
import java.sql.SQLException; import java.sql.SQLException;
/**
* Represents a batch update database exception.
*/
public class JdbcBatchUpdateException extends BatchUpdateException { public class JdbcBatchUpdateException extends BatchUpdateException {
private static final long serialVersionUID = 9006432914018679675L; private static final long serialVersionUID = 9006432914018679675L;
/** /**
* INTERNAL * INTERNAL
*/ */
......
...@@ -11,7 +11,7 @@ import java.sql.SQLException; ...@@ -11,7 +11,7 @@ import java.sql.SQLException;
import org.h2.engine.Constants; import org.h2.engine.Constants;
/** /**
* Represents an exception. * Represents a database exception.
*/ */
public class JdbcSQLException extends SQLException { public class JdbcSQLException extends SQLException {
......
...@@ -7,7 +7,7 @@ package org.h2.store.fs; ...@@ -7,7 +7,7 @@ package org.h2.store.fs;
import java.io.IOException; import java.io.IOException;
/** /**
* This interface represents a RandomAccessFile. * This interface represents a random access file.
*/ */
public interface FileObject { public interface FileObject {
......
...@@ -11,7 +11,7 @@ import java.io.RandomAccessFile; ...@@ -11,7 +11,7 @@ import java.io.RandomAccessFile;
import org.h2.util.FileUtils; import org.h2.util.FileUtils;
/** /**
* This class is extends a RandomAccessFile. * This class is extends a java.io.RandomAccessFile.
*/ */
public class FileObjectDisk extends RandomAccessFile implements FileObject { public class FileObjectDisk extends RandomAccessFile implements FileObject {
......
...@@ -74,10 +74,10 @@ import org.h2.test.synth.TestCrashAPI; ...@@ -74,10 +74,10 @@ import org.h2.test.synth.TestCrashAPI;
import org.h2.test.synth.TestHaltApp; import org.h2.test.synth.TestHaltApp;
import org.h2.test.synth.TestJoin; import org.h2.test.synth.TestJoin;
import org.h2.test.synth.TestKill; import org.h2.test.synth.TestKill;
import org.h2.test.synth.TestMulti;
import org.h2.test.synth.TestRandomSQL; import org.h2.test.synth.TestRandomSQL;
import org.h2.test.synth.TestSynth;
import org.h2.test.synth.TestTimer; import org.h2.test.synth.TestTimer;
import org.h2.test.synth.sql.TestSynth;
import org.h2.test.synth.thread.TestMulti;
import org.h2.test.unit.TestBitField; import org.h2.test.unit.TestBitField;
import org.h2.test.unit.TestCache; import org.h2.test.unit.TestCache;
import org.h2.test.unit.TestCompress; import org.h2.test.unit.TestCompress;
...@@ -149,7 +149,6 @@ java org.h2.test.TestAll timer ...@@ -149,7 +149,6 @@ java org.h2.test.TestAll timer
/* /*
check no more @author
staging.trace.db.gz staging.trace.db.gz
...@@ -160,7 +159,8 @@ http://java.sun.com/j2se/1.4.2/docs/guide/jdbc/getstart/callablestatement.html#1 ...@@ -160,7 +159,8 @@ http://java.sun.com/j2se/1.4.2/docs/guide/jdbc/getstart/callablestatement.html#1
-Djboss.bind.address=<ip_address> -Djboss.bind.address=<ip_address>
-Dh2.bindAddress=... -Dh2.bindAddress=...
documentation: package.html: write test (enforce one package.html where there is a .java file) [echo] Java version is 1.6 but source code is switched to 1.4.
[echo] Run ant codeswitchJdk... first.
write to the db file what version was used to create a database write to the db file what version was used to create a database
......
...@@ -11,6 +11,9 @@ import java.sql.Statement; ...@@ -11,6 +11,9 @@ import java.sql.Statement;
import org.h2.test.TestBase; import org.h2.test.TestBase;
/**
* Tests for the CallableStatement class.
*/
public class TestCallableStatement extends TestBase { public class TestCallableStatement extends TestBase {
public void test() throws Exception { public void test() throws Exception {
...@@ -19,7 +22,7 @@ public class TestCallableStatement extends TestBase { ...@@ -19,7 +22,7 @@ public class TestCallableStatement extends TestBase {
testPrepare(conn); testPrepare(conn);
conn.close(); conn.close();
} }
private void testPrepare(Connection conn) throws Exception { private void testPrepare(Connection conn) throws Exception {
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
CallableStatement call; CallableStatement call;
......
/* /*
* Copyright 2004-2007 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html). * Copyright 2004-2007 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group * Initial Developer: H2 Group
*/ */
package org.h2.test.jdbc; package org.h2.test.jdbc;
...@@ -12,10 +12,10 @@ import java.sql.Statement; ...@@ -12,10 +12,10 @@ import java.sql.Statement;
import org.h2.test.TestBase; import org.h2.test.TestBase;
/** /**
* @author Thomas * Tests Statement.cancel
*/ */
public class TestCancel extends TestBase { public class TestCancel extends TestBase {
class CancelThread extends Thread { class CancelThread extends Thread {
......
...@@ -16,19 +16,22 @@ import javax.transaction.xa.Xid; ...@@ -16,19 +16,22 @@ import javax.transaction.xa.Xid;
import org.h2.jdbcx.JdbcDataSource; import org.h2.jdbcx.JdbcDataSource;
import org.h2.test.TestBase; import org.h2.test.TestBase;
/**
* Tests DataSource and XAConnection.
*/
public class TestDataSource extends TestBase { public class TestDataSource extends TestBase {
// public static void main(String[] args) throws Exception { // public static void main(String[] args) throws Exception {
// //
// // first, need to start on the command line: // // first, need to start on the command line:
// // rmiregistry 1099 // // rmiregistry 1099
// //
// // System.setProperty(Context.INITIAL_CONTEXT_FACTORY, // // System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
// "com.sun.jndi.ldap.LdapCtxFactory"); // "com.sun.jndi.ldap.LdapCtxFactory");
// System.setProperty(Context.INITIAL_CONTEXT_FACTORY, // System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
// "com.sun.jndi.rmi.registry.RegistryContextFactory"); // "com.sun.jndi.rmi.registry.RegistryContextFactory");
// System.setProperty(Context.PROVIDER_URL, "rmi://localhost:1099"); // System.setProperty(Context.PROVIDER_URL, "rmi://localhost:1099");
// //
// JdbcDataSource ds = new JdbcDataSource(); // JdbcDataSource ds = new JdbcDataSource();
// ds.setURL("jdbc:h2:test"); // ds.setURL("jdbc:h2:test");
// ds.setUser("test"); // ds.setUser("test");
...@@ -36,7 +39,7 @@ public class TestDataSource extends TestBase { ...@@ -36,7 +39,7 @@ public class TestDataSource extends TestBase {
// //
// Context ctx = new InitialContext(); // Context ctx = new InitialContext();
// ctx.bind("jdbc/test", ds); // ctx.bind("jdbc/test", ds);
// //
// DataSource ds2 = (DataSource)ctx.lookup("jdbc/test"); // DataSource ds2 = (DataSource)ctx.lookup("jdbc/test");
// Connection conn = ds2.getConnection(); // Connection conn = ds2.getConnection();
// conn.close(); // conn.close();
......
...@@ -13,8 +13,11 @@ import java.util.Properties; ...@@ -13,8 +13,11 @@ import java.util.Properties;
import org.h2.api.DatabaseEventListener; import org.h2.api.DatabaseEventListener;
import org.h2.test.TestBase; import org.h2.test.TestBase;
/**
* Tests the DatabaseEventListener interface.
*/
public class TestDatabaseEventListener extends TestBase implements DatabaseEventListener { public class TestDatabaseEventListener extends TestBase implements DatabaseEventListener {
private boolean calledOpened, calledClosingDatabase, calledScan; private boolean calledOpened, calledClosingDatabase, calledScan;
public void test() throws Exception { public void test() throws Exception {
...@@ -22,7 +25,7 @@ public class TestDatabaseEventListener extends TestBase implements DatabaseEvent ...@@ -22,7 +25,7 @@ public class TestDatabaseEventListener extends TestBase implements DatabaseEvent
testCloseLog0(false); testCloseLog0(false);
testCloseLog0(true); testCloseLog0(true);
} }
private void testCloseLog0(boolean shutdown) throws Exception { private void testCloseLog0(boolean shutdown) throws Exception {
if (config.memory) { if (config.memory) {
return; return;
...@@ -52,7 +55,7 @@ public class TestDatabaseEventListener extends TestBase implements DatabaseEvent ...@@ -52,7 +55,7 @@ public class TestDatabaseEventListener extends TestBase implements DatabaseEvent
check(!l.calledScan); check(!l.calledScan);
} }
} }
private void testCalled() throws Exception { private void testCalled() throws Exception {
Properties p = new Properties(); Properties p = new Properties();
p.setProperty("user", "sa"); p.setProperty("user", "sa");
...@@ -65,7 +68,7 @@ public class TestDatabaseEventListener extends TestBase implements DatabaseEvent ...@@ -65,7 +68,7 @@ public class TestDatabaseEventListener extends TestBase implements DatabaseEvent
check(l.calledOpened); check(l.calledOpened);
check(l.calledClosingDatabase); check(l.calledClosingDatabase);
} }
public void closingDatabase() { public void closingDatabase() {
calledClosingDatabase = true; calledClosingDatabase = true;
} }
......
/* /*
* Copyright 2004-2007 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html). * Copyright 2004-2007 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group * Initial Developer: H2 Group
*/ */
package org.h2.test.jdbc; package org.h2.test.jdbc;
...@@ -13,6 +13,9 @@ import java.sql.Statement; ...@@ -13,6 +13,9 @@ import java.sql.Statement;
import org.h2.constant.SysProperties; import org.h2.constant.SysProperties;
import org.h2.test.TestBase; import org.h2.test.TestBase;
/**
* Tests the server by creating many JDBC objects (result sets and so on).
*/
public class TestManyJdbcObjects extends TestBase { public class TestManyJdbcObjects extends TestBase {
public void test() throws Exception { public void test() throws Exception {
......
...@@ -15,6 +15,9 @@ import org.h2.engine.Constants; ...@@ -15,6 +15,9 @@ import org.h2.engine.Constants;
import org.h2.test.TestBase; import org.h2.test.TestBase;
import org.h2.value.DataType; import org.h2.value.DataType;
/**
* Test for the DatabaseMetaData implementation.
*/
public class TestMetaData extends TestBase { public class TestMetaData extends TestBase {
Connection conn; Connection conn;
......
/* /*
* Copyright 2004-2007 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html). * Copyright 2004-2007 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group * Initial Developer: H2 Group
*/ */
package org.h2.test.jdbc; package org.h2.test.jdbc;
...@@ -11,9 +11,8 @@ import java.sql.Statement; ...@@ -11,9 +11,8 @@ import java.sql.Statement;
import org.h2.test.TestBase; import org.h2.test.TestBase;
/** /**
* @author Thomas * Tests the Connection.nativeSQL method.
*/ */
public class TestNativeSQL extends TestBase { public class TestNativeSQL extends TestBase {
public void test() throws Exception { public void test() throws Exception {
......
...@@ -20,6 +20,9 @@ import java.sql.Types; ...@@ -20,6 +20,9 @@ import java.sql.Types;
import org.h2.test.TestBase; import org.h2.test.TestBase;
/**
* Tests for the PreparedStatement implementation.
*/
public class TestPreparedStatement extends TestBase { public class TestPreparedStatement extends TestBase {
static final int LOB_SIZE = 4000, LOB_SIZE_BIG = 512 * 1024; static final int LOB_SIZE = 4000, LOB_SIZE_BIG = 512 * 1024;
...@@ -33,7 +36,7 @@ public class TestPreparedStatement extends TestBase { ...@@ -33,7 +36,7 @@ public class TestPreparedStatement extends TestBase {
testPrepareRecompile(conn); testPrepareRecompile(conn);
testMaxRowsChange(conn); testMaxRowsChange(conn);
testUnknownDataType(conn); testUnknownDataType(conn);
testCancelReuse(conn); testCancelReuse(conn);
testCoalesce(conn); testCoalesce(conn);
testPreparedStatementMetaData(conn); testPreparedStatementMetaData(conn);
testDate(conn); testDate(conn);
...@@ -54,14 +57,14 @@ public class TestPreparedStatement extends TestBase { ...@@ -54,14 +57,14 @@ public class TestPreparedStatement extends TestBase {
testParameterMetaData(conn); testParameterMetaData(conn);
conn.close(); conn.close();
} }
private void testTempView(Connection conn) throws Exception { private void testTempView(Connection conn) throws Exception {
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
PreparedStatement prep; PreparedStatement prep;
stat.execute("CREATE TABLE TEST(FIELD INT PRIMARY KEY)"); stat.execute("CREATE TABLE TEST(FIELD INT PRIMARY KEY)");
stat.execute("INSERT INTO TEST VALUES(1)"); stat.execute("INSERT INTO TEST VALUES(1)");
stat.execute("INSERT INTO TEST VALUES(2)"); stat.execute("INSERT INTO TEST VALUES(2)");
prep = conn.prepareStatement("select FIELD FROM " prep = conn.prepareStatement("select FIELD FROM "
+ "(select FIELD FROM (SELECT FIELD FROM TEST WHERE FIELD = ?) AS T2 " + "(select FIELD FROM (SELECT FIELD FROM TEST WHERE FIELD = ?) AS T2 "
+ "WHERE T2.FIELD = ?) AS T3 WHERE T3.FIELD = ?"); + "WHERE T2.FIELD = ?) AS T3 WHERE T3.FIELD = ?");
prep.setInt(1, 1); prep.setInt(1, 1);
...@@ -78,12 +81,12 @@ public class TestPreparedStatement extends TestBase { ...@@ -78,12 +81,12 @@ public class TestPreparedStatement extends TestBase {
check(2, rs.getInt(1)); check(2, rs.getInt(1));
stat.execute("DROP TABLE TEST"); stat.execute("DROP TABLE TEST");
} }
private void testInsertFunction(Connection conn) throws Exception { private void testInsertFunction(Connection conn) throws Exception {
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
PreparedStatement prep; PreparedStatement prep;
ResultSet rs; ResultSet rs;
stat.execute("CREATE TABLE TEST(ID INT, H BINARY)"); stat.execute("CREATE TABLE TEST(ID INT, H BINARY)");
prep = conn.prepareStatement("INSERT INTO TEST VALUES(?, HASH('SHA256', STRINGTOUTF8(?), 5))"); prep = conn.prepareStatement("INSERT INTO TEST VALUES(?, HASH('SHA256', STRINGTOUTF8(?), 5))");
prep.setInt(1, 1); prep.setInt(1, 1);
...@@ -95,15 +98,15 @@ public class TestPreparedStatement extends TestBase { ...@@ -95,15 +98,15 @@ public class TestPreparedStatement extends TestBase {
rs = stat.executeQuery("SELECT COUNT(DISTINCT H) FROM TEST"); rs = stat.executeQuery("SELECT COUNT(DISTINCT H) FROM TEST");
rs.next(); rs.next();
check(rs.getInt(1), 2); check(rs.getInt(1), 2);
stat.execute("DROP TABLE TEST"); stat.execute("DROP TABLE TEST");
} }
private void testPrepareRecompile(Connection conn) throws Exception { private void testPrepareRecompile(Connection conn) throws Exception {
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
PreparedStatement prep; PreparedStatement prep;
ResultSet rs; ResultSet rs;
prep = conn.prepareStatement("SELECT COUNT(*) FROM DUAL WHERE ? IS NULL"); prep = conn.prepareStatement("SELECT COUNT(*) FROM DUAL WHERE ? IS NULL");
prep.setString(1, null); prep.setString(1, null);
prep.executeQuery(); prep.executeQuery();
...@@ -131,9 +134,9 @@ public class TestPreparedStatement extends TestBase { ...@@ -131,9 +134,9 @@ public class TestPreparedStatement extends TestBase {
rs.next(); rs.next();
check(rs.getInt(1), 3); check(rs.getInt(1), 3);
stat.execute("DROP TABLE t1, t2"); stat.execute("DROP TABLE t1, t2");
} }
private void testMaxRowsChange(Connection conn) throws Exception { private void testMaxRowsChange(Connection conn) throws Exception {
PreparedStatement prep = conn.prepareStatement("SELECT * FROM SYSTEM_RANGE(1, 100)"); PreparedStatement prep = conn.prepareStatement("SELECT * FROM SYSTEM_RANGE(1, 100)");
ResultSet rs; ResultSet rs;
...@@ -146,7 +149,7 @@ public class TestPreparedStatement extends TestBase { ...@@ -146,7 +149,7 @@ public class TestPreparedStatement extends TestBase {
checkFalse(rs.next()); checkFalse(rs.next());
} }
} }
private void testUnknownDataType(Connection conn) throws Exception { private void testUnknownDataType(Connection conn) throws Exception {
try { try {
PreparedStatement prep = conn.prepareStatement( PreparedStatement prep = conn.prepareStatement(
...@@ -165,7 +168,7 @@ public class TestPreparedStatement extends TestBase { ...@@ -165,7 +168,7 @@ public class TestPreparedStatement extends TestBase {
prep.setInt(2, 2); prep.setInt(2, 2);
prep.execute(); prep.execute();
} }
private void testCancelReuse(Connection conn) throws Exception { private void testCancelReuse(Connection conn) throws Exception {
conn.createStatement().execute("CREATE ALIAS YIELD FOR \"java.lang.Thread.yield\""); conn.createStatement().execute("CREATE ALIAS YIELD FOR \"java.lang.Thread.yield\"");
final PreparedStatement prep = conn.prepareStatement("SELECT YIELD() FROM SYSTEM_RANGE(1, 1000000) LIMIT ?"); final PreparedStatement prep = conn.prepareStatement("SELECT YIELD() FROM SYSTEM_RANGE(1, 1000000) LIMIT ?");
...@@ -192,7 +195,7 @@ public class TestPreparedStatement extends TestBase { ...@@ -192,7 +195,7 @@ public class TestPreparedStatement extends TestBase {
check(rs.getInt(1), 0); check(rs.getInt(1), 0);
checkFalse(rs.next()); checkFalse(rs.next());
} }
private void testCoalesce(Connection conn) throws Exception { private void testCoalesce(Connection conn) throws Exception {
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
stat.executeUpdate("create table test(tm timestamp)"); stat.executeUpdate("create table test(tm timestamp)");
......
...@@ -25,6 +25,9 @@ import java.util.TimeZone; ...@@ -25,6 +25,9 @@ import java.util.TimeZone;
import org.h2.test.TestBase; import org.h2.test.TestBase;
/**
* Tests for the ResultSet implementation.
*/
public class TestResultSet extends TestBase { public class TestResultSet extends TestBase {
Connection conn; Connection conn;
Statement stat; Statement stat;
......
...@@ -14,6 +14,9 @@ import org.h2.constant.SysProperties; ...@@ -14,6 +14,9 @@ import org.h2.constant.SysProperties;
import org.h2.jdbc.JdbcStatement; import org.h2.jdbc.JdbcStatement;
import org.h2.test.TestBase; import org.h2.test.TestBase;
/**
* Tests for the Statement implementation.
*/
public class TestStatement extends TestBase { public class TestStatement extends TestBase {
Connection conn; Connection conn;
......
...@@ -9,6 +9,9 @@ import java.sql.SQLException; ...@@ -9,6 +9,9 @@ import java.sql.SQLException;
import org.h2.test.TestBase; import org.h2.test.TestBase;
/**
* Transaction isolation level tests.
*/
public class TestTransactionIsolation extends TestBase { public class TestTransactionIsolation extends TestBase {
Connection conn1, conn2; Connection conn1, conn2;
......
...@@ -19,6 +19,9 @@ import java.sql.Timestamp; ...@@ -19,6 +19,9 @@ import java.sql.Timestamp;
import org.h2.test.TestBase; import org.h2.test.TestBase;
/**
* Updatable result set tests.
*/
public class TestUpdatableResultSet extends TestBase { public class TestUpdatableResultSet extends TestBase {
public void test() throws Exception { public void test() throws Exception {
......
...@@ -8,9 +8,12 @@ import java.sql.Connection; ...@@ -8,9 +8,12 @@ import java.sql.Connection;
import org.h2.jdbcx.JdbcDataSource; import org.h2.jdbcx.JdbcDataSource;
/**
* A simple XA test.
*/
public class TestXASimple { public class TestXASimple {
int notYetImplemented; private int notYetImplemented;
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
Class.forName("org.h2.Driver"); Class.forName("org.h2.Driver");
......
...@@ -12,6 +12,10 @@ import java.sql.SQLException; ...@@ -12,6 +12,10 @@ import java.sql.SQLException;
import org.h2.test.TestBase; import org.h2.test.TestBase;
/**
* Tests a custom BigDecimal implementation, as well
* as direct modification of a byte in a byte array.
*/
public class TestZloty extends TestBase { public class TestZloty extends TestBase {
public void test() throws Exception { public void test() throws Exception {
...@@ -61,7 +65,7 @@ public class TestZloty extends TestBase { ...@@ -61,7 +65,7 @@ public class TestZloty extends TestBase {
/** /**
* H2 destroyer application ;-> * H2 destroyer application ;->
* *
* @author Maciej Wegorkiewicz * @author Maciej Wegorkiewicz
*/ */
private void testZloty() throws Exception { private void testZloty() throws Exception {
......
...@@ -16,6 +16,9 @@ import org.h2.jdbcx.JdbcDataSource; ...@@ -16,6 +16,9 @@ import org.h2.jdbcx.JdbcDataSource;
import org.h2.test.TestBase; import org.h2.test.TestBase;
import org.h2.util.JdbcUtils; import org.h2.util.JdbcUtils;
/**
* Basic XA tests.
*/
public class TestXA extends TestBase { public class TestXA extends TestBase {
private static final String DB_NAME1 = "xadb1"; private static final String DB_NAME1 = "xadb1";
private static final String DB_NAME2 = "xadb2"; private static final String DB_NAME2 = "xadb2";
...@@ -30,7 +33,7 @@ public class TestXA extends TestBase { ...@@ -30,7 +33,7 @@ public class TestXA extends TestBase {
deleteDb(baseDir, DB_NAME2); deleteDb(baseDir, DB_NAME2);
testXA(false); testXA(false);
} }
public static class MyXid implements Xid { public static class MyXid implements Xid {
private byte[] branchQualifier = new byte[1]; private byte[] branchQualifier = new byte[1];
private byte[] globalTransactionId = new byte[1]; private byte[] globalTransactionId = new byte[1];
...@@ -43,8 +46,8 @@ public class TestXA extends TestBase { ...@@ -43,8 +46,8 @@ public class TestXA extends TestBase {
public byte[] getGlobalTransactionId() { public byte[] getGlobalTransactionId() {
return globalTransactionId; return globalTransactionId;
} }
} }
private void testXAAutoCommit() throws Exception { private void testXAAutoCommit() throws Exception {
JdbcDataSource ds = new JdbcDataSource(); JdbcDataSource ds = new JdbcDataSource();
ds.setURL("jdbc:h2:mem:test"); ds.setURL("jdbc:h2:mem:test");
...@@ -58,7 +61,7 @@ public class TestXA extends TestBase { ...@@ -58,7 +61,7 @@ public class TestXA extends TestBase {
check(!c.getAutoCommit()); check(!c.getAutoCommit());
c.close(); c.close();
} }
private void testXA(boolean useOneDatabase) { private void testXA(boolean useOneDatabase) {
XAConnection xaConn1 = null; XAConnection xaConn1 = null;
XAConnection xaConn2 = null; XAConnection xaConn2 = null;
......
...@@ -9,6 +9,9 @@ import java.net.UnknownHostException; ...@@ -9,6 +9,9 @@ import java.net.UnknownHostException;
import java.text.NumberFormat; import java.text.NumberFormat;
import javax.transaction.xa.Xid; import javax.transaction.xa.Xid;
/**
* A utility class for the basic XA test.
*/
public class TestXid implements Xid { public class TestXid implements Xid {
private static final NumberFormat NF; private static final NumberFormat NF;
...@@ -30,7 +33,7 @@ public class TestXid implements Xid { ...@@ -30,7 +33,7 @@ public class TestXid implements Xid {
public static void main(String[] args) { public static void main(String[] args) {
new TestXid(); new TestXid();
} }
public TestXid() { public TestXid() {
this(1); this(1);
} }
......
...@@ -11,6 +11,10 @@ import java.sql.Statement; ...@@ -11,6 +11,10 @@ import java.sql.Statement;
import org.h2.test.TestBase; import org.h2.test.TestBase;
/**
* Tests remote JDBC access with nested loops.
* This is not allowed in some databases.
*/
public class TestNestedLoop extends TestBase { public class TestNestedLoop extends TestBase {
public void test() throws Exception { public void test() throws Exception {
......
...@@ -16,6 +16,9 @@ import java.sql.Statement; ...@@ -16,6 +16,9 @@ import java.sql.Statement;
import org.h2.test.TestBase; import org.h2.test.TestBase;
import org.h2.tools.Server; import org.h2.tools.Server;
/**
* Tests the PostgreSQL server protocol compliant implementation.
*/
public class TestPgServer extends TestBase { public class TestPgServer extends TestBase {
public void test() throws Exception { public void test() throws Exception {
...@@ -43,7 +46,7 @@ public class TestPgServer extends TestBase { ...@@ -43,7 +46,7 @@ public class TestPgServer extends TestBase {
} }
conn.close(); conn.close();
conn = DriverManager.getConnection("jdbc:postgresql://localhost:5435/test", "sa", "sa"); conn = DriverManager.getConnection("jdbc:postgresql://localhost:5435/test", "sa", "sa");
stat = conn.createStatement(); stat = conn.createStatement();
stat.execute("create table test(id int primary key, name varchar)"); stat.execute("create table test(id int primary key, name varchar)");
PreparedStatement prep = conn.prepareStatement("insert into test values(?, ?)"); PreparedStatement prep = conn.prepareStatement("insert into test values(?, ?)");
ParameterMetaData meta = prep.getParameterMetaData(); ParameterMetaData meta = prep.getParameterMetaData();
...@@ -92,7 +95,7 @@ public class TestPgServer extends TestBase { ...@@ -92,7 +95,7 @@ public class TestPgServer extends TestBase {
s = rs.getString(3); s = rs.getString(3);
check(s, "PUBLIC"); check(s, "PUBLIC");
checkFalse(rs.next()); checkFalse(rs.next());
conn.setAutoCommit(false); conn.setAutoCommit(false);
stat.execute("delete from test"); stat.execute("delete from test");
conn.rollback(); conn.rollback();
...@@ -103,12 +106,12 @@ public class TestPgServer extends TestBase { ...@@ -103,12 +106,12 @@ public class TestPgServer extends TestBase {
check(1, rs.getInt(1)); check(1, rs.getInt(1));
check("Hallo", rs.getString(2)); check("Hallo", rs.getString(2));
checkFalse(rs.next()); checkFalse(rs.next());
rs = stat.executeQuery("select id, name, pg_get_userbyid(id) from information_schema.users order by id"); rs = stat.executeQuery("select id, name, pg_get_userbyid(id) from information_schema.users order by id");
rs.next(); rs.next();
check(rs.getString(2), rs.getString(3)); check(rs.getString(2), rs.getString(3));
checkFalse(rs.next()); checkFalse(rs.next());
conn.close(); conn.close();
} }
......
...@@ -7,6 +7,9 @@ package org.h2.test.server; ...@@ -7,6 +7,9 @@ package org.h2.test.server;
import org.h2.test.TestBase; import org.h2.test.TestBase;
import org.h2.tools.Server; import org.h2.tools.Server;
/**
* Tests the H2 Console application.
*/
public class TestWeb extends TestBase { public class TestWeb extends TestBase {
public void test() throws Exception { public void test() throws Exception {
...@@ -61,14 +64,14 @@ public class TestWeb extends TestBase { ...@@ -61,14 +64,14 @@ public class TestWeb extends TestBase {
check(result.indexOf("id") >= 0); check(result.indexOf("id") >= 0);
result = client.get(url, "autoCompleteList.do?query=select id x from test te where t"); result = client.get(url, "autoCompleteList.do?query=select id x from test te where t");
check(result.indexOf("te") >= 0); check(result.indexOf("te") >= 0);
result = client.get(url, "query.do?sql=delete from test"); result = client.get(url, "query.do?sql=delete from test");
result = client.get(url, "query.do?sql=@LOOP 10 @STATEMENT insert into test values(?, 'Hello')"); result = client.get(url, "query.do?sql=@LOOP 10 @STATEMENT insert into test values(?, 'Hello')");
result = client.get(url, "query.do?sql=select * from test"); result = client.get(url, "query.do?sql=select * from test");
check(result.indexOf("8") >= 0); check(result.indexOf("8") >= 0);
result = client.get(url, "query.do?sql=@EDIT select * from test"); result = client.get(url, "query.do?sql=@EDIT select * from test");
check(result.indexOf("editRow") >= 0); check(result.indexOf("editRow") >= 0);
result = client.get(url, "query.do?sql=@AUTOCOMMIT TRUE"); result = client.get(url, "query.do?sql=@AUTOCOMMIT TRUE");
result = client.get(url, "query.do?sql=@AUTOCOMMIT FALSE"); result = client.get(url, "query.do?sql=@AUTOCOMMIT FALSE");
result = client.get(url, "query.do?sql=@TRANSACTION_ISOLATION"); result = client.get(url, "query.do?sql=@TRANSACTION_ISOLATION");
...@@ -86,10 +89,10 @@ public class TestWeb extends TestBase { ...@@ -86,10 +89,10 @@ public class TestWeb extends TestBase {
result = client.get(url, "query.do?sql=@MEMORY"); result = client.get(url, "query.do?sql=@MEMORY");
check(result.indexOf("Used") >= 0); check(result.indexOf("Used") >= 0);
result = client.get(url, "query.do?sql=@UDTS"); result = client.get(url, "query.do?sql=@UDTS");
result = client.get(url, "query.do?sql=@INFO"); result = client.get(url, "query.do?sql=@INFO");
check(result.indexOf("getCatalog") >= 0); check(result.indexOf("getCatalog") >= 0);
result = client.get(url, "logout.do"); result = client.get(url, "logout.do");
result = client.get(url, "settingRemove.do?name=_test_"); result = client.get(url, "settingRemove.do?name=_test_");
server.stop(); server.stop();
......
...@@ -12,10 +12,13 @@ import java.net.URL; ...@@ -12,10 +12,13 @@ import java.net.URL;
import org.h2.util.IOUtils; import org.h2.util.IOUtils;
/**
* A simple web browser simulator.
*/
public class WebClient { public class WebClient {
private String sessionId; private String sessionId;
String get(String url) throws IOException { String get(String url) throws IOException {
HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection(); HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
connection.setRequestMethod("GET"); connection.setRequestMethod("GET");
...@@ -30,7 +33,7 @@ public class WebClient { ...@@ -30,7 +33,7 @@ public class WebClient {
connection.disconnect(); connection.disconnect();
return result; return result;
} }
void readSessionId(String result) { void readSessionId(String result) {
int idx = result.indexOf("jsessionid="); int idx = result.indexOf("jsessionid=");
String id = result.substring(idx + "jsessionid=".length()); String id = result.substring(idx + "jsessionid=".length());
...@@ -59,5 +62,5 @@ public class WebClient { ...@@ -59,5 +62,5 @@ public class WebClient {
url += page; url += page;
return get(url); return get(url);
} }
} }
...@@ -10,6 +10,9 @@ import java.util.LinkedList; ...@@ -10,6 +10,9 @@ import java.util.LinkedList;
import org.h2.util.IOUtils; import org.h2.util.IOUtils;
/**
* Catches the output of another process.
*/
class OutputCatcher extends Thread { class OutputCatcher extends Thread {
private InputStream in; private InputStream in;
private LinkedList list = new LinkedList(); private LinkedList list = new LinkedList();
......
...@@ -15,6 +15,9 @@ import java.util.Random; ...@@ -15,6 +15,9 @@ import java.util.Random;
import org.h2.test.TestBase; import org.h2.test.TestBase;
import org.h2.tools.DeleteDbFiles; import org.h2.tools.DeleteDbFiles;
/**
* A b-tree index test.
*/
public class TestBtreeIndex extends TestBase { public class TestBtreeIndex extends TestBase {
public void test() throws Exception { public void test() throws Exception {
......
...@@ -31,10 +31,12 @@ import org.h2.jdbc.JdbcConnection; ...@@ -31,10 +31,12 @@ import org.h2.jdbc.JdbcConnection;
import org.h2.test.TestAll; import org.h2.test.TestAll;
import org.h2.test.TestBase; import org.h2.test.TestBase;
import org.h2.test.db.TestScript; import org.h2.test.db.TestScript;
import org.h2.test.synth.sql.RandomGen;
import org.h2.util.RandomUtils; import org.h2.util.RandomUtils;
/** /**
* This is sometimes called 'Fuzz Testing' * A test that calls random methods with random parameters from JDBC objects.
* This is sometimes called 'Fuzz Testing'.
*/ */
public class TestCrashAPI extends TestBase { public class TestCrashAPI extends TestBase {
public static final Class[] INTERFACES = { Connection.class, PreparedStatement.class, Statement.class, public static final Class[] INTERFACES = { Connection.class, PreparedStatement.class, Statement.class,
......
...@@ -9,6 +9,9 @@ import java.sql.ResultSet; ...@@ -9,6 +9,9 @@ import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Statement; import java.sql.Statement;
/**
* The application code for the {@link TestHalt} application.
*/
public class TestHaltApp extends TestHalt { public class TestHaltApp extends TestHalt {
private int rowCount; private int rowCount;
......
...@@ -18,6 +18,9 @@ import java.util.Random; ...@@ -18,6 +18,9 @@ import java.util.Random;
import org.h2.test.TestBase; import org.h2.test.TestBase;
import org.h2.util.StringUtils; import org.h2.util.StringUtils;
/**
* A test that runs random join statements against two databases and compares the results.
*/
public class TestJoin extends TestBase { public class TestJoin extends TestBase {
private ArrayList connections = new ArrayList(); private ArrayList connections = new ArrayList();
...@@ -54,18 +57,18 @@ public class TestJoin extends TestBase { ...@@ -54,18 +57,18 @@ public class TestJoin extends TestBase {
// connections.add(c2); // connections.add(c2);
/* /*
DROP TABLE ONE; DROP TABLE ONE;
DROP TABLE TWO; DROP TABLE TWO;
CREATE TABLE ONE(A INT PRIMARY KEY, B INT); CREATE TABLE ONE(A INT PRIMARY KEY, B INT);
INSERT INTO ONE VALUES(0, NULL); INSERT INTO ONE VALUES(0, NULL);
INSERT INTO ONE VALUES(1, 0); INSERT INTO ONE VALUES(1, 0);
INSERT INTO ONE VALUES(2, 1); INSERT INTO ONE VALUES(2, 1);
INSERT INTO ONE VALUES(3, 4); INSERT INTO ONE VALUES(3, 4);
CREATE TABLE TWO(A INT PRIMARY KEY, B INT); CREATE TABLE TWO(A INT PRIMARY KEY, B INT);
INSERT INTO TWO VALUES(0, NULL); INSERT INTO TWO VALUES(0, NULL);
INSERT INTO TWO VALUES(1, 0); INSERT INTO TWO VALUES(1, 0);
INSERT INTO TWO VALUES(2, 2); INSERT INTO TWO VALUES(2, 2);
INSERT INTO TWO VALUES(3, 3); INSERT INTO TWO VALUES(3, 3);
INSERT INTO TWO VALUES(4, NULL); INSERT INTO TWO VALUES(4, NULL);
*/ */
......
...@@ -13,6 +13,10 @@ import java.util.Random; ...@@ -13,6 +13,10 @@ import java.util.Random;
import org.h2.test.TestBase; import org.h2.test.TestBase;
/**
* A random recovery test. This test starts a process that executes random operations
* against a database, then kills this process. Afterwards recovery is tested.
*/
public class TestKill extends TestBase { public class TestKill extends TestBase {
Connection conn; Connection conn;
......
...@@ -13,6 +13,9 @@ import java.util.Random; ...@@ -13,6 +13,9 @@ import java.util.Random;
import org.h2.store.FileLister; import org.h2.store.FileLister;
import org.h2.test.TestBase; import org.h2.test.TestBase;
/**
* Test application for {@link TestKill}.
*/
public class TestKillProcess { public class TestKillProcess {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
try { try {
......
...@@ -14,6 +14,10 @@ import java.util.Random; ...@@ -14,6 +14,10 @@ import java.util.Random;
import org.h2.test.TestBase; import org.h2.test.TestBase;
/**
* Standalone recovery test. A new process is started and then killed while it
* executes random statements.
*/
public class TestKillRestart extends TestBase { public class TestKillRestart extends TestBase {
public void test() throws Exception { public void test() throws Exception {
......
...@@ -18,6 +18,9 @@ import org.h2.test.TestBase; ...@@ -18,6 +18,9 @@ import org.h2.test.TestBase;
import org.h2.tools.DeleteDbFiles; import org.h2.tools.DeleteDbFiles;
import org.h2.util.RandomUtils; import org.h2.util.RandomUtils;
/**
* This test executes random SQL statements generated using the BNF tool.
*/
public class TestRandomSQL extends TestBase { public class TestRandomSQL extends TestBase {
private int dbId; private int dbId;
......
...@@ -10,7 +10,11 @@ import java.sql.SQLException; ...@@ -10,7 +10,11 @@ import java.sql.SQLException;
import java.sql.Statement; import java.sql.Statement;
import org.h2.test.TestBase; import org.h2.test.TestBase;
import org.h2.test.synth.sql.RandomGen;
/**
* A test that runs random operations against a table to test the various index implementations.
*/
public class TestSimpleIndex extends TestBase { public class TestSimpleIndex extends TestBase {
Connection conn; Connection conn;
......
...@@ -12,10 +12,12 @@ import java.util.Random; ...@@ -12,10 +12,12 @@ import java.util.Random;
import org.h2.test.TestBase; import org.h2.test.TestBase;
/**
* This test starts multiple threads and executes random operations in each thread.
*/
public class TestThreads extends TestBase implements Runnable { public class TestThreads extends TestBase implements Runnable {
public TestThreads() { public TestThreads() {
} }
public void test() throws Exception { public void test() throws Exception {
......
...@@ -15,6 +15,11 @@ import org.h2.test.TestBase; ...@@ -15,6 +15,11 @@ import org.h2.test.TestBase;
import org.h2.tools.Backup; import org.h2.tools.Backup;
import org.h2.tools.DeleteDbFiles; import org.h2.tools.DeleteDbFiles;
/**
* A recovery test that checks the consistency of a database (if it exists),
* then deletes everything and runs in an endless loop executing random operations.
* This loop is usually stopped by turning off the computer.
*/
public class TestTimer extends TestBase { public class TestTimer extends TestBase {
public void test() throws Exception { public void test() throws Exception {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* Copyright 2004-2007 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html). * Copyright 2004-2007 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group * Initial Developer: H2 Group
*/ */
package org.h2.test.synth; package org.h2.test.synth.sql;
import java.sql.ResultSetMetaData; import java.sql.ResultSetMetaData;
import java.sql.SQLException; import java.sql.SQLException;
...@@ -10,6 +10,9 @@ import java.sql.Types; ...@@ -10,6 +10,9 @@ import java.sql.Types;
import org.h2.value.DataType; import org.h2.value.DataType;
/**
* A column of a table.
*/
class Column { class Column {
private TestSynth config; private TestSynth config;
private String name; private String name;
......
...@@ -2,11 +2,14 @@ ...@@ -2,11 +2,14 @@
* Copyright 2004-2007 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html). * Copyright 2004-2007 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group * Initial Developer: H2 Group
*/ */
package org.h2.test.synth; package org.h2.test.synth.sql;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.HashMap; import java.util.HashMap;
/**
* Represents a statement.
*/
class Command { class Command {
TestSynth config; TestSynth config;
static final int CONNECT = 0, RESET = 1, DISCONNECT = 2, CREATE_TABLE = 3, INSERT = 4, DROP_TABLE = 5, SELECT = 6, static final int CONNECT = 0, RESET = 1, DISCONNECT = 2, CREATE_TABLE = 3, INSERT = 4, DROP_TABLE = 5, SELECT = 6,
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* Copyright 2004-2007 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html). * Copyright 2004-2007 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group * Initial Developer: H2 Group
*/ */
package org.h2.test.synth; package org.h2.test.synth.sql;
import java.sql.Connection; import java.sql.Connection;
import java.sql.DatabaseMetaData; import java.sql.DatabaseMetaData;
...@@ -12,6 +12,9 @@ import java.sql.SQLException; ...@@ -12,6 +12,9 @@ import java.sql.SQLException;
import java.sql.Statement; import java.sql.Statement;
import java.util.ArrayList; import java.util.ArrayList;
/**
* Represents a connection to a real database.
*/
class DbConnection implements DbInterface { class DbConnection implements DbInterface {
private TestSynth config; private TestSynth config;
private int id; private int id;
......
...@@ -2,10 +2,13 @@ ...@@ -2,10 +2,13 @@
* Copyright 2004-2007 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html). * Copyright 2004-2007 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group * Initial Developer: H2 Group
*/ */
package org.h2.test.synth; package org.h2.test.synth.sql;
import java.sql.SQLException; import java.sql.SQLException;
/**
* Represents a connection to a (real or simulated) database.
*/
public interface DbInterface { public interface DbInterface {
void reset() throws SQLException; void reset() throws SQLException;
......
...@@ -2,11 +2,14 @@ ...@@ -2,11 +2,14 @@
* Copyright 2004-2007 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html). * Copyright 2004-2007 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group * Initial Developer: H2 Group
*/ */
package org.h2.test.synth; package org.h2.test.synth.sql;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.ArrayList; import java.util.ArrayList;
/**
* Represents a connection to a simulated database.
*/
public class DbState implements DbInterface { public class DbState implements DbInterface {
private TestSynth config; private TestSynth config;
......
...@@ -2,11 +2,14 @@ ...@@ -2,11 +2,14 @@
* Copyright 2004-2007 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html). * Copyright 2004-2007 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group * Initial Developer: H2 Group
*/ */
package org.h2.test.synth; package org.h2.test.synth.sql;
import java.sql.Types; import java.sql.Types;
import java.util.ArrayList; import java.util.ArrayList;
/**
* Represents an expression.
*/
public class Expression { public class Expression {
boolean isCondition; boolean isCondition;
......
...@@ -2,8 +2,11 @@ ...@@ -2,8 +2,11 @@
* Copyright 2004-2007 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html). * Copyright 2004-2007 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group * Initial Developer: H2 Group
*/ */
package org.h2.test.synth; package org.h2.test.synth.sql;
/**
* Represents an index.
*/
public class Index { public class Index {
Table table; Table table;
String name; String name;
......
...@@ -2,13 +2,16 @@ ...@@ -2,13 +2,16 @@
* Copyright 2004-2007 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html). * Copyright 2004-2007 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group * Initial Developer: H2 Group
*/ */
package org.h2.test.synth; package org.h2.test.synth.sql;
import java.sql.Date; import java.sql.Date;
import java.sql.Time; import java.sql.Time;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.Random; import java.util.Random;
/**
* A random data generator class.
*/
public class RandomGen { public class RandomGen {
private Random random = new Random(); private Random random = new Random();
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* Copyright 2004-2007 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html). * Copyright 2004-2007 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group * Initial Developer: H2 Group
*/ */
package org.h2.test.synth; package org.h2.test.synth.sql;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.io.StringWriter; import java.io.StringWriter;
...@@ -14,6 +14,9 @@ import java.util.Collections; ...@@ -14,6 +14,9 @@ import java.util.Collections;
import org.h2.test.TestBase; import org.h2.test.TestBase;
/**
* Represents an in-memory result.
*/
class Result implements Comparable { class Result implements Comparable {
static final int SUCCESS = 0, BOOLEAN = 1, INT = 2, EXCEPTION = 3, RESULT_SET = 4; static final int SUCCESS = 0, BOOLEAN = 1, INT = 2, EXCEPTION = 3, RESULT_SET = 4;
private int type; private int type;
......
...@@ -2,11 +2,14 @@ ...@@ -2,11 +2,14 @@
* Copyright 2004-2007 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html). * Copyright 2004-2007 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group * Initial Developer: H2 Group
*/ */
package org.h2.test.synth; package org.h2.test.synth.sql;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
/**
* Represents a row.
*/
class Row implements Comparable { class Row implements Comparable {
private Value[] data; private Value[] data;
......
...@@ -2,10 +2,13 @@ ...@@ -2,10 +2,13 @@
* Copyright 2004-2007 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html). * Copyright 2004-2007 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group * Initial Developer: H2 Group
*/ */
package org.h2.test.synth; package org.h2.test.synth.sql;
import java.util.ArrayList; import java.util.ArrayList;
/**
* Represents a table.
*/
class Table { class Table {
private TestSynth config; private TestSynth config;
private String name; private String name;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* Copyright 2004-2007 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html). * Copyright 2004-2007 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group * Initial Developer: H2 Group
*/ */
package org.h2.test.synth; package org.h2.test.synth.sql;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -10,10 +10,15 @@ import org.h2.test.TestAll; ...@@ -10,10 +10,15 @@ import org.h2.test.TestAll;
import org.h2.test.TestBase; import org.h2.test.TestBase;
import org.h2.util.RandomUtils; import org.h2.util.RandomUtils;
// TODO hsqldb: call 1||null should return 1 but returns null /**
// TODO hsqldb: call mod(1) should return invalid parameter count but returns null * A test that generates random SQL statements against a number of databases
* and compares the results.
*/
public class TestSynth extends TestBase { public class TestSynth extends TestBase {
// TODO hsqldb: call 1||null should return 1 but returns null
// TODO hsqldb: call mod(1) should return invalid parameter count but returns null
static final int H2 = 0, H2_MEM = 1, HSQLDB = 2, MYSQL = 3, POSTGRESQL = 4; static final int H2 = 0, H2_MEM = 1, HSQLDB = 2, MYSQL = 3, POSTGRESQL = 4;
private DbState db = new DbState(this); private DbState db = new DbState(this);
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* Copyright 2004-2007 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html). * Copyright 2004-2007 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group * Initial Developer: H2 Group
*/ */
package org.h2.test.synth; package org.h2.test.synth.sql;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.sql.Date; import java.sql.Date;
...@@ -15,6 +15,9 @@ import java.sql.Types; ...@@ -15,6 +15,9 @@ import java.sql.Types;
import org.h2.value.DataType; import org.h2.value.DataType;
/**
* Represents a simple value.
*/
public class Value { public class Value {
private int type; private int type;
private Object data; private Object data;
......
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
Copyright 2004-2007 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
Initial Developer: H2 Group
-->
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head><meta http-equiv="Content-Type" content="text/html;charset=utf-8" /><title>
Javadoc package documentation
</title></head><body style="font: 8pt/130% Tahoma, Arial, Helvetica, sans-serif; font-weight: normal;">
A synthetic test using random SQL statements executed against multiple databases.
</body></html>
\ No newline at end of file
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* Copyright 2004-2007 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html). * Copyright 2004-2007 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group * Initial Developer: H2 Group
*/ */
package org.h2.test.synth; package org.h2.test.synth.thread;
import java.sql.Connection; import java.sql.Connection;
import java.sql.DriverManager; import java.sql.DriverManager;
...@@ -10,6 +10,9 @@ import java.sql.SQLException; ...@@ -10,6 +10,9 @@ import java.sql.SQLException;
import org.h2.test.TestBase; import org.h2.test.TestBase;
/**
* Starts multiple threads and performs random operations on each thread.
*/
public class TestMulti extends TestBase { public class TestMulti extends TestBase {
public volatile boolean stop; public volatile boolean stop;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* Copyright 2004-2007 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html). * Copyright 2004-2007 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group * Initial Developer: H2 Group
*/ */
package org.h2.test.synth; package org.h2.test.synth.thread;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
...@@ -10,6 +10,10 @@ import java.sql.ResultSet; ...@@ -10,6 +10,10 @@ import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Statement; import java.sql.Statement;
/**
* The operation part of {@link TestMulti}.
* Queries and updates a table.
*/
public class TestMultiNews extends TestMultiThread { public class TestMultiNews extends TestMultiThread {
private static final String PREFIX_URL = "http://feeds.wizbangblog.com/WizbangFullFeed?m="; private static final String PREFIX_URL = "http://feeds.wizbangblog.com/WizbangFullFeed?m=";
......
...@@ -2,13 +2,17 @@ ...@@ -2,13 +2,17 @@
* Copyright 2004-2007 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html). * Copyright 2004-2007 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group * Initial Developer: H2 Group
*/ */
package org.h2.test.synth; package org.h2.test.synth.thread;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
/**
* The operation part of {@link TestMulti}.
* Executes simple queries and updates in a table.
*/
public class TestMultiNewsSimple extends TestMultiThread { public class TestMultiNewsSimple extends TestMultiThread {
Connection conn; Connection conn;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* Copyright 2004-2007 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html). * Copyright 2004-2007 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group * Initial Developer: H2 Group
*/ */
package org.h2.test.synth; package org.h2.test.synth.thread;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.sql.Connection; import java.sql.Connection;
...@@ -11,6 +11,10 @@ import java.sql.ResultSet; ...@@ -11,6 +11,10 @@ import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.Random; import java.util.Random;
/**
* The operation part of {@link TestMulti}.
* Queries and updates two tables.
*/
public class TestMultiOrder extends TestMultiThread { public class TestMultiOrder extends TestMultiThread {
Connection conn; Connection conn;
......
...@@ -2,13 +2,16 @@ ...@@ -2,13 +2,16 @@
* Copyright 2004-2007 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html). * Copyright 2004-2007 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group * Initial Developer: H2 Group
*/ */
package org.h2.test.synth; package org.h2.test.synth.thread;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.Random; import java.util.Random;
import org.h2.test.TestBase; import org.h2.test.TestBase;
/**
* The is an abstract operation for {@link TestMulti}.
*/
abstract class TestMultiThread extends Thread { abstract class TestMultiThread extends Thread {
TestMulti base; TestMulti base;
......
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
Copyright 2004-2007 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
Initial Developer: H2 Group
-->
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head><meta http-equiv="Content-Type" content="text/html;charset=utf-8" /><title>
Javadoc package documentation
</title></head><body style="font: 8pt/130% Tahoma, Arial, Helvetica, sans-serif; font-weight: normal;">
Synthetic tests using random operations in multiple threads.
</body></html>
\ No newline at end of file
/*
* Copyright 2004-2007 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.tools.code; package org.h2.tools.code;
import java.io.File; import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
/** /**
* This tool checks that for each .java file there is a package.html file. * This tool checks that for each .java file there is a package.html file,
* and that for each .java file there is at least one (class level) javadoc comment.
*/ */
public class CheckPackageHtml { public class CheckJavadoc {
private boolean hasError; private boolean hasError;
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
new CheckPackageHtml().run(); new CheckJavadoc().run();
} }
void run() throws Exception { void run() throws Exception {
...@@ -43,6 +50,7 @@ public class CheckPackageHtml { ...@@ -43,6 +50,7 @@ public class CheckPackageHtml {
} }
} else { } else {
if (name.endsWith(".java")) { if (name.endsWith(".java")) {
checkJavadoc(file);
return 1; return 1;
} else if (name.equals("package.html")) { } else if (name.equals("package.html")) {
return 2; return 2;
...@@ -51,4 +59,22 @@ public class CheckPackageHtml { ...@@ -51,4 +59,22 @@ public class CheckPackageHtml {
return 0; return 0;
} }
private void checkJavadoc(File file) throws IOException {
RandomAccessFile in = new RandomAccessFile(file, "r");
byte[] data = new byte[(int) file.length()];
in.readFully(data);
in.close();
String text = new String(data);
int comment = text.indexOf("/**");
if (comment < 0) {
System.out.println("No Javadoc comment: " + file.getAbsolutePath());
hasError = true;
}
int open = text.indexOf('{');
if (open < 0 || open < comment) {
System.out.println("No '{' or '{' before the first Javadoc comment: " + file.getAbsolutePath());
hasError = true;
}
}
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论