Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
dd4dd186
提交
dd4dd186
authored
1月 09, 2008
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
--no commit message
--no commit message
上级
e299cfc2
隐藏空白字符变更
内嵌
并排
正在显示
63 个修改的文件
包含
566 行增加
和
355 行删除
+566
-355
build.xml
h2/build.xml
+1
-1
SysProperties.java
h2/src/main/org/h2/constant/SysProperties.java
+2
-0
Constants.java
h2/src/main/org/h2/engine/Constants.java
+0
-2
Database.java
h2/src/main/org/h2/engine/Database.java
+1
-1
JdbcBatchUpdateException.java
h2/src/main/org/h2/jdbc/JdbcBatchUpdateException.java
+4
-1
JdbcSQLException.java
h2/src/main/org/h2/jdbc/JdbcSQLException.java
+1
-1
FileObject.java
h2/src/main/org/h2/store/fs/FileObject.java
+1
-1
FileObjectDisk.java
h2/src/main/org/h2/store/fs/FileObjectDisk.java
+1
-1
TestAll.java
h2/src/test/org/h2/test/TestAll.java
+4
-4
TestCallableStatement.java
h2/src/test/org/h2/test/jdbc/TestCallableStatement.java
+4
-1
TestCancel.java
h2/src/test/org/h2/test/jdbc/TestCancel.java
+4
-4
TestDataSource.java
h2/src/test/org/h2/test/jdbc/TestDataSource.java
+7
-4
TestDatabaseEventListener.java
h2/src/test/org/h2/test/jdbc/TestDatabaseEventListener.java
+7
-4
TestManyJdbcObjects.java
h2/src/test/org/h2/test/jdbc/TestManyJdbcObjects.java
+5
-2
TestMetaData.java
h2/src/test/org/h2/test/jdbc/TestMetaData.java
+3
-0
TestNativeSQL.java
h2/src/test/org/h2/test/jdbc/TestNativeSQL.java
+3
-4
TestPreparedStatement.java
h2/src/test/org/h2/test/jdbc/TestPreparedStatement.java
+16
-13
TestResultSet.java
h2/src/test/org/h2/test/jdbc/TestResultSet.java
+3
-0
TestStatement.java
h2/src/test/org/h2/test/jdbc/TestStatement.java
+3
-0
TestTransactionIsolation.java
h2/src/test/org/h2/test/jdbc/TestTransactionIsolation.java
+3
-0
TestUpdatableResultSet.java
h2/src/test/org/h2/test/jdbc/TestUpdatableResultSet.java
+3
-0
TestXASimple.java
h2/src/test/org/h2/test/jdbc/TestXASimple.java
+4
-1
TestZloty.java
h2/src/test/org/h2/test/jdbc/TestZloty.java
+5
-1
TestXA.java
h2/src/test/org/h2/test/jdbc/xa/TestXA.java
+7
-4
TestXid.java
h2/src/test/org/h2/test/jdbc/xa/TestXid.java
+4
-1
TestNestedLoop.java
h2/src/test/org/h2/test/server/TestNestedLoop.java
+4
-0
TestPgServer.java
h2/src/test/org/h2/test/server/TestPgServer.java
+7
-4
TestWeb.java
h2/src/test/org/h2/test/server/TestWeb.java
+7
-4
WebClient.java
h2/src/test/org/h2/test/server/WebClient.java
+7
-4
OutputCatcher.java
h2/src/test/org/h2/test/synth/OutputCatcher.java
+3
-0
TestBtreeIndex.java
h2/src/test/org/h2/test/synth/TestBtreeIndex.java
+3
-0
TestCrashAPI.java
h2/src/test/org/h2/test/synth/TestCrashAPI.java
+3
-1
TestHalt.java
h2/src/test/org/h2/test/synth/TestHalt.java
+260
-257
TestHaltApp.java
h2/src/test/org/h2/test/synth/TestHaltApp.java
+3
-0
TestJoin.java
h2/src/test/org/h2/test/synth/TestJoin.java
+13
-10
TestKill.java
h2/src/test/org/h2/test/synth/TestKill.java
+4
-0
TestKillProcess.java
h2/src/test/org/h2/test/synth/TestKillProcess.java
+3
-0
TestKillRestart.java
h2/src/test/org/h2/test/synth/TestKillRestart.java
+4
-0
TestRandomSQL.java
h2/src/test/org/h2/test/synth/TestRandomSQL.java
+3
-0
TestSimpleIndex.java
h2/src/test/org/h2/test/synth/TestSimpleIndex.java
+4
-0
TestThreads.java
h2/src/test/org/h2/test/synth/TestThreads.java
+3
-1
TestTimer.java
h2/src/test/org/h2/test/synth/TestTimer.java
+5
-0
Column.java
h2/src/test/org/h2/test/synth/sql/Column.java
+4
-1
Command.java
h2/src/test/org/h2/test/synth/sql/Command.java
+4
-1
DbConnection.java
h2/src/test/org/h2/test/synth/sql/DbConnection.java
+4
-1
DbInterface.java
h2/src/test/org/h2/test/synth/sql/DbInterface.java
+4
-1
DbState.java
h2/src/test/org/h2/test/synth/sql/DbState.java
+4
-1
Expression.java
h2/src/test/org/h2/test/synth/sql/Expression.java
+4
-1
Index.java
h2/src/test/org/h2/test/synth/sql/Index.java
+4
-1
RandomGen.java
h2/src/test/org/h2/test/synth/sql/RandomGen.java
+4
-1
Result.java
h2/src/test/org/h2/test/synth/sql/Result.java
+4
-1
Row.java
h2/src/test/org/h2/test/synth/sql/Row.java
+4
-1
Table.java
h2/src/test/org/h2/test/synth/sql/Table.java
+4
-1
TestSynth.java
h2/src/test/org/h2/test/synth/sql/TestSynth.java
+8
-3
Value.java
h2/src/test/org/h2/test/synth/sql/Value.java
+4
-1
package.html
h2/src/test/org/h2/test/synth/sql/package.html
+13
-0
TestMulti.java
h2/src/test/org/h2/test/synth/thread/TestMulti.java
+4
-1
TestMultiNews.java
h2/src/test/org/h2/test/synth/thread/TestMultiNews.java
+5
-1
TestMultiNewsSimple.java
...rc/test/org/h2/test/synth/thread/TestMultiNewsSimple.java
+5
-1
TestMultiOrder.java
h2/src/test/org/h2/test/synth/thread/TestMultiOrder.java
+5
-1
TestMultiThread.java
h2/src/test/org/h2/test/synth/thread/TestMultiThread.java
+4
-1
package.html
h2/src/test/org/h2/test/synth/thread/package.html
+13
-0
CheckJavadoc.java
h2/src/tools/org/h2/tools/code/CheckJavadoc.java
+29
-3
没有找到文件。
h2/build.xml
浏览文件 @
dd4dd186
...
...
@@ -161,7 +161,7 @@
<fileset
dir=
"src/docsrc"
includes=
"index.html"
/>
<fileset
dir=
"src/docsrc"
includes=
"html/**/*"
excludes=
"**/*.jsp"
/>
</copy>
<java
classname=
"org.h2.tools.code.Check
PackageHtml
"
classpath=
"bin"
/>
<java
classname=
"org.h2.tools.code.Check
Javadoc
"
classpath=
"bin"
/>
<java
classname=
"org.h2.tools.code.CheckTextFiles"
classpath=
"bin"
/>
<java
classname=
"org.h2.tools.doc.GenerateDoc"
classpath=
"bin"
>
<arg
line=
"-in src/docsrc/html -out docs/html"
/>
...
...
h2/src/main/org/h2/constant/SysProperties.java
浏览文件 @
dd4dd186
...
...
@@ -126,4 +126,6 @@ public class SysProperties {
public
static
String
getBaseDir
()
{
return
baseDir
;
}
public
static
final
int
CACHE_SIZE_INDEX_DEFAULT
=
CACHE_SIZE_DEFAULT
>>
CACHE_SIZE_INDEX_SHIFT
;
}
h2/src/main/org/h2/engine/Constants.java
浏览文件 @
dd4dd186
...
...
@@ -4,7 +4,6 @@
*/
package
org
.
h2
.
engine
;
import
org.h2.constant.SysProperties
;
/*
* Release checklist
...
...
@@ -176,5 +175,4 @@ public class Constants {
public
static
final
int
ENCRYPTION_KEY_HASH_ITERATIONS
=
1024
;
public
static
final
String
SCRIPT_SQL
=
"script.sql"
;
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
;
}
h2/src/main/org/h2/engine/Database.java
浏览文件 @
dd4dd186
...
...
@@ -390,7 +390,7 @@ public class Database implements DataHandler {
private
void
openFileIndex
()
throws
SQLException
{
fileIndex
=
new
DiskFile
(
this
,
databaseName
+
Constants
.
SUFFIX_INDEX_FILE
,
accessModeData
,
false
,
logIndexChanges
,
Constant
s
.
CACHE_SIZE_INDEX_DEFAULT
);
logIndexChanges
,
SysPropertie
s
.
CACHE_SIZE_INDEX_DEFAULT
);
}
public
DataPage
getDataPage
()
{
...
...
h2/src/main/org/h2/jdbc/JdbcBatchUpdateException.java
浏览文件 @
dd4dd186
...
...
@@ -9,10 +9,13 @@ import java.io.PrintWriter;
import
java.sql.BatchUpdateException
;
import
java.sql.SQLException
;
/**
* Represents a batch update database exception.
*/
public
class
JdbcBatchUpdateException
extends
BatchUpdateException
{
private
static
final
long
serialVersionUID
=
9006432914018679675L
;
/**
* INTERNAL
*/
...
...
h2/src/main/org/h2/jdbc/JdbcSQLException.java
浏览文件 @
dd4dd186
...
...
@@ -11,7 +11,7 @@ import java.sql.SQLException;
import
org.h2.engine.Constants
;
/**
* Represents a
n
exception.
* Represents a
database
exception.
*/
public
class
JdbcSQLException
extends
SQLException
{
...
...
h2/src/main/org/h2/store/fs/FileObject.java
浏览文件 @
dd4dd186
...
...
@@ -7,7 +7,7 @@ package org.h2.store.fs;
import
java.io.IOException
;
/**
* This interface represents a
RandomAccessF
ile.
* This interface represents a
random access f
ile.
*/
public
interface
FileObject
{
...
...
h2/src/main/org/h2/store/fs/FileObjectDisk.java
浏览文件 @
dd4dd186
...
...
@@ -11,7 +11,7 @@ import java.io.RandomAccessFile;
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
{
...
...
h2/src/test/org/h2/test/TestAll.java
浏览文件 @
dd4dd186
...
...
@@ -74,10 +74,10 @@ import org.h2.test.synth.TestCrashAPI;
import
org.h2.test.synth.TestHaltApp
;
import
org.h2.test.synth.TestJoin
;
import
org.h2.test.synth.TestKill
;
import
org.h2.test.synth.TestMulti
;
import
org.h2.test.synth.TestRandomSQL
;
import
org.h2.test.synth.TestSynth
;
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.TestCache
;
import
org.h2.test.unit.TestCompress
;
...
...
@@ -149,7 +149,6 @@ java org.h2.test.TestAll timer
/*
check no more @author
staging.trace.db.gz
...
...
@@ -160,7 +159,8 @@ http://java.sun.com/j2se/1.4.2/docs/guide/jdbc/getstart/callablestatement.html#1
-Djboss.bind.address=<ip_address>
-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
...
...
h2/src/test/org/h2/test/jdbc/TestCallableStatement.java
浏览文件 @
dd4dd186
...
...
@@ -11,6 +11,9 @@ import java.sql.Statement;
import
org.h2.test.TestBase
;
/**
* Tests for the CallableStatement class.
*/
public
class
TestCallableStatement
extends
TestBase
{
public
void
test
()
throws
Exception
{
...
...
@@ -19,7 +22,7 @@ public class TestCallableStatement extends TestBase {
testPrepare
(
conn
);
conn
.
close
();
}
private
void
testPrepare
(
Connection
conn
)
throws
Exception
{
Statement
stat
=
conn
.
createStatement
();
CallableStatement
call
;
...
...
h2/src/test/org/h2/test/jdbc/TestCancel.java
浏览文件 @
dd4dd186
/*
* Copyright 2004-2007 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
* 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
.
test
.
jdbc
;
...
...
@@ -12,10 +12,10 @@ import java.sql.Statement;
import
org.h2.test.TestBase
;
/**
*
@author Thomas
*
Tests Statement.cancel
*/
public
class
TestCancel
extends
TestBase
{
class
CancelThread
extends
Thread
{
...
...
h2/src/test/org/h2/test/jdbc/TestDataSource.java
浏览文件 @
dd4dd186
...
...
@@ -16,19 +16,22 @@ import javax.transaction.xa.Xid;
import
org.h2.jdbcx.JdbcDataSource
;
import
org.h2.test.TestBase
;
/**
* Tests DataSource and XAConnection.
*/
public
class
TestDataSource
extends
TestBase
{
// public static void main(String[] args) throws Exception {
//
//
// // first, need to start on the command line:
// // rmiregistry 1099
//
//
// // System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
// "com.sun.jndi.ldap.LdapCtxFactory");
// System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
// "com.sun.jndi.rmi.registry.RegistryContextFactory");
// System.setProperty(Context.PROVIDER_URL, "rmi://localhost:1099");
//
//
// JdbcDataSource ds = new JdbcDataSource();
// ds.setURL("jdbc:h2:test");
// ds.setUser("test");
...
...
@@ -36,7 +39,7 @@ public class TestDataSource extends TestBase {
//
// Context ctx = new InitialContext();
// ctx.bind("jdbc/test", ds);
//
//
// DataSource ds2 = (DataSource)ctx.lookup("jdbc/test");
// Connection conn = ds2.getConnection();
// conn.close();
...
...
h2/src/test/org/h2/test/jdbc/TestDatabaseEventListener.java
浏览文件 @
dd4dd186
...
...
@@ -13,8 +13,11 @@ import java.util.Properties;
import
org.h2.api.DatabaseEventListener
;
import
org.h2.test.TestBase
;
/**
* Tests the DatabaseEventListener interface.
*/
public
class
TestDatabaseEventListener
extends
TestBase
implements
DatabaseEventListener
{
private
boolean
calledOpened
,
calledClosingDatabase
,
calledScan
;
public
void
test
()
throws
Exception
{
...
...
@@ -22,7 +25,7 @@ public class TestDatabaseEventListener extends TestBase implements DatabaseEvent
testCloseLog0
(
false
);
testCloseLog0
(
true
);
}
private
void
testCloseLog0
(
boolean
shutdown
)
throws
Exception
{
if
(
config
.
memory
)
{
return
;
...
...
@@ -52,7 +55,7 @@ public class TestDatabaseEventListener extends TestBase implements DatabaseEvent
check
(!
l
.
calledScan
);
}
}
private
void
testCalled
()
throws
Exception
{
Properties
p
=
new
Properties
();
p
.
setProperty
(
"user"
,
"sa"
);
...
...
@@ -65,7 +68,7 @@ public class TestDatabaseEventListener extends TestBase implements DatabaseEvent
check
(
l
.
calledOpened
);
check
(
l
.
calledClosingDatabase
);
}
public
void
closingDatabase
()
{
calledClosingDatabase
=
true
;
}
...
...
h2/src/test/org/h2/test/jdbc/TestManyJdbcObjects.java
浏览文件 @
dd4dd186
/*
* Copyright 2004-2007 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
* 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
.
test
.
jdbc
;
...
...
@@ -13,6 +13,9 @@ import java.sql.Statement;
import
org.h2.constant.SysProperties
;
import
org.h2.test.TestBase
;
/**
* Tests the server by creating many JDBC objects (result sets and so on).
*/
public
class
TestManyJdbcObjects
extends
TestBase
{
public
void
test
()
throws
Exception
{
...
...
h2/src/test/org/h2/test/jdbc/TestMetaData.java
浏览文件 @
dd4dd186
...
...
@@ -15,6 +15,9 @@ import org.h2.engine.Constants;
import
org.h2.test.TestBase
;
import
org.h2.value.DataType
;
/**
* Test for the DatabaseMetaData implementation.
*/
public
class
TestMetaData
extends
TestBase
{
Connection
conn
;
...
...
h2/src/test/org/h2/test/jdbc/TestNativeSQL.java
浏览文件 @
dd4dd186
/*
* Copyright 2004-2007 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
* 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
.
test
.
jdbc
;
...
...
@@ -11,9 +11,8 @@ import java.sql.Statement;
import
org.h2.test.TestBase
;
/**
*
@author Thomas
*
Tests the Connection.nativeSQL method.
*/
public
class
TestNativeSQL
extends
TestBase
{
public
void
test
()
throws
Exception
{
...
...
h2/src/test/org/h2/test/jdbc/TestPreparedStatement.java
浏览文件 @
dd4dd186
...
...
@@ -20,6 +20,9 @@ import java.sql.Types;
import
org.h2.test.TestBase
;
/**
* Tests for the PreparedStatement implementation.
*/
public
class
TestPreparedStatement
extends
TestBase
{
static
final
int
LOB_SIZE
=
4000
,
LOB_SIZE_BIG
=
512
*
1024
;
...
...
@@ -33,7 +36,7 @@ public class TestPreparedStatement extends TestBase {
testPrepareRecompile
(
conn
);
testMaxRowsChange
(
conn
);
testUnknownDataType
(
conn
);
testCancelReuse
(
conn
);
testCancelReuse
(
conn
);
testCoalesce
(
conn
);
testPreparedStatementMetaData
(
conn
);
testDate
(
conn
);
...
...
@@ -54,14 +57,14 @@ public class TestPreparedStatement extends TestBase {
testParameterMetaData
(
conn
);
conn
.
close
();
}
private
void
testTempView
(
Connection
conn
)
throws
Exception
{
Statement
stat
=
conn
.
createStatement
();
PreparedStatement
prep
;
stat
.
execute
(
"CREATE TABLE TEST(FIELD INT PRIMARY KEY)"
);
stat
.
execute
(
"INSERT INTO TEST VALUES(1)"
);
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 "
+
"WHERE T2.FIELD = ?) AS T3 WHERE T3.FIELD = ?"
);
prep
.
setInt
(
1
,
1
);
...
...
@@ -78,12 +81,12 @@ public class TestPreparedStatement extends TestBase {
check
(
2
,
rs
.
getInt
(
1
));
stat
.
execute
(
"DROP TABLE TEST"
);
}
private
void
testInsertFunction
(
Connection
conn
)
throws
Exception
{
Statement
stat
=
conn
.
createStatement
();
PreparedStatement
prep
;
ResultSet
rs
;
stat
.
execute
(
"CREATE TABLE TEST(ID INT, H BINARY)"
);
prep
=
conn
.
prepareStatement
(
"INSERT INTO TEST VALUES(?, HASH('SHA256', STRINGTOUTF8(?), 5))"
);
prep
.
setInt
(
1
,
1
);
...
...
@@ -95,15 +98,15 @@ public class TestPreparedStatement extends TestBase {
rs
=
stat
.
executeQuery
(
"SELECT COUNT(DISTINCT H) FROM TEST"
);
rs
.
next
();
check
(
rs
.
getInt
(
1
),
2
);
stat
.
execute
(
"DROP TABLE TEST"
);
}
private
void
testPrepareRecompile
(
Connection
conn
)
throws
Exception
{
Statement
stat
=
conn
.
createStatement
();
PreparedStatement
prep
;
ResultSet
rs
;
prep
=
conn
.
prepareStatement
(
"SELECT COUNT(*) FROM DUAL WHERE ? IS NULL"
);
prep
.
setString
(
1
,
null
);
prep
.
executeQuery
();
...
...
@@ -131,9 +134,9 @@ public class TestPreparedStatement extends TestBase {
rs
.
next
();
check
(
rs
.
getInt
(
1
),
3
);
stat
.
execute
(
"DROP TABLE t1, t2"
);
}
private
void
testMaxRowsChange
(
Connection
conn
)
throws
Exception
{
PreparedStatement
prep
=
conn
.
prepareStatement
(
"SELECT * FROM SYSTEM_RANGE(1, 100)"
);
ResultSet
rs
;
...
...
@@ -146,7 +149,7 @@ public class TestPreparedStatement extends TestBase {
checkFalse
(
rs
.
next
());
}
}
private
void
testUnknownDataType
(
Connection
conn
)
throws
Exception
{
try
{
PreparedStatement
prep
=
conn
.
prepareStatement
(
...
...
@@ -165,7 +168,7 @@ public class TestPreparedStatement extends TestBase {
prep
.
setInt
(
2
,
2
);
prep
.
execute
();
}
private
void
testCancelReuse
(
Connection
conn
)
throws
Exception
{
conn
.
createStatement
().
execute
(
"CREATE ALIAS YIELD FOR \"java.lang.Thread.yield\""
);
final
PreparedStatement
prep
=
conn
.
prepareStatement
(
"SELECT YIELD() FROM SYSTEM_RANGE(1, 1000000) LIMIT ?"
);
...
...
@@ -192,7 +195,7 @@ public class TestPreparedStatement extends TestBase {
check
(
rs
.
getInt
(
1
),
0
);
checkFalse
(
rs
.
next
());
}
private
void
testCoalesce
(
Connection
conn
)
throws
Exception
{
Statement
stat
=
conn
.
createStatement
();
stat
.
executeUpdate
(
"create table test(tm timestamp)"
);
...
...
h2/src/test/org/h2/test/jdbc/TestResultSet.java
浏览文件 @
dd4dd186
...
...
@@ -25,6 +25,9 @@ import java.util.TimeZone;
import
org.h2.test.TestBase
;
/**
* Tests for the ResultSet implementation.
*/
public
class
TestResultSet
extends
TestBase
{
Connection
conn
;
Statement
stat
;
...
...
h2/src/test/org/h2/test/jdbc/TestStatement.java
浏览文件 @
dd4dd186
...
...
@@ -14,6 +14,9 @@ import org.h2.constant.SysProperties;
import
org.h2.jdbc.JdbcStatement
;
import
org.h2.test.TestBase
;
/**
* Tests for the Statement implementation.
*/
public
class
TestStatement
extends
TestBase
{
Connection
conn
;
...
...
h2/src/test/org/h2/test/jdbc/TestTransactionIsolation.java
浏览文件 @
dd4dd186
...
...
@@ -9,6 +9,9 @@ import java.sql.SQLException;
import
org.h2.test.TestBase
;
/**
* Transaction isolation level tests.
*/
public
class
TestTransactionIsolation
extends
TestBase
{
Connection
conn1
,
conn2
;
...
...
h2/src/test/org/h2/test/jdbc/TestUpdatableResultSet.java
浏览文件 @
dd4dd186
...
...
@@ -19,6 +19,9 @@ import java.sql.Timestamp;
import
org.h2.test.TestBase
;
/**
* Updatable result set tests.
*/
public
class
TestUpdatableResultSet
extends
TestBase
{
public
void
test
()
throws
Exception
{
...
...
h2/src/test/org/h2/test/jdbc/TestXASimple.java
浏览文件 @
dd4dd186
...
...
@@ -8,9 +8,12 @@ import java.sql.Connection;
import
org.h2.jdbcx.JdbcDataSource
;
/**
* A simple XA test.
*/
public
class
TestXASimple
{
int
notYetImplemented
;
private
int
notYetImplemented
;
public
static
void
main
(
String
[]
args
)
throws
Exception
{
Class
.
forName
(
"org.h2.Driver"
);
...
...
h2/src/test/org/h2/test/jdbc/TestZloty.java
浏览文件 @
dd4dd186
...
...
@@ -12,6 +12,10 @@ import java.sql.SQLException;
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
void
test
()
throws
Exception
{
...
...
@@ -61,7 +65,7 @@ public class TestZloty extends TestBase {
/**
* H2 destroyer application ;->
*
*
* @author Maciej Wegorkiewicz
*/
private
void
testZloty
()
throws
Exception
{
...
...
h2/src/test/org/h2/test/jdbc/xa/TestXA.java
浏览文件 @
dd4dd186
...
...
@@ -16,6 +16,9 @@ import org.h2.jdbcx.JdbcDataSource;
import
org.h2.test.TestBase
;
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"
;
...
...
@@ -30,7 +33,7 @@ public class TestXA extends TestBase {
deleteDb
(
baseDir
,
DB_NAME2
);
testXA
(
false
);
}
public
static
class
MyXid
implements
Xid
{
private
byte
[]
branchQualifier
=
new
byte
[
1
];
private
byte
[]
globalTransactionId
=
new
byte
[
1
];
...
...
@@ -43,8 +46,8 @@ public class TestXA extends TestBase {
public
byte
[]
getGlobalTransactionId
()
{
return
globalTransactionId
;
}
}
}
private
void
testXAAutoCommit
()
throws
Exception
{
JdbcDataSource
ds
=
new
JdbcDataSource
();
ds
.
setURL
(
"jdbc:h2:mem:test"
);
...
...
@@ -58,7 +61,7 @@ public class TestXA extends TestBase {
check
(!
c
.
getAutoCommit
());
c
.
close
();
}
private
void
testXA
(
boolean
useOneDatabase
)
{
XAConnection
xaConn1
=
null
;
XAConnection
xaConn2
=
null
;
...
...
h2/src/test/org/h2/test/jdbc/xa/TestXid.java
浏览文件 @
dd4dd186
...
...
@@ -9,6 +9,9 @@ import java.net.UnknownHostException;
import
java.text.NumberFormat
;
import
javax.transaction.xa.Xid
;
/**
* A utility class for the basic XA test.
*/
public
class
TestXid
implements
Xid
{
private
static
final
NumberFormat
NF
;
...
...
@@ -30,7 +33,7 @@ public class TestXid implements Xid {
public
static
void
main
(
String
[]
args
)
{
new
TestXid
();
}
public
TestXid
()
{
this
(
1
);
}
...
...
h2/src/test/org/h2/test/server/TestNestedLoop.java
浏览文件 @
dd4dd186
...
...
@@ -11,6 +11,10 @@ import java.sql.Statement;
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
void
test
()
throws
Exception
{
...
...
h2/src/test/org/h2/test/server/TestPgServer.java
浏览文件 @
dd4dd186
...
...
@@ -16,6 +16,9 @@ import java.sql.Statement;
import
org.h2.test.TestBase
;
import
org.h2.tools.Server
;
/**
* Tests the PostgreSQL server protocol compliant implementation.
*/
public
class
TestPgServer
extends
TestBase
{
public
void
test
()
throws
Exception
{
...
...
@@ -43,7 +46,7 @@ public class TestPgServer extends TestBase {
}
conn
.
close
();
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)"
);
PreparedStatement
prep
=
conn
.
prepareStatement
(
"insert into test values(?, ?)"
);
ParameterMetaData
meta
=
prep
.
getParameterMetaData
();
...
...
@@ -92,7 +95,7 @@ public class TestPgServer extends TestBase {
s
=
rs
.
getString
(
3
);
check
(
s
,
"PUBLIC"
);
checkFalse
(
rs
.
next
());
conn
.
setAutoCommit
(
false
);
stat
.
execute
(
"delete from test"
);
conn
.
rollback
();
...
...
@@ -103,12 +106,12 @@ public class TestPgServer extends TestBase {
check
(
1
,
rs
.
getInt
(
1
));
check
(
"Hallo"
,
rs
.
getString
(
2
));
checkFalse
(
rs
.
next
());
rs
=
stat
.
executeQuery
(
"select id, name, pg_get_userbyid(id) from information_schema.users order by id"
);
rs
.
next
();
check
(
rs
.
getString
(
2
),
rs
.
getString
(
3
));
checkFalse
(
rs
.
next
());
conn
.
close
();
}
...
...
h2/src/test/org/h2/test/server/TestWeb.java
浏览文件 @
dd4dd186
...
...
@@ -7,6 +7,9 @@ package org.h2.test.server;
import
org.h2.test.TestBase
;
import
org.h2.tools.Server
;
/**
* Tests the H2 Console application.
*/
public
class
TestWeb
extends
TestBase
{
public
void
test
()
throws
Exception
{
...
...
@@ -61,14 +64,14 @@ public class TestWeb extends TestBase {
check
(
result
.
indexOf
(
"id"
)
>=
0
);
result
=
client
.
get
(
url
,
"autoCompleteList.do?query=select id x from test te where t"
);
check
(
result
.
indexOf
(
"te"
)
>=
0
);
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=select * from test"
);
check
(
result
.
indexOf
(
"8"
)
>=
0
);
result
=
client
.
get
(
url
,
"query.do?sql=@EDIT select * from test"
);
check
(
result
.
indexOf
(
"editRow"
)
>=
0
);
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=@TRANSACTION_ISOLATION"
);
...
...
@@ -86,10 +89,10 @@ public class TestWeb extends TestBase {
result
=
client
.
get
(
url
,
"query.do?sql=@MEMORY"
);
check
(
result
.
indexOf
(
"Used"
)
>=
0
);
result
=
client
.
get
(
url
,
"query.do?sql=@UDTS"
);
result
=
client
.
get
(
url
,
"query.do?sql=@INFO"
);
check
(
result
.
indexOf
(
"getCatalog"
)
>=
0
);
result
=
client
.
get
(
url
,
"logout.do"
);
result
=
client
.
get
(
url
,
"settingRemove.do?name=_test_"
);
server
.
stop
();
...
...
h2/src/test/org/h2/test/server/WebClient.java
浏览文件 @
dd4dd186
...
...
@@ -12,10 +12,13 @@ import java.net.URL;
import
org.h2.util.IOUtils
;
/**
* A simple web browser simulator.
*/
public
class
WebClient
{
private
String
sessionId
;
String
get
(
String
url
)
throws
IOException
{
HttpURLConnection
connection
=
(
HttpURLConnection
)
new
URL
(
url
).
openConnection
();
connection
.
setRequestMethod
(
"GET"
);
...
...
@@ -30,7 +33,7 @@ public class WebClient {
connection
.
disconnect
();
return
result
;
}
void
readSessionId
(
String
result
)
{
int
idx
=
result
.
indexOf
(
"jsessionid="
);
String
id
=
result
.
substring
(
idx
+
"jsessionid="
.
length
());
...
...
@@ -59,5 +62,5 @@ public class WebClient {
url
+=
page
;
return
get
(
url
);
}
}
h2/src/test/org/h2/test/synth/OutputCatcher.java
浏览文件 @
dd4dd186
...
...
@@ -10,6 +10,9 @@ import java.util.LinkedList;
import
org.h2.util.IOUtils
;
/**
* Catches the output of another process.
*/
class
OutputCatcher
extends
Thread
{
private
InputStream
in
;
private
LinkedList
list
=
new
LinkedList
();
...
...
h2/src/test/org/h2/test/synth/TestBtreeIndex.java
浏览文件 @
dd4dd186
...
...
@@ -15,6 +15,9 @@ import java.util.Random;
import
org.h2.test.TestBase
;
import
org.h2.tools.DeleteDbFiles
;
/**
* A b-tree index test.
*/
public
class
TestBtreeIndex
extends
TestBase
{
public
void
test
()
throws
Exception
{
...
...
h2/src/test/org/h2/test/synth/TestCrashAPI.java
浏览文件 @
dd4dd186
...
...
@@ -31,10 +31,12 @@ import org.h2.jdbc.JdbcConnection;
import
org.h2.test.TestAll
;
import
org.h2.test.TestBase
;
import
org.h2.test.db.TestScript
;
import
org.h2.test.synth.sql.RandomGen
;
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
static
final
Class
[]
INTERFACES
=
{
Connection
.
class
,
PreparedStatement
.
class
,
Statement
.
class
,
...
...
h2/src/test/org/h2/test/synth/TestHalt.java
浏览文件 @
dd4dd186
/*
* 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
.
test
.
synth
;
import
java.io.File
;
import
java.io.FileWriter
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.PrintWriter
;
import
java.sql.Connection
;
import
java.sql.DriverManager
;
import
java.sql.SQLException
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.Random
;
import
org.h2.test.TestAll
;
import
org.h2.test.TestBase
;
import
org.h2.tools.Backup
;
import
org.h2.tools.DeleteDbFiles
;
import
org.h2.util.IOUtils
;
public
abstract
class
TestHalt
extends
TestBase
{
private
SimpleDateFormat
dateFormat
=
new
SimpleDateFormat
(
"MM-dd HH:mm:ss "
);
protected
static
final
int
OP_INSERT
=
1
,
OP_DELETE
=
2
,
OP_UPDATE
=
4
,
OP_SELECT
=
8
;
protected
static
final
int
FLAG_NO_DELAY
=
1
,
FLAG_LOBS
=
2
;
protected
int
operations
,
flags
,
value
;
protected
Connection
conn
;
protected
Random
random
=
new
Random
();
private
int
errorId
;
private
int
sequenceId
;
private
static
final
String
DATABASE_NAME
=
"halt"
;
static
final
String
DIR
=
"dataHalt"
;
private
static
final
String
TRACE_FILE_NAME
=
"haltTrace.trace.db"
;
abstract
void
testInit
()
throws
Exception
;
abstract
void
testCheckAfterCrash
()
throws
Exception
;
abstract
void
testWaitAfterAppStart
()
throws
Exception
;
abstract
void
appStart
()
throws
Exception
;
abstract
void
appRun
()
throws
Exception
;
public
void
test
()
throws
Exception
{
for
(
int
i
=
0
;;
i
++)
{
operations
=
OP_INSERT
|
i
;
flags
=
i
>>
4
;
// flags |= FLAG_NO_DELAY; // | FLAG_LOBS;
try
{
runTest
();
}
catch
(
Throwable
t
)
{
System
.
out
.
println
(
"Error: "
+
t
);
t
.
printStackTrace
();
}
}
}
Connection
getConnection
()
throws
Exception
{
Class
.
forName
(
"org.h2.Driver"
);
return
DriverManager
.
getConnection
(
"jdbc:h2:"
+
baseDir
+
"/halt"
,
"sa"
,
"sa"
);
}
protected
void
start
(
String
[]
args
)
throws
Exception
{
if
(
args
.
length
==
0
)
{
runTest
();
}
else
{
operations
=
Integer
.
parseInt
(
args
[
0
]);
flags
=
Integer
.
parseInt
(
args
[
1
]);
value
=
Integer
.
parseInt
(
args
[
2
]);
runRandom
();
}
}
private
void
runRandom
()
throws
Exception
{
connect
();
try
{
traceOperation
(
"connected, operations:"
+
operations
+
" flags:"
+
flags
+
" value:"
+
value
);
appStart
();
System
.
out
.
println
(
"READY"
);
System
.
out
.
println
(
"READY"
);
System
.
out
.
println
(
"READY"
);
appRun
();
traceOperation
(
"done"
);
}
catch
(
Exception
e
)
{
trace
(
"run"
,
e
);
}
disconnect
();
}
private
void
connect
()
throws
Exception
{
try
{
traceOperation
(
"connecting"
);
conn
=
getConnection
();
}
catch
(
Exception
e
)
{
trace
(
"connect"
,
e
);
e
.
printStackTrace
();
throw
e
;
}
}
protected
void
traceOperation
(
String
s
)
{
trace
(
s
,
null
);
}
protected
void
trace
(
String
s
,
Exception
e
)
{
FileWriter
writer
=
null
;
try
{
File
f
=
new
File
(
baseDir
+
"/"
+
TRACE_FILE_NAME
);
f
.
getParentFile
().
mkdirs
();
writer
=
new
FileWriter
(
f
,
true
);
PrintWriter
w
=
new
PrintWriter
(
writer
);
s
=
dateFormat
.
format
(
new
Date
())
+
": "
+
s
;
w
.
println
(
s
);
if
(
e
!=
null
)
{
e
.
printStackTrace
(
w
);
}
}
catch
(
IOException
e2
)
{
e2
.
printStackTrace
();
}
finally
{
IOUtils
.
closeSilently
(
writer
);
}
}
private
void
runTest
()
throws
Exception
{
traceOperation
(
"delete database -----------------------------"
);
DeleteDbFiles
.
execute
(
baseDir
,
DATABASE_NAME
,
true
);
new
File
(
baseDir
+
"/"
+
TRACE_FILE_NAME
).
delete
();
connect
();
testInit
();
disconnect
();
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
traceOperation
(
"backing up "
+
sequenceId
);
Backup
.
execute
(
baseDir
+
"/haltSeq"
+
sequenceId
+
".zip"
,
baseDir
,
null
,
true
);
sequenceId
++;
// int operations = OP_INSERT;
// OP_DELETE = 1, OP_UPDATE = 2, OP_SELECT = 4;
// int flags = FLAG_NODELAY;
// FLAG_NO_DELAY = 1, FLAG_AUTO_COMMIT = 2, FLAG_SMALL_CACHE = 4;
int
value
=
random
.
nextInt
(
1000
);
// for Derby and HSQLDB
// String classPath = "-cp
// .;D:/data/java/hsqldb.jar;D:/data/java/derby.jar";
String
classPath
=
""
;
String
command
=
"java "
+
classPath
+
" "
+
getClass
().
getName
()
+
" "
+
operations
+
" "
+
flags
+
" "
+
value
;
traceOperation
(
"start: "
+
command
);
Process
p
=
Runtime
.
getRuntime
().
exec
(
command
);
InputStream
in
=
p
.
getInputStream
();
OutputCatcher
catcher
=
new
OutputCatcher
(
in
);
catcher
.
start
();
String
s
=
catcher
.
readLine
(
5000
);
if
(
s
==
null
)
{
throw
new
IOException
(
"No reply from process, command: "
+
command
);
}
else
if
(
s
.
startsWith
(
"READY"
))
{
traceOperation
(
"got reply: "
+
s
);
}
testWaitAfterAppStart
();
p
.
destroy
();
try
{
traceOperation
(
"backing up "
+
sequenceId
);
Backup
.
execute
(
baseDir
+
"/haltSeq"
+
sequenceId
+
".zip"
,
baseDir
,
null
,
true
);
// new File(BASE_DIR + "/haltSeq" + (sequenceId-20) +
// ".zip").delete();
connect
();
testCheckAfterCrash
();
}
catch
(
Exception
e
)
{
File
zip
=
new
File
(
baseDir
+
"/haltSeq"
+
sequenceId
+
".zip"
);
File
zipId
=
new
File
(
baseDir
+
"/haltSeq"
+
sequenceId
+
"-"
+
errorId
+
".zip"
);
zip
.
renameTo
(
zipId
);
printTime
(
"ERROR: "
+
sequenceId
+
" "
+
errorId
+
" "
+
e
.
toString
());
e
.
printStackTrace
();
errorId
++;
}
finally
{
sequenceId
++;
disconnect
();
}
}
}
protected
void
disconnect
()
{
try
{
traceOperation
(
"disconnect"
);
conn
.
close
();
}
catch
(
Exception
e
)
{
trace
(
"disconnect"
,
e
);
}
}
public
Connection
getConnectionHSQLDB
()
throws
Exception
{
File
lock
=
new
File
(
"test.lck"
);
while
(
lock
.
exists
())
{
lock
.
delete
();
System
.
gc
();
}
Class
.
forName
(
"org.hsqldb.jdbcDriver"
);
return
DriverManager
.
getConnection
(
"jdbc:hsqldb:test"
,
"sa"
,
""
);
}
public
Connection
getConnectionDerby
()
throws
Exception
{
File
lock
=
new
File
(
"test3/db.lck"
);
while
(
lock
.
exists
())
{
lock
.
delete
();
System
.
gc
();
}
Class
.
forName
(
"org.apache.derby.jdbc.EmbeddedDriver"
).
newInstance
();
try
{
return
DriverManager
.
getConnection
(
"jdbc:derby:test3;create=true"
,
"sa"
,
"sa"
);
}
catch
(
SQLException
e
)
{
Exception
e2
=
e
;
do
{
e
.
printStackTrace
();
e
=
e
.
getNextException
();
}
while
(
e
!=
null
);
throw
e2
;
}
}
public
void
disconnectHSQLDB
()
{
try
{
conn
.
createStatement
().
execute
(
"SHUTDOWN"
);
}
catch
(
Exception
e
)
{
// ignore
}
// super.disconnect();
}
public
void
disconnectDerby
()
{
// super.disconnect();
try
{
Class
.
forName
(
"org.apache.derby.jdbc.EmbeddedDriver"
);
DriverManager
.
getConnection
(
"jdbc:derby:;shutdown=true"
,
"sa"
,
"sa"
);
}
catch
(
Exception
e
)
{
// ignore
}
}
protected
String
getRandomString
(
int
len
)
{
StringBuffer
buff
=
new
StringBuffer
();
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
buff
.
append
(
'a'
+
random
.
nextInt
(
20
));
}
return
buff
.
toString
();
}
public
TestBase
init
(
TestAll
conf
)
throws
Exception
{
super
.
init
(
conf
);
baseDir
=
DIR
;
return
this
;
}
}
/*
* 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
.
test
.
synth
;
import
java.io.File
;
import
java.io.FileWriter
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.PrintWriter
;
import
java.sql.Connection
;
import
java.sql.DriverManager
;
import
java.sql.SQLException
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.Random
;
import
org.h2.test.TestAll
;
import
org.h2.test.TestBase
;
import
org.h2.tools.Backup
;
import
org.h2.tools.DeleteDbFiles
;
import
org.h2.util.IOUtils
;
/**
* Tests database recovery by destroying a process that writes to the database.
*/
public
abstract
class
TestHalt
extends
TestBase
{
private
SimpleDateFormat
dateFormat
=
new
SimpleDateFormat
(
"MM-dd HH:mm:ss "
);
protected
static
final
int
OP_INSERT
=
1
,
OP_DELETE
=
2
,
OP_UPDATE
=
4
,
OP_SELECT
=
8
;
protected
static
final
int
FLAG_NO_DELAY
=
1
,
FLAG_LOBS
=
2
;
protected
int
operations
,
flags
,
value
;
protected
Connection
conn
;
protected
Random
random
=
new
Random
();
private
int
errorId
;
private
int
sequenceId
;
private
static
final
String
DATABASE_NAME
=
"halt"
;
static
final
String
DIR
=
"dataHalt"
;
private
static
final
String
TRACE_FILE_NAME
=
"haltTrace.trace.db"
;
abstract
void
testInit
()
throws
Exception
;
abstract
void
testCheckAfterCrash
()
throws
Exception
;
abstract
void
testWaitAfterAppStart
()
throws
Exception
;
abstract
void
appStart
()
throws
Exception
;
abstract
void
appRun
()
throws
Exception
;
public
void
test
()
throws
Exception
{
for
(
int
i
=
0
;;
i
++)
{
operations
=
OP_INSERT
|
i
;
flags
=
i
>>
4
;
// flags |= FLAG_NO_DELAY; // | FLAG_LOBS;
try
{
runTest
();
}
catch
(
Throwable
t
)
{
System
.
out
.
println
(
"Error: "
+
t
);
t
.
printStackTrace
();
}
}
}
Connection
getConnection
()
throws
Exception
{
Class
.
forName
(
"org.h2.Driver"
);
return
DriverManager
.
getConnection
(
"jdbc:h2:"
+
baseDir
+
"/halt"
,
"sa"
,
"sa"
);
}
protected
void
start
(
String
[]
args
)
throws
Exception
{
if
(
args
.
length
==
0
)
{
runTest
();
}
else
{
operations
=
Integer
.
parseInt
(
args
[
0
]);
flags
=
Integer
.
parseInt
(
args
[
1
]);
value
=
Integer
.
parseInt
(
args
[
2
]);
runRandom
();
}
}
private
void
runRandom
()
throws
Exception
{
connect
();
try
{
traceOperation
(
"connected, operations:"
+
operations
+
" flags:"
+
flags
+
" value:"
+
value
);
appStart
();
System
.
out
.
println
(
"READY"
);
System
.
out
.
println
(
"READY"
);
System
.
out
.
println
(
"READY"
);
appRun
();
traceOperation
(
"done"
);
}
catch
(
Exception
e
)
{
trace
(
"run"
,
e
);
}
disconnect
();
}
private
void
connect
()
throws
Exception
{
try
{
traceOperation
(
"connecting"
);
conn
=
getConnection
();
}
catch
(
Exception
e
)
{
trace
(
"connect"
,
e
);
e
.
printStackTrace
();
throw
e
;
}
}
protected
void
traceOperation
(
String
s
)
{
trace
(
s
,
null
);
}
protected
void
trace
(
String
s
,
Exception
e
)
{
FileWriter
writer
=
null
;
try
{
File
f
=
new
File
(
baseDir
+
"/"
+
TRACE_FILE_NAME
);
f
.
getParentFile
().
mkdirs
();
writer
=
new
FileWriter
(
f
,
true
);
PrintWriter
w
=
new
PrintWriter
(
writer
);
s
=
dateFormat
.
format
(
new
Date
())
+
": "
+
s
;
w
.
println
(
s
);
if
(
e
!=
null
)
{
e
.
printStackTrace
(
w
);
}
}
catch
(
IOException
e2
)
{
e2
.
printStackTrace
();
}
finally
{
IOUtils
.
closeSilently
(
writer
);
}
}
private
void
runTest
()
throws
Exception
{
traceOperation
(
"delete database -----------------------------"
);
DeleteDbFiles
.
execute
(
baseDir
,
DATABASE_NAME
,
true
);
new
File
(
baseDir
+
"/"
+
TRACE_FILE_NAME
).
delete
();
connect
();
testInit
();
disconnect
();
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
traceOperation
(
"backing up "
+
sequenceId
);
Backup
.
execute
(
baseDir
+
"/haltSeq"
+
sequenceId
+
".zip"
,
baseDir
,
null
,
true
);
sequenceId
++;
// int operations = OP_INSERT;
// OP_DELETE = 1, OP_UPDATE = 2, OP_SELECT = 4;
// int flags = FLAG_NODELAY;
// FLAG_NO_DELAY = 1, FLAG_AUTO_COMMIT = 2, FLAG_SMALL_CACHE = 4;
int
value
=
random
.
nextInt
(
1000
);
// for Derby and HSQLDB
// String classPath = "-cp
// .;D:/data/java/hsqldb.jar;D:/data/java/derby.jar";
String
classPath
=
""
;
String
command
=
"java "
+
classPath
+
" "
+
getClass
().
getName
()
+
" "
+
operations
+
" "
+
flags
+
" "
+
value
;
traceOperation
(
"start: "
+
command
);
Process
p
=
Runtime
.
getRuntime
().
exec
(
command
);
InputStream
in
=
p
.
getInputStream
();
OutputCatcher
catcher
=
new
OutputCatcher
(
in
);
catcher
.
start
();
String
s
=
catcher
.
readLine
(
5000
);
if
(
s
==
null
)
{
throw
new
IOException
(
"No reply from process, command: "
+
command
);
}
else
if
(
s
.
startsWith
(
"READY"
))
{
traceOperation
(
"got reply: "
+
s
);
}
testWaitAfterAppStart
();
p
.
destroy
();
try
{
traceOperation
(
"backing up "
+
sequenceId
);
Backup
.
execute
(
baseDir
+
"/haltSeq"
+
sequenceId
+
".zip"
,
baseDir
,
null
,
true
);
// new File(BASE_DIR + "/haltSeq" + (sequenceId-20) +
// ".zip").delete();
connect
();
testCheckAfterCrash
();
}
catch
(
Exception
e
)
{
File
zip
=
new
File
(
baseDir
+
"/haltSeq"
+
sequenceId
+
".zip"
);
File
zipId
=
new
File
(
baseDir
+
"/haltSeq"
+
sequenceId
+
"-"
+
errorId
+
".zip"
);
zip
.
renameTo
(
zipId
);
printTime
(
"ERROR: "
+
sequenceId
+
" "
+
errorId
+
" "
+
e
.
toString
());
e
.
printStackTrace
();
errorId
++;
}
finally
{
sequenceId
++;
disconnect
();
}
}
}
protected
void
disconnect
()
{
try
{
traceOperation
(
"disconnect"
);
conn
.
close
();
}
catch
(
Exception
e
)
{
trace
(
"disconnect"
,
e
);
}
}
public
Connection
getConnectionHSQLDB
()
throws
Exception
{
File
lock
=
new
File
(
"test.lck"
);
while
(
lock
.
exists
())
{
lock
.
delete
();
System
.
gc
();
}
Class
.
forName
(
"org.hsqldb.jdbcDriver"
);
return
DriverManager
.
getConnection
(
"jdbc:hsqldb:test"
,
"sa"
,
""
);
}
public
Connection
getConnectionDerby
()
throws
Exception
{
File
lock
=
new
File
(
"test3/db.lck"
);
while
(
lock
.
exists
())
{
lock
.
delete
();
System
.
gc
();
}
Class
.
forName
(
"org.apache.derby.jdbc.EmbeddedDriver"
).
newInstance
();
try
{
return
DriverManager
.
getConnection
(
"jdbc:derby:test3;create=true"
,
"sa"
,
"sa"
);
}
catch
(
SQLException
e
)
{
Exception
e2
=
e
;
do
{
e
.
printStackTrace
();
e
=
e
.
getNextException
();
}
while
(
e
!=
null
);
throw
e2
;
}
}
public
void
disconnectHSQLDB
()
{
try
{
conn
.
createStatement
().
execute
(
"SHUTDOWN"
);
}
catch
(
Exception
e
)
{
// ignore
}
// super.disconnect();
}
public
void
disconnectDerby
()
{
// super.disconnect();
try
{
Class
.
forName
(
"org.apache.derby.jdbc.EmbeddedDriver"
);
DriverManager
.
getConnection
(
"jdbc:derby:;shutdown=true"
,
"sa"
,
"sa"
);
}
catch
(
Exception
e
)
{
// ignore
}
}
protected
String
getRandomString
(
int
len
)
{
StringBuffer
buff
=
new
StringBuffer
();
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
buff
.
append
(
'a'
+
random
.
nextInt
(
20
));
}
return
buff
.
toString
();
}
public
TestBase
init
(
TestAll
conf
)
throws
Exception
{
super
.
init
(
conf
);
baseDir
=
DIR
;
return
this
;
}
}
h2/src/test/org/h2/test/synth/TestHaltApp.java
浏览文件 @
dd4dd186
...
...
@@ -9,6 +9,9 @@ import java.sql.ResultSet;
import
java.sql.SQLException
;
import
java.sql.Statement
;
/**
* The application code for the {@link TestHalt} application.
*/
public
class
TestHaltApp
extends
TestHalt
{
private
int
rowCount
;
...
...
h2/src/test/org/h2/test/synth/TestJoin.java
浏览文件 @
dd4dd186
...
...
@@ -18,6 +18,9 @@ import java.util.Random;
import
org.h2.test.TestBase
;
import
org.h2.util.StringUtils
;
/**
* A test that runs random join statements against two databases and compares the results.
*/
public
class
TestJoin
extends
TestBase
{
private
ArrayList
connections
=
new
ArrayList
();
...
...
@@ -54,18 +57,18 @@ public class TestJoin extends TestBase {
// connections.add(c2);
/*
DROP TABLE ONE;
DROP TABLE TWO;
CREATE TABLE ONE(A INT PRIMARY KEY, B INT);
INSERT INTO ONE VALUES(0, NULL);
DROP TABLE ONE;
DROP TABLE TWO;
CREATE TABLE ONE(A INT PRIMARY KEY, B INT);
INSERT INTO ONE VALUES(0, NULL);
INSERT INTO ONE VALUES(1, 0);
INSERT INTO ONE VALUES(2, 1);
INSERT INTO ONE VALUES(3, 4);
CREATE TABLE TWO(A INT PRIMARY KEY, B INT);
INSERT INTO ONE VALUES(2, 1);
INSERT INTO ONE VALUES(3, 4);
CREATE TABLE TWO(A INT PRIMARY KEY, B INT);
INSERT INTO TWO VALUES(0, NULL);
INSERT INTO TWO VALUES(1, 0);
INSERT INTO TWO VALUES(2, 2);
INSERT INTO TWO VALUES(3, 3);
INSERT INTO TWO VALUES(1, 0);
INSERT INTO TWO VALUES(2, 2);
INSERT INTO TWO VALUES(3, 3);
INSERT INTO TWO VALUES(4, NULL);
*/
...
...
h2/src/test/org/h2/test/synth/TestKill.java
浏览文件 @
dd4dd186
...
...
@@ -13,6 +13,10 @@ import java.util.Random;
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
{
Connection
conn
;
...
...
h2/src/test/org/h2/test/synth/TestKillProcess.java
浏览文件 @
dd4dd186
...
...
@@ -13,6 +13,9 @@ import java.util.Random;
import
org.h2.store.FileLister
;
import
org.h2.test.TestBase
;
/**
* Test application for {@link TestKill}.
*/
public
class
TestKillProcess
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
try
{
...
...
h2/src/test/org/h2/test/synth/TestKillRestart.java
浏览文件 @
dd4dd186
...
...
@@ -14,6 +14,10 @@ import java.util.Random;
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
void
test
()
throws
Exception
{
...
...
h2/src/test/org/h2/test/synth/TestRandomSQL.java
浏览文件 @
dd4dd186
...
...
@@ -18,6 +18,9 @@ import org.h2.test.TestBase;
import
org.h2.tools.DeleteDbFiles
;
import
org.h2.util.RandomUtils
;
/**
* This test executes random SQL statements generated using the BNF tool.
*/
public
class
TestRandomSQL
extends
TestBase
{
private
int
dbId
;
...
...
h2/src/test/org/h2/test/synth/TestSimpleIndex.java
浏览文件 @
dd4dd186
...
...
@@ -10,7 +10,11 @@ import java.sql.SQLException;
import
java.sql.Statement
;
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
{
Connection
conn
;
...
...
h2/src/test/org/h2/test/synth/TestThreads.java
浏览文件 @
dd4dd186
...
...
@@ -12,10 +12,12 @@ import java.util.Random;
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
TestThreads
()
{
}
public
void
test
()
throws
Exception
{
...
...
h2/src/test/org/h2/test/synth/TestTimer.java
浏览文件 @
dd4dd186
...
...
@@ -15,6 +15,11 @@ import org.h2.test.TestBase;
import
org.h2.tools.Backup
;
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
void
test
()
throws
Exception
{
...
...
h2/src/test/org/h2/test/synth/Column.java
→
h2/src/test/org/h2/test/synth/
sql/
Column.java
浏览文件 @
dd4dd186
...
...
@@ -2,7 +2,7 @@
* 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
.
test
.
synth
;
package
org
.
h2
.
test
.
synth
.
sql
;
import
java.sql.ResultSetMetaData
;
import
java.sql.SQLException
;
...
...
@@ -10,6 +10,9 @@ import java.sql.Types;
import
org.h2.value.DataType
;
/**
* A column of a table.
*/
class
Column
{
private
TestSynth
config
;
private
String
name
;
...
...
h2/src/test/org/h2/test/synth/Command.java
→
h2/src/test/org/h2/test/synth/
sql/
Command.java
浏览文件 @
dd4dd186
...
...
@@ -2,11 +2,14 @@
* 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
.
test
.
synth
;
package
org
.
h2
.
test
.
synth
.
sql
;
import
java.sql.SQLException
;
import
java.util.HashMap
;
/**
* Represents a statement.
*/
class
Command
{
TestSynth
config
;
static
final
int
CONNECT
=
0
,
RESET
=
1
,
DISCONNECT
=
2
,
CREATE_TABLE
=
3
,
INSERT
=
4
,
DROP_TABLE
=
5
,
SELECT
=
6
,
...
...
h2/src/test/org/h2/test/synth/DbConnection.java
→
h2/src/test/org/h2/test/synth/
sql/
DbConnection.java
浏览文件 @
dd4dd186
...
...
@@ -2,7 +2,7 @@
* 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
.
test
.
synth
;
package
org
.
h2
.
test
.
synth
.
sql
;
import
java.sql.Connection
;
import
java.sql.DatabaseMetaData
;
...
...
@@ -12,6 +12,9 @@ import java.sql.SQLException;
import
java.sql.Statement
;
import
java.util.ArrayList
;
/**
* Represents a connection to a real database.
*/
class
DbConnection
implements
DbInterface
{
private
TestSynth
config
;
private
int
id
;
...
...
h2/src/test/org/h2/test/synth/DbInterface.java
→
h2/src/test/org/h2/test/synth/
sql/
DbInterface.java
浏览文件 @
dd4dd186
...
...
@@ -2,10 +2,13 @@
* 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
.
test
.
synth
;
package
org
.
h2
.
test
.
synth
.
sql
;
import
java.sql.SQLException
;
/**
* Represents a connection to a (real or simulated) database.
*/
public
interface
DbInterface
{
void
reset
()
throws
SQLException
;
...
...
h2/src/test/org/h2/test/synth/DbState.java
→
h2/src/test/org/h2/test/synth/
sql/
DbState.java
浏览文件 @
dd4dd186
...
...
@@ -2,11 +2,14 @@
* 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
.
test
.
synth
;
package
org
.
h2
.
test
.
synth
.
sql
;
import
java.sql.SQLException
;
import
java.util.ArrayList
;
/**
* Represents a connection to a simulated database.
*/
public
class
DbState
implements
DbInterface
{
private
TestSynth
config
;
...
...
h2/src/test/org/h2/test/synth/Expression.java
→
h2/src/test/org/h2/test/synth/
sql/
Expression.java
浏览文件 @
dd4dd186
...
...
@@ -2,11 +2,14 @@
* 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
.
test
.
synth
;
package
org
.
h2
.
test
.
synth
.
sql
;
import
java.sql.Types
;
import
java.util.ArrayList
;
/**
* Represents an expression.
*/
public
class
Expression
{
boolean
isCondition
;
...
...
h2/src/test/org/h2/test/synth/Index.java
→
h2/src/test/org/h2/test/synth/
sql/
Index.java
浏览文件 @
dd4dd186
...
...
@@ -2,8 +2,11 @@
* 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
.
test
.
synth
;
package
org
.
h2
.
test
.
synth
.
sql
;
/**
* Represents an index.
*/
public
class
Index
{
Table
table
;
String
name
;
...
...
h2/src/test/org/h2/test/synth/RandomGen.java
→
h2/src/test/org/h2/test/synth/
sql/
RandomGen.java
浏览文件 @
dd4dd186
...
...
@@ -2,13 +2,16 @@
* 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
.
test
.
synth
;
package
org
.
h2
.
test
.
synth
.
sql
;
import
java.sql.Date
;
import
java.sql.Time
;
import
java.sql.Timestamp
;
import
java.util.Random
;
/**
* A random data generator class.
*/
public
class
RandomGen
{
private
Random
random
=
new
Random
();
...
...
h2/src/test/org/h2/test/synth/Result.java
→
h2/src/test/org/h2/test/synth/
sql/
Result.java
浏览文件 @
dd4dd186
...
...
@@ -2,7 +2,7 @@
* 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
.
test
.
synth
;
package
org
.
h2
.
test
.
synth
.
sql
;
import
java.io.PrintWriter
;
import
java.io.StringWriter
;
...
...
@@ -14,6 +14,9 @@ import java.util.Collections;
import
org.h2.test.TestBase
;
/**
* Represents an in-memory result.
*/
class
Result
implements
Comparable
{
static
final
int
SUCCESS
=
0
,
BOOLEAN
=
1
,
INT
=
2
,
EXCEPTION
=
3
,
RESULT_SET
=
4
;
private
int
type
;
...
...
h2/src/test/org/h2/test/synth/Row.java
→
h2/src/test/org/h2/test/synth/
sql/
Row.java
浏览文件 @
dd4dd186
...
...
@@ -2,11 +2,14 @@
* 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
.
test
.
synth
;
package
org
.
h2
.
test
.
synth
.
sql
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
/**
* Represents a row.
*/
class
Row
implements
Comparable
{
private
Value
[]
data
;
...
...
h2/src/test/org/h2/test/synth/Table.java
→
h2/src/test/org/h2/test/synth/
sql/
Table.java
浏览文件 @
dd4dd186
...
...
@@ -2,10 +2,13 @@
* 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
.
test
.
synth
;
package
org
.
h2
.
test
.
synth
.
sql
;
import
java.util.ArrayList
;
/**
* Represents a table.
*/
class
Table
{
private
TestSynth
config
;
private
String
name
;
...
...
h2/src/test/org/h2/test/synth/TestSynth.java
→
h2/src/test/org/h2/test/synth/
sql/
TestSynth.java
浏览文件 @
dd4dd186
...
...
@@ -2,7 +2,7 @@
* 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
.
test
.
synth
;
package
org
.
h2
.
test
.
synth
.
sql
;
import
java.util.ArrayList
;
...
...
@@ -10,10 +10,15 @@ import org.h2.test.TestAll;
import
org.h2.test.TestBase
;
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
{
// 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
;
private
DbState
db
=
new
DbState
(
this
);
...
...
h2/src/test/org/h2/test/synth/Value.java
→
h2/src/test/org/h2/test/synth/
sql/
Value.java
浏览文件 @
dd4dd186
...
...
@@ -2,7 +2,7 @@
* 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
.
test
.
synth
;
package
org
.
h2
.
test
.
synth
.
sql
;
import
java.math.BigDecimal
;
import
java.sql.Date
;
...
...
@@ -15,6 +15,9 @@ import java.sql.Types;
import
org.h2.value.DataType
;
/**
* Represents a simple value.
*/
public
class
Value
{
private
int
type
;
private
Object
data
;
...
...
h2/src/test/org/h2/test/synth/sql/package.html
0 → 100644
浏览文件 @
dd4dd186
<!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
h2/src/test/org/h2/test/synth/TestMulti.java
→
h2/src/test/org/h2/test/synth/
thread/
TestMulti.java
浏览文件 @
dd4dd186
...
...
@@ -2,7 +2,7 @@
* 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
.
test
.
synth
;
package
org
.
h2
.
test
.
synth
.
thread
;
import
java.sql.Connection
;
import
java.sql.DriverManager
;
...
...
@@ -10,6 +10,9 @@ import java.sql.SQLException;
import
org.h2.test.TestBase
;
/**
* Starts multiple threads and performs random operations on each thread.
*/
public
class
TestMulti
extends
TestBase
{
public
volatile
boolean
stop
;
...
...
h2/src/test/org/h2/test/synth/TestMultiNews.java
→
h2/src/test/org/h2/test/synth/
thread/
TestMultiNews.java
浏览文件 @
dd4dd186
...
...
@@ -2,7 +2,7 @@
* 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
.
test
.
synth
;
package
org
.
h2
.
test
.
synth
.
thread
;
import
java.sql.Connection
;
import
java.sql.PreparedStatement
;
...
...
@@ -10,6 +10,10 @@ import java.sql.ResultSet;
import
java.sql.SQLException
;
import
java.sql.Statement
;
/**
* The operation part of {@link TestMulti}.
* Queries and updates a table.
*/
public
class
TestMultiNews
extends
TestMultiThread
{
private
static
final
String
PREFIX_URL
=
"http://feeds.wizbangblog.com/WizbangFullFeed?m="
;
...
...
h2/src/test/org/h2/test/synth/TestMultiNewsSimple.java
→
h2/src/test/org/h2/test/synth/
thread/
TestMultiNewsSimple.java
浏览文件 @
dd4dd186
...
...
@@ -2,13 +2,17 @@
* 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
.
test
.
synth
;
package
org
.
h2
.
test
.
synth
.
thread
;
import
java.sql.Connection
;
import
java.sql.PreparedStatement
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
/**
* The operation part of {@link TestMulti}.
* Executes simple queries and updates in a table.
*/
public
class
TestMultiNewsSimple
extends
TestMultiThread
{
Connection
conn
;
...
...
h2/src/test/org/h2/test/synth/TestMultiOrder.java
→
h2/src/test/org/h2/test/synth/
thread/
TestMultiOrder.java
浏览文件 @
dd4dd186
...
...
@@ -2,7 +2,7 @@
* 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
.
test
.
synth
;
package
org
.
h2
.
test
.
synth
.
thread
;
import
java.math.BigDecimal
;
import
java.sql.Connection
;
...
...
@@ -11,6 +11,10 @@ import java.sql.ResultSet;
import
java.sql.SQLException
;
import
java.util.Random
;
/**
* The operation part of {@link TestMulti}.
* Queries and updates two tables.
*/
public
class
TestMultiOrder
extends
TestMultiThread
{
Connection
conn
;
...
...
h2/src/test/org/h2/test/synth/TestMultiThread.java
→
h2/src/test/org/h2/test/synth/
thread/
TestMultiThread.java
浏览文件 @
dd4dd186
...
...
@@ -2,13 +2,16 @@
* 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
.
test
.
synth
;
package
org
.
h2
.
test
.
synth
.
thread
;
import
java.sql.SQLException
;
import
java.util.Random
;
import
org.h2.test.TestBase
;
/**
* The is an abstract operation for {@link TestMulti}.
*/
abstract
class
TestMultiThread
extends
Thread
{
TestMulti
base
;
...
...
h2/src/test/org/h2/test/synth/thread/package.html
0 → 100644
浏览文件 @
dd4dd186
<!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
h2/src/tools/org/h2/tools/code/Check
PackageHtml
.java
→
h2/src/tools/org/h2/tools/code/Check
Javadoc
.java
浏览文件 @
dd4dd186
/*
* 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
;
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
Check
PackageHtml
{
public
class
Check
Javadoc
{
private
boolean
hasError
;
public
static
void
main
(
String
[]
args
)
throws
Exception
{
new
Check
PackageHtml
().
run
();
new
Check
Javadoc
().
run
();
}
void
run
()
throws
Exception
{
...
...
@@ -43,6 +50,7 @@ public class CheckPackageHtml {
}
}
else
{
if
(
name
.
endsWith
(
".java"
))
{
checkJavadoc
(
file
);
return
1
;
}
else
if
(
name
.
equals
(
"package.html"
))
{
return
2
;
...
...
@@ -51,4 +59,22 @@ public class CheckPackageHtml {
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
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论