Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
43fde846
提交
43fde846
authored
5月 07, 2010
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Test need to clean up the file system after running.
上级
30107279
隐藏空白字符变更
内嵌
并排
正在显示
38 个修改的文件
包含
164 行增加
和
150 行删除
+164
-150
Compact.java
h2/src/test/org/h2/samples/Compact.java
+2
-0
CsvSample.java
h2/src/test/org/h2/samples/CsvSample.java
+2
-0
TestBackup.java
h2/src/test/org/h2/test/db/TestBackup.java
+7
-7
TestBigResult.java
h2/src/test/org/h2/test/db/TestBigResult.java
+1
-1
TestCases.java
h2/src/test/org/h2/test/db/TestCases.java
+5
-3
TestCluster.java
h2/src/test/org/h2/test/db/TestCluster.java
+15
-12
TestCsv.java
h2/src/test/org/h2/test/db/TestCsv.java
+23
-22
TestFullText.java
h2/src/test/org/h2/test/db/TestFullText.java
+10
-5
TestFunctions.java
h2/src/test/org/h2/test/db/TestFunctions.java
+5
-2
TestLinkedTable.java
h2/src/test/org/h2/test/db/TestLinkedTable.java
+1
-1
TestLob.java
h2/src/test/org/h2/test/db/TestLob.java
+7
-6
TestMultiThreadedKernel.java
h2/src/test/org/h2/test/db/TestMultiThreadedKernel.java
+1
-0
TestOpenClose.java
h2/src/test/org/h2/test/db/TestOpenClose.java
+3
-3
TestPowerOff.java
h2/src/test/org/h2/test/db/TestPowerOff.java
+1
-1
TestReadOnly.java
h2/src/test/org/h2/test/db/TestReadOnly.java
+4
-3
TestRights.java
h2/src/test/org/h2/test/db/TestRights.java
+2
-2
TestRunscript.java
h2/src/test/org/h2/test/db/TestRunscript.java
+9
-8
TestSpaceReuse.java
h2/src/test/org/h2/test/db/TestSpaceReuse.java
+1
-1
TestTempTables.java
h2/src/test/org/h2/test/db/TestTempTables.java
+4
-4
TestCallableStatement.java
h2/src/test/org/h2/test/jdbc/TestCallableStatement.java
+1
-1
TestStatement.java
h2/src/test/org/h2/test/jdbc/TestStatement.java
+1
-1
TestAutoServer.java
h2/src/test/org/h2/test/server/TestAutoServer.java
+2
-2
TestInit.java
h2/src/test/org/h2/test/server/TestInit.java
+15
-10
TestBtreeIndex.java
h2/src/test/org/h2/test/synth/TestBtreeIndex.java
+3
-4
TestCrashAPI.java
h2/src/test/org/h2/test/synth/TestCrashAPI.java
+2
-6
TestHalt.java
h2/src/test/org/h2/test/synth/TestHalt.java
+8
-14
TestHaltApp.java
h2/src/test/org/h2/test/synth/TestHaltApp.java
+0
-1
TestJoin.java
h2/src/test/org/h2/test/synth/TestJoin.java
+0
-3
TestKill.java
h2/src/test/org/h2/test/synth/TestKill.java
+1
-1
TestKillRestart.java
h2/src/test/org/h2/test/synth/TestKillRestart.java
+3
-0
TestKillRestartMulti.java
h2/src/test/org/h2/test/synth/TestKillRestartMulti.java
+5
-2
TestPowerOffFs.java
h2/src/test/org/h2/test/synth/TestPowerOffFs.java
+4
-4
TestPowerOffFs2.java
h2/src/test/org/h2/test/synth/TestPowerOffFs2.java
+4
-4
TestRandomSQL.java
h2/src/test/org/h2/test/synth/TestRandomSQL.java
+3
-1
TestTimer.java
h2/src/test/org/h2/test/synth/TestTimer.java
+2
-2
TestSynth.java
h2/src/test/org/h2/test/synth/sql/TestSynth.java
+3
-10
TestMulti.java
h2/src/test/org/h2/test/synth/thread/TestMulti.java
+1
-1
Player.java
h2/src/test/org/h2/test/trace/Player.java
+3
-2
没有找到文件。
h2/src/test/org/h2/samples/Compact.java
浏览文件 @
43fde846
...
@@ -14,6 +14,7 @@ import java.sql.Statement;
...
@@ -14,6 +14,7 @@ import java.sql.Statement;
import
org.h2.tools.Script
;
import
org.h2.tools.Script
;
import
org.h2.tools.DeleteDbFiles
;
import
org.h2.tools.DeleteDbFiles
;
import
org.h2.tools.RunScript
;
import
org.h2.tools.RunScript
;
import
org.h2.util.IOUtils
;
/**
/**
* This sample application shows how to compact the database files.
* This sample application shows how to compact the database files.
...
@@ -56,5 +57,6 @@ public class Compact {
...
@@ -56,5 +57,6 @@ public class Compact {
Script
.
execute
(
url
,
user
,
password
,
file
);
Script
.
execute
(
url
,
user
,
password
,
file
);
DeleteDbFiles
.
execute
(
dir
,
dbName
,
true
);
DeleteDbFiles
.
execute
(
dir
,
dbName
,
true
);
RunScript
.
execute
(
url
,
user
,
password
,
file
,
null
,
false
);
RunScript
.
execute
(
url
,
user
,
password
,
file
,
null
,
false
);
IOUtils
.
delete
(
file
);
}
}
}
}
h2/src/test/org/h2/samples/CsvSample.java
浏览文件 @
43fde846
...
@@ -13,6 +13,7 @@ import java.sql.Types;
...
@@ -13,6 +13,7 @@ import java.sql.Types;
import
org.h2.tools.Csv
;
import
org.h2.tools.Csv
;
import
org.h2.tools.SimpleResultSet
;
import
org.h2.tools.SimpleResultSet
;
import
org.h2.util.IOUtils
;
/**
/**
* This sample application shows how to use the CSV tool
* This sample application shows how to use the CSV tool
...
@@ -31,6 +32,7 @@ public class CsvSample {
...
@@ -31,6 +32,7 @@ public class CsvSample {
public
static
void
main
(
String
...
args
)
throws
SQLException
{
public
static
void
main
(
String
...
args
)
throws
SQLException
{
CsvSample
.
write
();
CsvSample
.
write
();
CsvSample
.
read
();
CsvSample
.
read
();
IOUtils
.
delete
(
"data/test.csv"
);
}
}
/**
/**
...
...
h2/src/test/org/h2/test/db/TestBackup.java
浏览文件 @
43fde846
...
@@ -37,6 +37,7 @@ public class TestBackup extends TestBase {
...
@@ -37,6 +37,7 @@ public class TestBackup extends TestBase {
testBackupRestoreLob
();
testBackupRestoreLob
();
testBackup
();
testBackup
();
deleteDb
(
"backup"
);
deleteDb
(
"backup"
);
IOUtils
.
delete
(
getBaseDir
()
+
"/backup.zip"
);
}
}
private
void
testBackupRestoreLob
()
throws
SQLException
{
private
void
testBackupRestoreLob
()
throws
SQLException
{
...
@@ -44,19 +45,19 @@ public class TestBackup extends TestBase {
...
@@ -44,19 +45,19 @@ public class TestBackup extends TestBase {
Connection
conn
=
getConnection
(
"backup"
);
Connection
conn
=
getConnection
(
"backup"
);
conn
.
createStatement
().
execute
(
"create table test(x clob) as select space(10000)"
);
conn
.
createStatement
().
execute
(
"create table test(x clob) as select space(10000)"
);
conn
.
close
();
conn
.
close
();
Backup
.
execute
(
get
TestDir
(
""
)
+
"/backup.zip"
,
getTestDir
(
""
),
"backup"
,
true
);
Backup
.
execute
(
get
BaseDir
()
+
"/backup.zip"
,
getBaseDir
(
),
"backup"
,
true
);
deleteDb
(
"backup"
);
deleteDb
(
"backup"
);
Restore
.
execute
(
get
TestDir
(
""
)
+
"/backup.zip"
,
getTestDir
(
""
),
"backup"
,
true
);
Restore
.
execute
(
get
BaseDir
()
+
"/backup.zip"
,
getBaseDir
(
),
"backup"
,
true
);
}
}
private
void
testBackupRestoreLobStatement
()
throws
SQLException
{
private
void
testBackupRestoreLobStatement
()
throws
SQLException
{
deleteDb
(
"backup"
);
deleteDb
(
"backup"
);
Connection
conn
=
getConnection
(
"backup"
);
Connection
conn
=
getConnection
(
"backup"
);
conn
.
createStatement
().
execute
(
"create table test(x clob) as select space(10000)"
);
conn
.
createStatement
().
execute
(
"create table test(x clob) as select space(10000)"
);
conn
.
createStatement
().
execute
(
"backup to '"
+
getTestDir
(
""
)
+
"/backup.zip"
+
"'"
);
conn
.
createStatement
().
execute
(
"backup to '"
+
getBaseDir
(
)
+
"/backup.zip"
+
"'"
);
conn
.
close
();
conn
.
close
();
deleteDb
(
"backup"
);
deleteDb
(
"backup"
);
Restore
.
execute
(
get
TestDir
(
""
)
+
"/backup.zip"
,
getTestDir
(
""
),
"backup"
,
true
);
Restore
.
execute
(
get
BaseDir
()
+
"/backup.zip"
,
getBaseDir
(
),
"backup"
,
true
);
}
}
private
void
testBackup
()
throws
SQLException
{
private
void
testBackup
()
throws
SQLException
{
...
@@ -77,11 +78,11 @@ public class TestBackup extends TestBase {
...
@@ -77,11 +78,11 @@ public class TestBackup extends TestBase {
stat2
.
execute
(
"insert into test values(4, 'fourth (uncommitted)')"
);
stat2
.
execute
(
"insert into test values(4, 'fourth (uncommitted)')"
);
stat2
.
execute
(
"insert into testlob values(2, ' ', '00')"
);
stat2
.
execute
(
"insert into testlob values(2, ' ', '00')"
);
stat1
.
execute
(
"backup to '"
+
baseDir
+
"/backup.zip'"
);
stat1
.
execute
(
"backup to '"
+
getBaseDir
()
+
"/backup.zip'"
);
conn2
.
rollback
();
conn2
.
rollback
();
assertEqualDatabases
(
stat1
,
stat2
);
assertEqualDatabases
(
stat1
,
stat2
);
Restore
.
execute
(
baseDir
+
"/backup.zip"
,
baseDir
,
"restored"
,
true
);
Restore
.
execute
(
getBaseDir
()
+
"/backup.zip"
,
getBaseDir
()
,
"restored"
,
true
);
conn3
=
getConnection
(
"restored"
);
conn3
=
getConnection
(
"restored"
);
stat3
=
conn3
.
createStatement
();
stat3
=
conn3
.
createStatement
();
assertEqualDatabases
(
stat1
,
stat3
);
assertEqualDatabases
(
stat1
,
stat3
);
...
@@ -90,7 +91,6 @@ public class TestBackup extends TestBase {
...
@@ -90,7 +91,6 @@ public class TestBackup extends TestBase {
conn2
.
close
();
conn2
.
close
();
conn3
.
close
();
conn3
.
close
();
deleteDb
(
"restored"
);
deleteDb
(
"restored"
);
IOUtils
.
delete
(
baseDir
+
"/backup.zip"
);
}
}
}
}
h2/src/test/org/h2/test/db/TestBigResult.java
浏览文件 @
43fde846
...
@@ -89,7 +89,7 @@ public class TestBigResult extends TestBase {
...
@@ -89,7 +89,7 @@ public class TestBigResult extends TestBase {
// rs.close();
// rs.close();
conn
.
close
();
conn
.
close
();
deleteDb
(
"bigResult"
);
deleteDb
(
"bigResult"
);
ArrayList
<
String
>
files
=
FileLister
.
getDatabaseFiles
(
baseDir
,
"bigResult"
,
true
);
ArrayList
<
String
>
files
=
FileLister
.
getDatabaseFiles
(
getBaseDir
()
,
"bigResult"
,
true
);
if
(
files
.
size
()
>
0
)
{
if
(
files
.
size
()
>
0
)
{
fail
(
"file not deleted: "
+
files
.
get
(
0
));
fail
(
"file not deleted: "
+
files
.
get
(
0
));
}
}
...
...
h2/src/test/org/h2/test/db/TestCases.java
浏览文件 @
43fde846
...
@@ -19,6 +19,7 @@ import java.sql.Timestamp;
...
@@ -19,6 +19,7 @@ import java.sql.Timestamp;
import
java.util.Random
;
import
java.util.Random
;
import
org.h2.constant.ErrorCode
;
import
org.h2.constant.ErrorCode
;
import
org.h2.test.TestBase
;
import
org.h2.test.TestBase
;
import
org.h2.util.IOUtils
;
/**
/**
* Various test cases.
* Various test cases.
...
@@ -320,9 +321,10 @@ public class TestCases extends TestBase {
...
@@ -320,9 +321,10 @@ public class TestCases extends TestBase {
sql
=
"delete from "
+
table
;
sql
=
"delete from "
+
table
;
}
}
stat
.
execute
(
sql
);
stat
.
execute
(
sql
);
stat
.
execute
(
"script to '"
+
baseDir
+
"/test.sql'"
);
stat
.
execute
(
"script to '"
+
getBaseDir
()
+
"/test.sql'"
);
}
}
conn
.
close
();
conn
.
close
();
IOUtils
.
delete
(
getBaseDir
()
+
"/test.sql"
);
}
}
private
void
testDeleteGroup
()
throws
SQLException
{
private
void
testDeleteGroup
()
throws
SQLException
{
...
@@ -1022,8 +1024,8 @@ public class TestCases extends TestBase {
...
@@ -1022,8 +1024,8 @@ public class TestCases extends TestBase {
conn
.
close
();
conn
.
close
();
File
[]
files
=
new
File
(
baseDir
+
"/cases.lobs.db"
).
listFiles
(
);
String
[]
list
=
IOUtils
.
listFiles
(
getBaseDir
()
+
"/cases.lobs.db"
);
if
(
files
!=
null
&&
files
.
length
>
0
)
{
if
(
list
!=
null
&&
list
.
length
>
0
)
{
fail
(
"Lob file was not deleted"
);
fail
(
"Lob file was not deleted"
);
}
}
}
}
...
...
h2/src/test/org/h2/test/db/TestCluster.java
浏览文件 @
43fde846
...
@@ -17,6 +17,7 @@ import org.h2.test.TestBase;
...
@@ -17,6 +17,7 @@ import org.h2.test.TestBase;
import
org.h2.tools.CreateCluster
;
import
org.h2.tools.CreateCluster
;
import
org.h2.tools.DeleteDbFiles
;
import
org.h2.tools.DeleteDbFiles
;
import
org.h2.tools.Server
;
import
org.h2.tools.Server
;
import
org.h2.util.IOUtils
;
import
org.h2.util.JdbcUtils
;
import
org.h2.util.JdbcUtils
;
/**
/**
...
@@ -56,14 +57,14 @@ public class TestCluster extends TestBase {
...
@@ -56,14 +57,14 @@ public class TestCluster extends TestBase {
int
len
=
10
;
int
len
=
10
;
// initialize the database
// initialize the database
Server
n1
=
org
.
h2
.
tools
.
Server
.
createTcpServer
(
"-tcpPort"
,
""
+
port1
,
"-baseDir"
,
baseDir
+
"/node1"
).
start
();
Server
n1
=
org
.
h2
.
tools
.
Server
.
createTcpServer
(
"-tcpPort"
,
""
+
port1
,
"-baseDir"
,
getBaseDir
()
+
"/node1"
).
start
();
conn
=
DriverManager
.
getConnection
(
url1
,
user
,
password
);
conn
=
DriverManager
.
getConnection
(
url1
,
user
,
password
);
stat
=
conn
.
createStatement
();
stat
=
conn
.
createStatement
();
stat
.
execute
(
"create table test(id int primary key, name varchar) as "
+
stat
.
execute
(
"create table test(id int primary key, name varchar) as "
+
"select x, 'Data' || x from system_range(0, "
+
(
len
-
1
)
+
")"
);
"select x, 'Data' || x from system_range(0, "
+
(
len
-
1
)
+
")"
);
// start the second server
// start the second server
Server
n2
=
org
.
h2
.
tools
.
Server
.
createTcpServer
(
"-tcpPort"
,
""
+
port2
,
"-baseDir"
,
baseDir
+
"/node2"
).
start
();
Server
n2
=
org
.
h2
.
tools
.
Server
.
createTcpServer
(
"-tcpPort"
,
""
+
port2
,
"-baseDir"
,
getBaseDir
()
+
"/node2"
).
start
();
// copy the database and initialize the cluster
// copy the database and initialize the cluster
CreateCluster
.
main
(
"-urlSource"
,
url1
,
"-urlTarget"
,
url2
,
"-user"
,
user
,
"-password"
,
password
,
"-serverList"
,
CreateCluster
.
main
(
"-urlSource"
,
url1
,
"-urlTarget"
,
url2
,
"-user"
,
user
,
"-password"
,
password
,
"-serverList"
,
...
@@ -87,7 +88,7 @@ public class TestCluster extends TestBase {
...
@@ -87,7 +88,7 @@ public class TestCluster extends TestBase {
check
(
connApp
,
len
,
"''"
);
check
(
connApp
,
len
,
"''"
);
// re-create the cluster
// re-create the cluster
n2
=
org
.
h2
.
tools
.
Server
.
createTcpServer
(
"-tcpPort"
,
""
+
port2
,
"-baseDir"
,
baseDir
+
"/node2"
).
start
();
n2
=
org
.
h2
.
tools
.
Server
.
createTcpServer
(
"-tcpPort"
,
""
+
port2
,
"-baseDir"
,
getBaseDir
()
+
"/node2"
).
start
();
CreateCluster
.
main
(
"-urlSource"
,
url1
,
"-urlTarget"
,
url2
,
"-user"
,
user
,
"-password"
,
password
,
"-serverList"
,
CreateCluster
.
main
(
"-urlSource"
,
url1
,
"-urlTarget"
,
url2
,
"-user"
,
user
,
"-password"
,
password
,
"-serverList"
,
serverList
);
serverList
);
...
@@ -135,8 +136,8 @@ public class TestCluster extends TestBase {
...
@@ -135,8 +136,8 @@ public class TestCluster extends TestBase {
serverList
);
serverList
);
// start both servers
// start both servers
Server
n1
=
org
.
h2
.
tools
.
Server
.
createTcpServer
(
"-tcpPort"
,
""
+
port1
,
"-baseDir"
,
baseDir
+
"/node1"
).
start
();
Server
n1
=
org
.
h2
.
tools
.
Server
.
createTcpServer
(
"-tcpPort"
,
""
+
port1
,
"-baseDir"
,
getBaseDir
()
+
"/node1"
).
start
();
Server
n2
=
org
.
h2
.
tools
.
Server
.
createTcpServer
(
"-tcpPort"
,
""
+
port2
,
"-baseDir"
,
baseDir
+
"/node2"
).
start
();
Server
n2
=
org
.
h2
.
tools
.
Server
.
createTcpServer
(
"-tcpPort"
,
""
+
port2
,
"-baseDir"
,
getBaseDir
()
+
"/node2"
).
start
();
// try to connect in standalone mode - should fail
// try to connect in standalone mode - should fail
try
{
try
{
...
@@ -169,12 +170,12 @@ public class TestCluster extends TestBase {
...
@@ -169,12 +170,12 @@ public class TestCluster extends TestBase {
n1
.
stop
();
n1
.
stop
();
// re-create the cluster
// re-create the cluster
DeleteDbFiles
.
main
(
"-dir"
,
baseDir
+
"/node2"
,
"-quiet"
);
DeleteDbFiles
.
main
(
"-dir"
,
getBaseDir
()
+
"/node2"
,
"-quiet"
);
CreateCluster
.
main
(
"-urlSource"
,
urlNode1
,
"-urlTarget"
,
CreateCluster
.
main
(
"-urlSource"
,
urlNode1
,
"-urlTarget"
,
urlNode2
,
"-user"
,
user
,
"-password"
,
password
,
"-serverList"
,
urlNode2
,
"-user"
,
user
,
"-password"
,
password
,
"-serverList"
,
serverList
);
serverList
);
n1
=
org
.
h2
.
tools
.
Server
.
createTcpServer
(
"-tcpPort"
,
""
+
port1
,
"-baseDir"
,
baseDir
+
"/node1"
).
start
();
n1
=
org
.
h2
.
tools
.
Server
.
createTcpServer
(
"-tcpPort"
,
""
+
port1
,
"-baseDir"
,
getBaseDir
()
+
"/node1"
).
start
();
n2
=
org
.
h2
.
tools
.
Server
.
createTcpServer
(
"-tcpPort"
,
""
+
port2
,
"-baseDir"
,
baseDir
+
"/node2"
).
start
();
n2
=
org
.
h2
.
tools
.
Server
.
createTcpServer
(
"-tcpPort"
,
""
+
port2
,
"-baseDir"
,
getBaseDir
()
+
"/node2"
).
start
();
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:tcp://"
+
serverList
+
"/test"
,
user
,
password
);
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:tcp://"
+
serverList
+
"/test"
,
user
,
password
);
stat
=
conn
.
createStatement
();
stat
=
conn
.
createStatement
();
...
@@ -186,13 +187,13 @@ public class TestCluster extends TestBase {
...
@@ -186,13 +187,13 @@ public class TestCluster extends TestBase {
conn
.
close
();
conn
.
close
();
n2
.
stop
();
n2
.
stop
();
n1
=
org
.
h2
.
tools
.
Server
.
createTcpServer
(
"-tcpPort"
,
""
+
port1
,
"-baseDir"
,
baseDir
+
"/node1"
).
start
();
n1
=
org
.
h2
.
tools
.
Server
.
createTcpServer
(
"-tcpPort"
,
""
+
port1
,
"-baseDir"
,
getBaseDir
()
+
"/node1"
).
start
();
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:tcp://localhost:"
+
port1
+
"/test;CLUSTER=''"
,
user
,
password
);
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:tcp://localhost:"
+
port1
+
"/test;CLUSTER=''"
,
user
,
password
);
check
(
conn
,
len
,
"''"
);
check
(
conn
,
len
,
"''"
);
conn
.
close
();
conn
.
close
();
n1
.
stop
();
n1
.
stop
();
n2
=
org
.
h2
.
tools
.
Server
.
createTcpServer
(
"-tcpPort"
,
""
+
port2
,
"-baseDir"
,
baseDir
+
"/node2"
).
start
();
n2
=
org
.
h2
.
tools
.
Server
.
createTcpServer
(
"-tcpPort"
,
""
+
port2
,
"-baseDir"
,
getBaseDir
()
+
"/node2"
).
start
();
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:tcp://localhost:"
+
port2
+
"/test;CLUSTER=''"
,
user
,
password
);
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:tcp://localhost:"
+
port2
+
"/test;CLUSTER=''"
,
user
,
password
);
check
(
conn
,
len
,
"''"
);
check
(
conn
,
len
,
"''"
);
conn
.
createStatement
().
execute
(
"SELECT * FROM A"
);
conn
.
createStatement
().
execute
(
"SELECT * FROM A"
);
...
@@ -202,8 +203,10 @@ public class TestCluster extends TestBase {
...
@@ -202,8 +203,10 @@ public class TestCluster extends TestBase {
}
}
private
void
deleteFiles
()
throws
SQLException
{
private
void
deleteFiles
()
throws
SQLException
{
DeleteDbFiles
.
main
(
"-dir"
,
baseDir
+
"/node1"
,
"-quiet"
);
DeleteDbFiles
.
main
(
"-dir"
,
getBaseDir
()
+
"/node1"
,
"-quiet"
);
DeleteDbFiles
.
main
(
"-dir"
,
baseDir
+
"/node2"
,
"-quiet"
);
DeleteDbFiles
.
main
(
"-dir"
,
getBaseDir
()
+
"/node2"
,
"-quiet"
);
IOUtils
.
delete
(
getBaseDir
()
+
"/node1"
);
IOUtils
.
delete
(
getBaseDir
()
+
"/node2"
);
}
}
private
void
check
(
Connection
conn
,
int
len
,
String
expectedCluster
)
throws
SQLException
{
private
void
check
(
Connection
conn
,
int
len
,
String
expectedCluster
)
throws
SQLException
{
...
...
h2/src/test/org/h2/test/db/TestCsv.java
浏览文件 @
43fde846
...
@@ -68,7 +68,7 @@ public class TestCsv extends TestBase {
...
@@ -68,7 +68,7 @@ public class TestCsv extends TestBase {
private
void
testSpaceSeparated
()
throws
SQLException
{
private
void
testSpaceSeparated
()
throws
SQLException
{
deleteDb
(
"csv"
);
deleteDb
(
"csv"
);
File
f
=
new
File
(
baseDir
+
"/testSpace.csv"
);
File
f
=
new
File
(
getBaseDir
()
+
"/testSpace.csv"
);
IOUtils
.
delete
(
f
.
getAbsolutePath
());
IOUtils
.
delete
(
f
.
getAbsolutePath
());
Connection
conn
=
getConnection
(
"csv"
);
Connection
conn
=
getConnection
(
"csv"
);
...
@@ -76,13 +76,14 @@ public class TestCsv extends TestBase {
...
@@ -76,13 +76,14 @@ public class TestCsv extends TestBase {
stat
.
execute
(
"create temporary table test (a int, b int, c int)"
);
stat
.
execute
(
"create temporary table test (a int, b int, c int)"
);
stat
.
execute
(
"insert into test values(1,2,3)"
);
stat
.
execute
(
"insert into test values(1,2,3)"
);
stat
.
execute
(
"insert into test values(4,null,5)"
);
stat
.
execute
(
"insert into test values(4,null,5)"
);
stat
.
execute
(
"call csvwrite('"
+
baseDir
+
"/test.tsv','select * from test',null,' ')"
);
stat
.
execute
(
"call csvwrite('"
+
getBaseDir
()
+
"/test.tsv','select * from test',null,' ')"
);
ResultSet
rs1
=
stat
.
executeQuery
(
"select * from test"
);
ResultSet
rs1
=
stat
.
executeQuery
(
"select * from test"
);
assertResultSetOrdered
(
rs1
,
new
String
[][]{
new
String
[]{
"1"
,
"2"
,
"3"
},
new
String
[]{
"4"
,
null
,
"5"
}});
assertResultSetOrdered
(
rs1
,
new
String
[][]{
new
String
[]{
"1"
,
"2"
,
"3"
},
new
String
[]{
"4"
,
null
,
"5"
}});
ResultSet
rs2
=
stat
.
executeQuery
(
"select * from csvread('"
+
baseDir
+
"/test.tsv',null,null,' ')"
);
ResultSet
rs2
=
stat
.
executeQuery
(
"select * from csvread('"
+
getBaseDir
()
+
"/test.tsv',null,null,' ')"
);
assertResultSetOrdered
(
rs2
,
new
String
[][]{
new
String
[]{
"1"
,
"2"
,
"3"
},
new
String
[]{
"4"
,
null
,
"5"
}});
assertResultSetOrdered
(
rs2
,
new
String
[][]{
new
String
[]{
"1"
,
"2"
,
"3"
},
new
String
[]{
"4"
,
null
,
"5"
}});
conn
.
close
();
conn
.
close
();
IOUtils
.
delete
(
f
.
getAbsolutePath
());
IOUtils
.
delete
(
f
.
getAbsolutePath
());
IOUtils
.
delete
(
getBaseDir
()
+
"/test.tsv"
);
}
}
/**
/**
...
@@ -91,7 +92,7 @@ public class TestCsv extends TestBase {
...
@@ -91,7 +92,7 @@ public class TestCsv extends TestBase {
private
void
testNull
()
throws
Exception
{
private
void
testNull
()
throws
Exception
{
deleteDb
(
"csv"
);
deleteDb
(
"csv"
);
String
fileName
=
baseDir
+
"/testNull.csv"
;
String
fileName
=
getBaseDir
()
+
"/testNull.csv"
;
FileSystem
fs
=
FileSystem
.
getInstance
(
fileName
);
FileSystem
fs
=
FileSystem
.
getInstance
(
fileName
);
fs
.
delete
(
fileName
);
fs
.
delete
(
fileName
);
...
@@ -148,11 +149,11 @@ public class TestCsv extends TestBase {
...
@@ -148,11 +149,11 @@ public class TestCsv extends TestBase {
list
.
add
(
new
String
[]{
a
,
b
});
list
.
add
(
new
String
[]{
a
,
b
});
prep
.
execute
();
prep
.
execute
();
}
}
stat
.
execute
(
"CALL CSVWRITE('"
+
baseDir
+
"/test.csv', 'SELECT * FROM test', 'UTF-8', '|', '#')"
);
stat
.
execute
(
"CALL CSVWRITE('"
+
getBaseDir
()
+
"/test.csv', 'SELECT * FROM test', 'UTF-8', '|', '#')"
);
Csv
csv
=
Csv
.
getInstance
();
Csv
csv
=
Csv
.
getInstance
();
csv
.
setFieldSeparatorRead
(
'|'
);
csv
.
setFieldSeparatorRead
(
'|'
);
csv
.
setFieldDelimiter
(
'#'
);
csv
.
setFieldDelimiter
(
'#'
);
ResultSet
rs
=
csv
.
read
(
baseDir
+
"/test.csv"
,
null
,
"UTF-8"
);
ResultSet
rs
=
csv
.
read
(
getBaseDir
()
+
"/test.csv"
,
null
,
"UTF-8"
);
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
assertTrue
(
rs
.
next
());
assertTrue
(
rs
.
next
());
String
[]
pair
=
list
.
get
(
i
);
String
[]
pair
=
list
.
get
(
i
);
...
@@ -161,7 +162,7 @@ public class TestCsv extends TestBase {
...
@@ -161,7 +162,7 @@ public class TestCsv extends TestBase {
}
}
assertFalse
(
rs
.
next
());
assertFalse
(
rs
.
next
());
conn
.
close
();
conn
.
close
();
IOUtils
.
delete
(
baseDir
+
"/test.csv"
);
IOUtils
.
delete
(
getBaseDir
()
+
"/test.csv"
);
}
}
private
String
randomData
(
Random
random
)
{
private
String
randomData
(
Random
random
)
{
...
@@ -178,7 +179,7 @@ public class TestCsv extends TestBase {
...
@@ -178,7 +179,7 @@ public class TestCsv extends TestBase {
}
}
private
void
testEmptyFieldDelimiter
()
throws
Exception
{
private
void
testEmptyFieldDelimiter
()
throws
Exception
{
String
fileName
=
baseDir
+
"/test.csv"
;
String
fileName
=
getBaseDir
()
+
"/test.csv"
;
IOUtils
.
delete
(
fileName
);
IOUtils
.
delete
(
fileName
);
Connection
conn
=
getConnection
(
"csv"
);
Connection
conn
=
getConnection
(
"csv"
);
Statement
stat
=
conn
.
createStatement
();
Statement
stat
=
conn
.
createStatement
();
...
@@ -201,8 +202,8 @@ public class TestCsv extends TestBase {
...
@@ -201,8 +202,8 @@ public class TestCsv extends TestBase {
}
}
private
void
testFieldDelimiter
()
throws
Exception
{
private
void
testFieldDelimiter
()
throws
Exception
{
String
fileName
=
baseDir
+
"/test.csv"
;
String
fileName
=
getBaseDir
()
+
"/test.csv"
;
String
fileName2
=
baseDir
+
"/test2.csv"
;
String
fileName2
=
getBaseDir
()
+
"/test2.csv"
;
FileSystem
fs
=
FileSystem
.
getInstance
(
fileName
);
FileSystem
fs
=
FileSystem
.
getInstance
(
fileName
);
fs
.
delete
(
fileName
);
fs
.
delete
(
fileName
);
FileObject
file
=
fs
.
openFileObject
(
fileName
,
"rw"
);
FileObject
file
=
fs
.
openFileObject
(
fileName
,
"rw"
);
...
@@ -239,13 +240,13 @@ public class TestCsv extends TestBase {
...
@@ -239,13 +240,13 @@ public class TestCsv extends TestBase {
deleteDb
(
"csv"
);
deleteDb
(
"csv"
);
Connection
conn
=
getConnection
(
"csv"
);
Connection
conn
=
getConnection
(
"csv"
);
Statement
stat
=
conn
.
createStatement
();
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"call csvwrite('"
+
baseDir
+
"/test.csv', 'select 1 id, ''Hello'' name', 'utf-8', '|')"
);
stat
.
execute
(
"call csvwrite('"
+
getBaseDir
()
+
"/test.csv', 'select 1 id, ''Hello'' name', 'utf-8', '|')"
);
ResultSet
rs
=
stat
.
executeQuery
(
"select * from csvread('"
+
baseDir
+
"/test.csv', null, 'utf-8', '|')"
);
ResultSet
rs
=
stat
.
executeQuery
(
"select * from csvread('"
+
getBaseDir
()
+
"/test.csv', null, 'utf-8', '|')"
);
assertTrue
(
rs
.
next
());
assertTrue
(
rs
.
next
());
assertEquals
(
1
,
rs
.
getInt
(
1
));
assertEquals
(
1
,
rs
.
getInt
(
1
));
assertEquals
(
"Hello"
,
rs
.
getString
(
2
));
assertEquals
(
"Hello"
,
rs
.
getString
(
2
));
assertFalse
(
rs
.
next
());
assertFalse
(
rs
.
next
());
new
File
(
baseDir
+
"/test.csv"
).
delete
();
new
File
(
getBaseDir
()
+
"/test.csv"
).
delete
();
// PreparedStatement prep = conn.prepareStatement("select * from
// PreparedStatement prep = conn.prepareStatement("select * from
// csvread(?, null, ?, ?)");
// csvread(?, null, ?, ?)");
...
@@ -255,29 +256,29 @@ public class TestCsv extends TestBase {
...
@@ -255,29 +256,29 @@ public class TestCsv extends TestBase {
// rs = prep.executeQuery();
// rs = prep.executeQuery();
conn
.
close
();
conn
.
close
();
IOUtils
.
delete
(
baseDir
+
"/test.csv"
);
IOUtils
.
delete
(
getBaseDir
()
+
"/test.csv"
);
}
}
private
void
testAsTable
()
throws
SQLException
{
private
void
testAsTable
()
throws
SQLException
{
deleteDb
(
"csv"
);
deleteDb
(
"csv"
);
Connection
conn
=
getConnection
(
"csv"
);
Connection
conn
=
getConnection
(
"csv"
);
Statement
stat
=
conn
.
createStatement
();
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"call csvwrite('"
+
baseDir
+
"/test.csv', 'select 1 id, ''Hello'' name')"
);
stat
.
execute
(
"call csvwrite('"
+
getBaseDir
()
+
"/test.csv', 'select 1 id, ''Hello'' name')"
);
ResultSet
rs
=
stat
.
executeQuery
(
"select name from csvread('"
+
baseDir
+
"/test.csv')"
);
ResultSet
rs
=
stat
.
executeQuery
(
"select name from csvread('"
+
getBaseDir
()
+
"/test.csv')"
);
assertTrue
(
rs
.
next
());
assertTrue
(
rs
.
next
());
assertEquals
(
"Hello"
,
rs
.
getString
(
1
));
assertEquals
(
"Hello"
,
rs
.
getString
(
1
));
assertFalse
(
rs
.
next
());
assertFalse
(
rs
.
next
());
rs
=
stat
.
executeQuery
(
"call csvread('"
+
baseDir
+
"/test.csv')"
);
rs
=
stat
.
executeQuery
(
"call csvread('"
+
getBaseDir
()
+
"/test.csv')"
);
assertTrue
(
rs
.
next
());
assertTrue
(
rs
.
next
());
assertEquals
(
1
,
rs
.
getInt
(
1
));
assertEquals
(
1
,
rs
.
getInt
(
1
));
assertEquals
(
"Hello"
,
rs
.
getString
(
2
));
assertEquals
(
"Hello"
,
rs
.
getString
(
2
));
assertFalse
(
rs
.
next
());
assertFalse
(
rs
.
next
());
new
File
(
baseDir
+
"/test.csv"
).
delete
();
new
File
(
getBaseDir
()
+
"/test.csv"
).
delete
();
conn
.
close
();
conn
.
close
();
}
}
private
void
testRead
()
throws
Exception
{
private
void
testRead
()
throws
Exception
{
String
fileName
=
baseDir
+
"/test.csv"
;
String
fileName
=
getBaseDir
()
+
"/test.csv"
;
FileSystem
fs
=
FileSystem
.
getInstance
(
fileName
);
FileSystem
fs
=
FileSystem
.
getInstance
(
fileName
);
fs
.
delete
(
fileName
);
fs
.
delete
(
fileName
);
FileObject
file
=
fs
.
openFileObject
(
fileName
,
"rw"
);
FileObject
file
=
fs
.
openFileObject
(
fileName
,
"rw"
);
...
@@ -334,8 +335,8 @@ public class TestCsv extends TestBase {
...
@@ -334,8 +335,8 @@ public class TestCsv extends TestBase {
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
stat
.
execute
(
"INSERT INTO TEST(NAME) VALUES('Ruebezahl')"
);
stat
.
execute
(
"INSERT INTO TEST(NAME) VALUES('Ruebezahl')"
);
}
}
Csv
.
getInstance
().
write
(
conn
,
baseDir
+
"/testRW.csv"
,
"SELECT * FROM TEST"
,
"UTF8"
);
Csv
.
getInstance
().
write
(
conn
,
getBaseDir
()
+
"/testRW.csv"
,
"SELECT * FROM TEST"
,
"UTF8"
);
ResultSet
rs
=
Csv
.
getInstance
().
read
(
baseDir
+
"/testRW.csv"
,
null
,
"UTF8"
);
ResultSet
rs
=
Csv
.
getInstance
().
read
(
getBaseDir
()
+
"/testRW.csv"
,
null
,
"UTF8"
);
// stat.execute("CREATE ALIAS CSVREAD FOR \"org.h2.tools.Csv.read\"");
// stat.execute("CREATE ALIAS CSVREAD FOR \"org.h2.tools.Csv.read\"");
ResultSetMetaData
meta
=
rs
.
getMetaData
();
ResultSetMetaData
meta
=
rs
.
getMetaData
();
assertEquals
(
2
,
meta
.
getColumnCount
());
assertEquals
(
2
,
meta
.
getColumnCount
());
...
@@ -347,7 +348,7 @@ public class TestCsv extends TestBase {
...
@@ -347,7 +348,7 @@ public class TestCsv extends TestBase {
assertFalse
(
rs
.
next
());
assertFalse
(
rs
.
next
());
rs
.
close
();
rs
.
close
();
conn
.
close
();
conn
.
close
();
IOUtils
.
delete
(
baseDir
+
"/testRW.csv"
);
IOUtils
.
delete
(
getBaseDir
()
+
"/testRW.csv"
);
}
}
}
}
h2/src/test/org/h2/test/db/TestFullText.java
浏览文件 @
43fde846
...
@@ -70,7 +70,7 @@ public class TestFullText extends TestBase {
...
@@ -70,7 +70,7 @@ public class TestFullText extends TestBase {
}
}
String
prefix
=
lucene
?
"FTL"
:
"FT"
;
String
prefix
=
lucene
?
"FTL"
:
"FT"
;
deleteDb
(
"fullTextTransaction"
);
deleteDb
(
"fullTextTransaction"
);
FileSystem
.
getInstance
(
baseDir
).
deleteRecursive
(
baseDir
+
"/fullTextTransaction"
,
false
);
FileSystem
.
getInstance
(
getBaseDir
()).
deleteRecursive
(
getBaseDir
()
+
"/fullTextTransaction"
,
false
);
Connection
conn
=
getConnection
(
"fullTextTransaction"
);
Connection
conn
=
getConnection
(
"fullTextTransaction"
);
Statement
stat
=
conn
.
createStatement
();
Statement
stat
=
conn
.
createStatement
();
String
className
=
lucene
?
"FullTextLucene"
:
"FullText"
;
String
className
=
lucene
?
"FullTextLucene"
:
"FullText"
;
...
@@ -94,6 +94,7 @@ public class TestFullText extends TestBase {
...
@@ -94,6 +94,7 @@ public class TestFullText extends TestBase {
FullText
.
dropAll
(
conn
);
FullText
.
dropAll
(
conn
);
conn
.
close
();
conn
.
close
();
deleteDb
(
"fullTextTransaction"
);
deleteDb
(
"fullTextTransaction"
);
FileSystem
.
getInstance
(
getBaseDir
()).
deleteRecursive
(
getBaseDir
()
+
"/fullTextTransaction"
,
false
);
}
}
private
void
testMultiThreaded
()
throws
Exception
{
private
void
testMultiThreaded
()
throws
Exception
{
...
@@ -192,7 +193,7 @@ public class TestFullText extends TestBase {
...
@@ -192,7 +193,7 @@ public class TestFullText extends TestBase {
private
void
testCreateDrop
()
throws
SQLException
{
private
void
testCreateDrop
()
throws
SQLException
{
deleteDb
(
"fullText"
);
deleteDb
(
"fullText"
);
FileSystem
.
getInstance
(
baseDir
).
deleteRecursive
(
baseDir
+
"/fullText"
,
false
);
FileSystem
.
getInstance
(
getBaseDir
()).
deleteRecursive
(
getBaseDir
()
+
"/fullText"
,
false
);
Connection
conn
=
getConnection
(
"fullText"
);
Connection
conn
=
getConnection
(
"fullText"
);
Statement
stat
=
conn
.
createStatement
();
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"CREATE ALIAS IF NOT EXISTS FT_INIT FOR \"org.h2.fulltext.FullText.init\""
);
stat
.
execute
(
"CREATE ALIAS IF NOT EXISTS FT_INIT FOR \"org.h2.fulltext.FullText.init\""
);
...
@@ -203,13 +204,13 @@ public class TestFullText extends TestBase {
...
@@ -203,13 +204,13 @@ public class TestFullText extends TestBase {
}
}
conn
.
close
();
conn
.
close
();
deleteDb
(
"fullText"
);
deleteDb
(
"fullText"
);
FileSystem
.
getInstance
(
baseDir
).
deleteRecursive
(
baseDir
+
"/fullText"
,
false
);
FileSystem
.
getInstance
(
getBaseDir
()).
deleteRecursive
(
getBaseDir
()
+
"/fullText"
,
false
);
}
}
private
void
testReopen
(
boolean
lucene
)
throws
SQLException
{
private
void
testReopen
(
boolean
lucene
)
throws
SQLException
{
String
prefix
=
lucene
?
"FTL"
:
"FT"
;
String
prefix
=
lucene
?
"FTL"
:
"FT"
;
deleteDb
(
"fullTextReopen"
);
deleteDb
(
"fullTextReopen"
);
FileSystem
.
getInstance
(
baseDir
).
deleteRecursive
(
baseDir
+
"/fullTextReopen"
,
false
);
FileSystem
.
getInstance
(
getBaseDir
()).
deleteRecursive
(
getBaseDir
()
+
"/fullTextReopen"
,
false
);
Connection
conn
=
getConnection
(
"fullTextReopen"
);
Connection
conn
=
getConnection
(
"fullTextReopen"
);
Statement
stat
=
conn
.
createStatement
();
Statement
stat
=
conn
.
createStatement
();
String
className
=
lucene
?
"FullTextLucene"
:
"FullText"
;
String
className
=
lucene
?
"FullTextLucene"
:
"FullText"
;
...
@@ -235,11 +236,12 @@ public class TestFullText extends TestBase {
...
@@ -235,11 +236,12 @@ public class TestFullText extends TestBase {
stat
=
conn
.
createStatement
();
stat
=
conn
.
createStatement
();
stat
.
execute
(
"INSERT INTO TEST VALUES(3, 'Hello')"
);
stat
.
execute
(
"INSERT INTO TEST VALUES(3, 'Hello')"
);
conn
.
close
();
conn
.
close
();
FileSystem
.
getInstance
(
getBaseDir
()).
deleteRecursive
(
getBaseDir
()
+
"/fullTextReopen"
,
false
);
}
}
private
void
testPerformance
(
boolean
lucene
)
throws
SQLException
{
private
void
testPerformance
(
boolean
lucene
)
throws
SQLException
{
deleteDb
(
"fullText"
);
deleteDb
(
"fullText"
);
FileSystem
.
getInstance
(
baseDir
).
deleteRecursive
(
baseDir
+
"/fullText"
,
false
);
FileSystem
.
getInstance
(
getBaseDir
()).
deleteRecursive
(
getBaseDir
()
+
"/fullText"
,
false
);
Connection
conn
=
getConnection
(
"fullText"
);
Connection
conn
=
getConnection
(
"fullText"
);
String
prefix
=
lucene
?
"FTL"
:
"FT"
;
String
prefix
=
lucene
?
"FTL"
:
"FT"
;
Statement
stat
=
conn
.
createStatement
();
Statement
stat
=
conn
.
createStatement
();
...
@@ -279,6 +281,9 @@ public class TestFullText extends TestBase {
...
@@ -279,6 +281,9 @@ public class TestFullText extends TestBase {
}
}
private
void
test
(
boolean
lucene
,
String
dataType
)
throws
SQLException
{
private
void
test
(
boolean
lucene
,
String
dataType
)
throws
SQLException
{
if
(
lucene
&&
getBaseDir
().
indexOf
(
':'
)
>
0
)
{
return
;
}
deleteDb
(
"fullText"
);
deleteDb
(
"fullText"
);
Connection
conn
=
getConnection
(
"fullText"
);
Connection
conn
=
getConnection
(
"fullText"
);
String
prefix
=
lucene
?
"FTL_"
:
"FT_"
;
String
prefix
=
lucene
?
"FTL_"
:
"FT_"
;
...
...
h2/src/test/org/h2/test/db/TestFunctions.java
浏览文件 @
43fde846
...
@@ -24,6 +24,7 @@ import java.util.Properties;
...
@@ -24,6 +24,7 @@ import java.util.Properties;
import
java.util.UUID
;
import
java.util.UUID
;
import
org.h2.api.AggregateFunction
;
import
org.h2.api.AggregateFunction
;
import
org.h2.store.fs.FileSystem
;
import
org.h2.test.TestBase
;
import
org.h2.test.TestBase
;
import
org.h2.tools.SimpleResultSet
;
import
org.h2.tools.SimpleResultSet
;
import
org.h2.util.IOUtils
;
import
org.h2.util.IOUtils
;
...
@@ -61,6 +62,7 @@ public class TestFunctions extends TestBase implements AggregateFunction {
...
@@ -61,6 +62,7 @@ public class TestFunctions extends TestBase implements AggregateFunction {
testFunctions
();
testFunctions
();
testFileRead
();
testFileRead
();
deleteDb
(
"functions"
);
deleteDb
(
"functions"
);
FileSystem
.
getInstance
(
TEMP_DIR
).
deleteRecursive
(
TEMP_DIR
,
false
);
}
}
private
void
testGreatest
()
throws
SQLException
{
private
void
testGreatest
()
throws
SQLException
{
...
@@ -254,7 +256,7 @@ public class TestFunctions extends TestBase implements AggregateFunction {
...
@@ -254,7 +256,7 @@ public class TestFunctions extends TestBase implements AggregateFunction {
private
void
testFileRead
()
throws
Exception
{
private
void
testFileRead
()
throws
Exception
{
Connection
conn
=
getConnection
(
"functions"
);
Connection
conn
=
getConnection
(
"functions"
);
Statement
stat
=
conn
.
createStatement
();
Statement
stat
=
conn
.
createStatement
();
String
fileName
=
baseDir
+
"/test.txt"
;
String
fileName
=
getBaseDir
()
+
"/test.txt"
;
Properties
prop
=
System
.
getProperties
();
Properties
prop
=
System
.
getProperties
();
OutputStream
out
=
IOUtils
.
openFileOutputStream
(
fileName
,
false
);
OutputStream
out
=
IOUtils
.
openFileOutputStream
(
fileName
,
false
);
prop
.
store
(
out
,
""
);
prop
.
store
(
out
,
""
);
...
@@ -273,8 +275,8 @@ public class TestFunctions extends TestBase implements AggregateFunction {
...
@@ -273,8 +275,8 @@ public class TestFunctions extends TestBase implements AggregateFunction {
InputStreamReader
r
=
new
InputStreamReader
(
IOUtils
.
openFileInputStream
(
fileName
));
InputStreamReader
r
=
new
InputStreamReader
(
IOUtils
.
openFileInputStream
(
fileName
));
String
ps2
=
IOUtils
.
readStringAndClose
(
r
,
-
1
);
String
ps2
=
IOUtils
.
readStringAndClose
(
r
,
-
1
);
assertEquals
(
ps
,
ps2
);
assertEquals
(
ps
,
ps2
);
IOUtils
.
delete
(
fileName
);
conn
.
close
();
conn
.
close
();
IOUtils
.
delete
(
fileName
);
}
}
/**
/**
...
@@ -487,6 +489,7 @@ public class TestFunctions extends TestBase implements AggregateFunction {
...
@@ -487,6 +489,7 @@ public class TestFunctions extends TestBase implements AggregateFunction {
// without white space
// without white space
stat
.
execute
(
"CREATE ALIAS PARSE_INT2 FOR \"java.lang.Integer.parseInt(java.lang.String,int)\""
);
stat
.
execute
(
"CREATE ALIAS PARSE_INT2 FOR \"java.lang.Integer.parseInt(java.lang.String,int)\""
);
stat
.
execute
(
"DROP ALIAS PARSE_INT2"
);
stat
.
execute
(
"DROP ALIAS PARSE_INT2"
);
conn
.
close
();
}
}
private
void
testSchemaSearchPath
()
throws
SQLException
{
private
void
testSchemaSearchPath
()
throws
SQLException
{
...
...
h2/src/test/org/h2/test/db/TestLinkedTable.java
浏览文件 @
43fde846
...
@@ -609,7 +609,7 @@ public class TestLinkedTable extends TestBase {
...
@@ -609,7 +609,7 @@ public class TestLinkedTable extends TestBase {
stat
.
execute
(
"CREATE TABLE TEST(ID INT PRIMARY KEY)"
);
stat
.
execute
(
"CREATE TABLE TEST(ID INT PRIMARY KEY)"
);
conn
.
close
();
conn
.
close
();
File
[]
files
=
new
File
(
baseDir
).
listFiles
();
File
[]
files
=
new
File
(
getBaseDir
()
).
listFiles
();
for
(
File
file
:
files
)
{
for
(
File
file
:
files
)
{
if
((
file
.
getName
().
startsWith
(
"testLinkedTableInReadOnlyDb"
))
&&
(!
file
.
getName
().
endsWith
(
".trace.db"
)))
{
if
((
file
.
getName
().
startsWith
(
"testLinkedTableInReadOnlyDb"
))
&&
(!
file
.
getName
().
endsWith
(
".trace.db"
)))
{
boolean
isReadOnly
=
file
.
setReadOnly
();
boolean
isReadOnly
=
file
.
setReadOnly
();
...
...
h2/src/test/org/h2/test/db/TestLob.java
浏览文件 @
43fde846
...
@@ -77,6 +77,7 @@ public class TestLob extends TestBase {
...
@@ -77,6 +77,7 @@ public class TestLob extends TestBase {
testLob
(
true
);
testLob
(
true
);
testJavaObject
();
testJavaObject
();
deleteDb
(
"lob"
);
deleteDb
(
"lob"
);
FileSystem
.
getInstance
(
TEMP_DIR
).
deleteRecursive
(
TEMP_DIR
,
false
);
}
}
private
void
testTempFilesDeleted
()
throws
Exception
{
private
void
testTempFilesDeleted
()
throws
Exception
{
...
@@ -145,10 +146,10 @@ public class TestLob extends TestBase {
...
@@ -145,10 +146,10 @@ public class TestLob extends TestBase {
Connection
conn
=
getConnection
(
"lob"
);
Connection
conn
=
getConnection
(
"lob"
);
Statement
stat
=
conn
.
createStatement
();
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"create table test(data clob) as select space(100000) from dual"
);
stat
.
execute
(
"create table test(data clob) as select space(100000) from dual"
);
assertEquals
(
1
,
IOUtils
.
listFiles
(
baseDir
+
"/lob.lobs.db"
).
length
);
assertEquals
(
1
,
IOUtils
.
listFiles
(
getBaseDir
()
+
"/lob.lobs.db"
).
length
);
stat
.
execute
(
"delete from test"
);
stat
.
execute
(
"delete from test"
);
conn
.
close
();
conn
.
close
();
assertEquals
(
0
,
IOUtils
.
listFiles
(
baseDir
+
"/lob.lobs.db"
).
length
);
assertEquals
(
0
,
IOUtils
.
listFiles
(
getBaseDir
()
+
"/lob.lobs.db"
).
length
);
}
}
private
void
testLobServerMemory
()
throws
SQLException
{
private
void
testLobServerMemory
()
throws
SQLException
{
...
@@ -172,18 +173,18 @@ public class TestLob extends TestBase {
...
@@ -172,18 +173,18 @@ public class TestLob extends TestBase {
Statement
stat
=
conn
.
createStatement
();
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"CREATE TABLE TEST(ID INT, DATA CLOB)"
);
stat
.
execute
(
"CREATE TABLE TEST(ID INT, DATA CLOB)"
);
stat
.
execute
(
"INSERT INTO TEST SELECT X, SPACE(10000) FROM SYSTEM_RANGE(1, 10)"
);
stat
.
execute
(
"INSERT INTO TEST SELECT X, SPACE(10000) FROM SYSTEM_RANGE(1, 10)"
);
ArrayList
<
String
>
list
=
FileLister
.
getDatabaseFiles
(
baseDir
,
"lob"
,
true
);
ArrayList
<
String
>
list
=
FileLister
.
getDatabaseFiles
(
getBaseDir
()
,
"lob"
,
true
);
stat
.
execute
(
"UPDATE TEST SET DATA = SPACE(5000)"
);
stat
.
execute
(
"UPDATE TEST SET DATA = SPACE(5000)"
);
collectAndWait
();
collectAndWait
();
stat
.
execute
(
"CHECKPOINT"
);
stat
.
execute
(
"CHECKPOINT"
);
ArrayList
<
String
>
list2
=
FileLister
.
getDatabaseFiles
(
baseDir
,
"lob"
,
true
);
ArrayList
<
String
>
list2
=
FileLister
.
getDatabaseFiles
(
getBaseDir
()
,
"lob"
,
true
);
if
(
list2
.
size
()
>=
list
.
size
()
+
5
)
{
if
(
list2
.
size
()
>=
list
.
size
()
+
5
)
{
fail
(
"Expected not many more files, got "
+
list2
.
size
()
+
" was "
+
list
.
size
());
fail
(
"Expected not many more files, got "
+
list2
.
size
()
+
" was "
+
list
.
size
());
}
}
stat
.
execute
(
"DELETE FROM TEST"
);
stat
.
execute
(
"DELETE FROM TEST"
);
collectAndWait
();
collectAndWait
();
stat
.
execute
(
"CHECKPOINT"
);
stat
.
execute
(
"CHECKPOINT"
);
ArrayList
<
String
>
list3
=
FileLister
.
getDatabaseFiles
(
baseDir
,
"lob"
,
true
);
ArrayList
<
String
>
list3
=
FileLister
.
getDatabaseFiles
(
getBaseDir
()
,
"lob"
,
true
);
if
(
list3
.
size
()
>=
list
.
size
())
{
if
(
list3
.
size
()
>=
list
.
size
())
{
fail
(
"Expected less files, got "
+
list2
.
size
()
+
" was "
+
list
.
size
());
fail
(
"Expected less files, got "
+
list2
.
size
()
+
" was "
+
list
.
size
());
}
}
...
@@ -573,7 +574,7 @@ public class TestLob extends TestBase {
...
@@ -573,7 +574,7 @@ public class TestLob extends TestBase {
trace
(
"time: "
+
time
+
" compress: "
+
compress
);
trace
(
"time: "
+
time
+
" compress: "
+
compress
);
conn
.
close
();
conn
.
close
();
if
(!
config
.
memory
&&
SysProperties
.
LOB_IN_DATABASE
)
{
if
(!
config
.
memory
&&
SysProperties
.
LOB_IN_DATABASE
)
{
long
length
=
new
File
(
baseDir
+
"/lob.h2.db"
).
length
();
long
length
=
new
File
(
getBaseDir
()
+
"/lob.h2.db"
).
length
();
trace
(
"len: "
+
length
+
" compress: "
+
compress
);
trace
(
"len: "
+
length
+
" compress: "
+
compress
);
}
}
}
}
...
...
h2/src/test/org/h2/test/db/TestMultiThreadedKernel.java
浏览文件 @
43fde846
...
@@ -79,6 +79,7 @@ public class TestMultiThreadedKernel extends TestBase {
...
@@ -79,6 +79,7 @@ public class TestMultiThreadedKernel extends TestBase {
if
(
exception
!=
null
)
{
if
(
exception
!=
null
)
{
throw
exception
;
throw
exception
;
}
}
deleteDb
(
"multiThreadedKernel"
);
}
}
}
}
h2/src/test/org/h2/test/db/TestOpenClose.java
浏览文件 @
43fde846
...
@@ -70,10 +70,10 @@ public class TestOpenClose extends TestBase implements DatabaseEventListener {
...
@@ -70,10 +70,10 @@ public class TestOpenClose extends TestBase implements DatabaseEventListener {
Statement
stat
=
conn
.
createStatement
();
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"CREATE TABLE TEST(C CLOB)"
);
stat
.
execute
(
"CREATE TABLE TEST(C CLOB)"
);
stat
.
execute
(
"INSERT INTO TEST VALUES(SPACE(10000))"
);
stat
.
execute
(
"INSERT INTO TEST VALUES(SPACE(10000))"
);
stat
.
execute
(
"BACKUP TO '"
+
baseDir
+
"/test.zip'"
);
stat
.
execute
(
"BACKUP TO '"
+
getBaseDir
()
+
"/test.zip'"
);
conn
.
close
();
conn
.
close
();
deleteDb
(
"openClose"
);
deleteDb
(
"openClose"
);
Restore
.
execute
(
baseDir
+
"/test.zip"
,
baseDir
,
null
,
true
);
Restore
.
execute
(
getBaseDir
()
+
"/test.zip"
,
getBaseDir
()
,
null
,
true
);
conn
=
DriverManager
.
getConnection
(
url
,
"sa"
,
"abc def"
);
conn
=
DriverManager
.
getConnection
(
url
,
"sa"
,
"abc def"
);
stat
=
conn
.
createStatement
();
stat
=
conn
.
createStatement
();
ResultSet
rs
=
stat
.
executeQuery
(
"SELECT * FROM TEST"
);
ResultSet
rs
=
stat
.
executeQuery
(
"SELECT * FROM TEST"
);
...
@@ -81,7 +81,7 @@ public class TestOpenClose extends TestBase implements DatabaseEventListener {
...
@@ -81,7 +81,7 @@ public class TestOpenClose extends TestBase implements DatabaseEventListener {
assertEquals
(
10000
,
rs
.
getString
(
1
).
length
());
assertEquals
(
10000
,
rs
.
getString
(
1
).
length
());
assertFalse
(
rs
.
next
());
assertFalse
(
rs
.
next
());
conn
.
close
();
conn
.
close
();
IOUtils
.
delete
(
baseDir
+
"/test.zip"
);
IOUtils
.
delete
(
getBaseDir
()
+
"/test.zip"
);
}
}
private
void
testReconnectFast
()
throws
SQLException
{
private
void
testReconnectFast
()
throws
SQLException
{
...
...
h2/src/test/org/h2/test/db/TestPowerOff.java
浏览文件 @
43fde846
...
@@ -43,7 +43,7 @@ public class TestPowerOff extends TestBase {
...
@@ -43,7 +43,7 @@ public class TestPowerOff extends TestBase {
return
;
return
;
}
}
if
(
config
.
big
||
config
.
googleAppEngine
)
{
if
(
config
.
big
||
config
.
googleAppEngine
)
{
dir
=
baseDir
;
dir
=
getBaseDir
()
;
}
else
{
}
else
{
dir
=
"memFS:"
;
dir
=
"memFS:"
;
}
}
...
...
h2/src/test/org/h2/test/db/TestReadOnly.java
浏览文件 @
43fde846
...
@@ -15,6 +15,7 @@ import java.sql.Statement;
...
@@ -15,6 +15,7 @@ import java.sql.Statement;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
org.h2.constant.ErrorCode
;
import
org.h2.constant.ErrorCode
;
import
org.h2.store.FileLister
;
import
org.h2.store.FileLister
;
import
org.h2.store.fs.FileSystem
;
import
org.h2.test.TestBase
;
import
org.h2.test.TestBase
;
/**
/**
...
@@ -128,10 +129,10 @@ public class TestReadOnly extends TestBase {
...
@@ -128,10 +129,10 @@ public class TestReadOnly extends TestBase {
}
}
private
void
setReadOnly
()
{
private
void
setReadOnly
()
{
ArrayList
<
String
>
list
=
FileLister
.
getDatabaseFiles
(
TestBase
.
baseDir
,
"readonly"
,
true
);
FileSystem
fs
=
FileSystem
.
getInstance
(
getBaseDir
());
ArrayList
<
String
>
list
=
FileLister
.
getDatabaseFiles
(
getBaseDir
(),
"readonly"
,
true
);
for
(
String
fileName
:
list
)
{
for
(
String
fileName
:
list
)
{
File
file
=
new
File
(
fileName
);
fs
.
setReadOnly
(
fileName
);
file
.
setReadOnly
();
}
}
}
}
...
...
h2/src/test/org/h2/test/db/TestRights.java
浏览文件 @
43fde846
...
@@ -220,7 +220,7 @@ public class TestRights extends TestBase {
...
@@ -220,7 +220,7 @@ public class TestRights extends TestBase {
executeSuccess
(
"ALTER USER TEST SET PASSWORD 'def'"
);
executeSuccess
(
"ALTER USER TEST SET PASSWORD 'def'"
);
executeSuccess
(
"CREATE USER TEST2 PASSWORD 'def' ADMIN"
);
executeSuccess
(
"CREATE USER TEST2 PASSWORD 'def' ADMIN"
);
executeSuccess
(
"ALTER USER TEST ADMIN FALSE"
);
executeSuccess
(
"ALTER USER TEST ADMIN FALSE"
);
executeSuccess
(
"SCRIPT TO '"
+
baseDir
+
"/rights.sql' CIPHER XTEA PASSWORD 'test'"
);
executeSuccess
(
"SCRIPT TO '"
+
getBaseDir
()
+
"/rights.sql' CIPHER XTEA PASSWORD 'test'"
);
conn
.
close
();
conn
.
close
();
try
{
try
{
...
@@ -288,7 +288,7 @@ public class TestRights extends TestBase {
...
@@ -288,7 +288,7 @@ public class TestRights extends TestBase {
conn
.
close
();
conn
.
close
();
conn
=
getConnection
(
"rights"
);
conn
=
getConnection
(
"rights"
);
conn
.
close
();
conn
.
close
();
IOUtils
.
delete
(
baseDir
+
"/rights.sql"
);
IOUtils
.
delete
(
getBaseDir
()
+
"/rights.sql"
);
}
}
private
void
testTableType
(
Connection
conn
,
String
type
)
throws
SQLException
{
private
void
testTableType
(
Connection
conn
,
String
type
)
throws
SQLException
{
...
...
h2/src/test/org/h2/test/db/TestRunscript.java
浏览文件 @
43fde846
...
@@ -54,14 +54,15 @@ public class TestRunscript extends TestBase implements Trigger {
...
@@ -54,14 +54,15 @@ public class TestRunscript extends TestBase implements Trigger {
stat
.
execute
(
"create table test(id int not null, data clob) as select 1, space(4100)"
);
stat
.
execute
(
"create table test(id int not null, data clob) as select 1, space(4100)"
);
// the primary key for SYSTEM_LOB_STREAM used to be named like this
// the primary key for SYSTEM_LOB_STREAM used to be named like this
stat
.
execute
(
"create primary key primary_key_e on test(id)"
);
stat
.
execute
(
"create primary key primary_key_e on test(id)"
);
stat
.
execute
(
"script to '"
+
baseDir
+
"/backup.sql'"
);
stat
.
execute
(
"script to '"
+
getBaseDir
()
+
"/backup.sql'"
);
conn
.
close
();
conn
.
close
();
deleteDb
(
"runscript"
);
deleteDb
(
"runscript"
);
conn
=
getConnection
(
"runscript"
);
conn
=
getConnection
(
"runscript"
);
stat
=
conn
.
createStatement
();
stat
=
conn
.
createStatement
();
stat
.
execute
(
"runscript from '"
+
baseDir
+
"/backup.sql'"
);
stat
.
execute
(
"runscript from '"
+
getBaseDir
()
+
"/backup.sql'"
);
conn
.
close
();
conn
.
close
();
deleteDb
(
"runscriptRestore"
);
deleteDb
(
"runscriptRestore"
);
IOUtils
.
delete
(
getBaseDir
()
+
"/backup.sql"
);
}
}
private
void
test
(
boolean
password
)
throws
SQLException
{
private
void
test
(
boolean
password
)
throws
SQLException
{
...
@@ -88,7 +89,7 @@ public class TestRunscript extends TestBase implements Trigger {
...
@@ -88,7 +89,7 @@ public class TestRunscript extends TestBase implements Trigger {
stat1
.
execute
(
"grant select, insert on testSchema.parent to testRole"
);
stat1
.
execute
(
"grant select, insert on testSchema.parent to testRole"
);
stat1
.
execute
(
"grant testRole to testUser"
);
stat1
.
execute
(
"grant testRole to testUser"
);
String
sql
=
"script to '"
+
baseDir
+
"/backup.2.sql'"
;
String
sql
=
"script to '"
+
getBaseDir
()
+
"/backup.2.sql'"
;
if
(
password
)
{
if
(
password
)
{
sql
+=
" CIPHER AES PASSWORD 't1e2s3t4'"
;
sql
+=
" CIPHER AES PASSWORD 't1e2s3t4'"
;
}
}
...
@@ -97,7 +98,7 @@ public class TestRunscript extends TestBase implements Trigger {
...
@@ -97,7 +98,7 @@ public class TestRunscript extends TestBase implements Trigger {
deleteDb
(
"runscriptRestore"
);
deleteDb
(
"runscriptRestore"
);
conn2
=
getConnection
(
"runscriptRestore"
);
conn2
=
getConnection
(
"runscriptRestore"
);
stat2
=
conn2
.
createStatement
();
stat2
=
conn2
.
createStatement
();
sql
=
"runscript from '"
+
baseDir
+
"/backup.2.sql'"
;
sql
=
"runscript from '"
+
getBaseDir
()
+
"/backup.2.sql'"
;
if
(
password
)
{
if
(
password
)
{
sql
+=
" CIPHER AES PASSWORD 'wrongPassword'"
;
sql
+=
" CIPHER AES PASSWORD 'wrongPassword'"
;
}
}
...
@@ -109,20 +110,20 @@ public class TestRunscript extends TestBase implements Trigger {
...
@@ -109,20 +110,20 @@ public class TestRunscript extends TestBase implements Trigger {
assertKnownException
(
e
);
assertKnownException
(
e
);
}
}
}
}
sql
=
"runscript from '"
+
baseDir
+
"/backup.2.sql'"
;
sql
=
"runscript from '"
+
getBaseDir
()
+
"/backup.2.sql'"
;
if
(
password
)
{
if
(
password
)
{
sql
+=
" CIPHER AES PASSWORD 't1e2s3t4'"
;
sql
+=
" CIPHER AES PASSWORD 't1e2s3t4'"
;
}
}
stat2
.
execute
(
sql
);
stat2
.
execute
(
sql
);
stat2
.
execute
(
"script to '"
+
baseDir
+
"/backup.3.sql'"
);
stat2
.
execute
(
"script to '"
+
getBaseDir
()
+
"/backup.3.sql'"
);
assertEqualDatabases
(
stat1
,
stat2
);
assertEqualDatabases
(
stat1
,
stat2
);
conn1
.
close
();
conn1
.
close
();
conn2
.
close
();
conn2
.
close
();
deleteDb
(
"runscriptRestore"
);
deleteDb
(
"runscriptRestore"
);
IOUtils
.
delete
(
baseDir
+
"/backup.2.sql"
);
IOUtils
.
delete
(
getBaseDir
()
+
"/backup.2.sql"
);
IOUtils
.
delete
(
baseDir
+
"/backup.3.sql"
);
IOUtils
.
delete
(
getBaseDir
()
+
"/backup.3.sql"
);
}
}
...
...
h2/src/test/org/h2/test/db/TestSpaceReuse.java
浏览文件 @
43fde846
...
@@ -42,7 +42,7 @@ public class TestSpaceReuse extends TestBase {
...
@@ -42,7 +42,7 @@ public class TestSpaceReuse extends TestBase {
conn
=
getConnection
(
"spaceReuse"
);
conn
=
getConnection
(
"spaceReuse"
);
conn
.
createStatement
().
execute
(
"delete from t"
);
conn
.
createStatement
().
execute
(
"delete from t"
);
conn
.
close
();
conn
.
close
();
now
=
new
File
(
baseDir
+
"/spaceReuse.data.db"
).
length
();
now
=
new
File
(
getBaseDir
()
+
"/spaceReuse.data.db"
).
length
();
if
(
first
==
0
)
{
if
(
first
==
0
)
{
first
=
now
;
first
=
now
;
}
}
...
...
h2/src/test/org/h2/test/db/TestTempTables.java
浏览文件 @
43fde846
...
@@ -6,13 +6,13 @@
...
@@ -6,13 +6,13 @@
*/
*/
package
org
.
h2
.
test
.
db
;
package
org
.
h2
.
test
.
db
;
import
java.io.File
;
import
java.sql.Connection
;
import
java.sql.Connection
;
import
java.sql.ResultSet
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
java.sql.Statement
;
import
org.h2.engine.Constants
;
import
org.h2.engine.Constants
;
import
org.h2.test.TestBase
;
import
org.h2.test.TestBase
;
import
org.h2.util.IOUtils
;
/**
/**
* Temporary table tests.
* Temporary table tests.
...
@@ -57,12 +57,12 @@ public class TestTempTables extends TestBase {
...
@@ -57,12 +57,12 @@ public class TestTempTables extends TestBase {
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
// expected
// expected
}
}
String
dbName
=
baseDir
+
"/tempTables"
+
Constants
.
SUFFIX_PAGE_FILE
;
String
dbName
=
getBaseDir
()
+
"/tempTables"
+
Constants
.
SUFFIX_PAGE_FILE
;
long
before
=
new
File
(
dbName
).
length
(
);
long
before
=
IOUtils
.
length
(
dbName
);
assertTrue
(
before
>
0
);
assertTrue
(
before
>
0
);
conn
=
getConnection
(
"tempTables"
);
conn
=
getConnection
(
"tempTables"
);
conn
.
close
();
conn
.
close
();
long
after
=
new
File
(
dbName
).
length
(
);
long
after
=
IOUtils
.
length
(
dbName
);
assertEquals
(
after
,
before
);
assertEquals
(
after
,
before
);
}
}
...
...
h2/src/test/org/h2/test/jdbc/TestCallableStatement.java
浏览文件 @
43fde846
...
@@ -30,7 +30,7 @@ public class TestCallableStatement extends TestBase {
...
@@ -30,7 +30,7 @@ public class TestCallableStatement extends TestBase {
public
void
test
()
throws
SQLException
{
public
void
test
()
throws
SQLException
{
deleteDb
(
"callableStatement"
);
deleteDb
(
"callableStatement"
);
Connection
conn
=
getConnection
(
"
prepared
Statement"
);
Connection
conn
=
getConnection
(
"
callable
Statement"
);
testPrepare
(
conn
);
testPrepare
(
conn
);
conn
.
close
();
conn
.
close
();
deleteDb
(
"callableStatement"
);
deleteDb
(
"callableStatement"
);
...
...
h2/src/test/org/h2/test/jdbc/TestStatement.java
浏览文件 @
43fde846
...
@@ -56,7 +56,7 @@ public class TestStatement extends TestBase {
...
@@ -56,7 +56,7 @@ public class TestStatement extends TestBase {
return
;
return
;
}
}
Statement
stat
=
conn
.
createStatement
();
Statement
stat
=
conn
.
createStatement
();
String
fileName
=
baseDir
+
"/statement.trace.db"
;
String
fileName
=
getBaseDir
()
+
"/statement.trace.db"
;
stat
.
execute
(
"DROP TABLE TEST IF EXISTS"
);
stat
.
execute
(
"DROP TABLE TEST IF EXISTS"
);
stat
.
execute
(
"CREATE TABLE TEST(ID INT PRIMARY KEY)"
);
stat
.
execute
(
"CREATE TABLE TEST(ID INT PRIMARY KEY)"
);
stat
.
execute
(
"INSERT INTO TEST VALUES(1)"
);
stat
.
execute
(
"INSERT INTO TEST VALUES(1)"
);
...
...
h2/src/test/org/h2/test/server/TestAutoServer.java
浏览文件 @
43fde846
...
@@ -55,7 +55,7 @@ public class TestAutoServer extends TestBase {
...
@@ -55,7 +55,7 @@ public class TestAutoServer extends TestBase {
int
i
=
ITERATIONS
;
int
i
=
ITERATIONS
;
for
(;
i
>
0
;
i
--)
{
for
(;
i
>
0
;
i
--)
{
Thread
.
sleep
(
100
);
Thread
.
sleep
(
100
);
SortedProperties
prop
=
SortedProperties
.
loadProperties
(
baseDir
+
"/autoServer.lock.db"
);
SortedProperties
prop
=
SortedProperties
.
loadProperties
(
getBaseDir
()
+
"/autoServer.lock.db"
);
String
key
=
prop
.
getProperty
(
"id"
);
String
key
=
prop
.
getProperty
(
"id"
);
String
server
=
prop
.
getProperty
(
"server"
);
String
server
=
prop
.
getProperty
(
"server"
);
if
(
server
!=
null
)
{
if
(
server
!=
null
)
{
...
@@ -124,7 +124,7 @@ public class TestAutoServer extends TestBase {
...
@@ -124,7 +124,7 @@ public class TestAutoServer extends TestBase {
// Now test insert
// Now test insert
statAutoServer2
.
execute
(
"INSERT INTO T (ID) VALUES('abc')"
);
statAutoServer2
.
execute
(
"INSERT INTO T (ID) VALUES('abc')"
);
statAutoServer2
.
execute
(
"drop table t"
);
connAutoServer2
.
close
();
connAutoServer2
.
close
();
// this will also close the linked connection from statAutoServer1
// this will also close the linked connection from statAutoServer1
...
...
h2/src/test/org/h2/test/server/TestInit.java
浏览文件 @
43fde846
...
@@ -6,8 +6,9 @@
...
@@ -6,8 +6,9 @@
*/
*/
package
org
.
h2
.
test
.
server
;
package
org
.
h2
.
test
.
server
;
import
java.io.
File
Writer
;
import
java.io.
OutputStream
Writer
;
import
java.io.PrintWriter
;
import
java.io.PrintWriter
;
import
java.io.Writer
;
import
java.sql.Connection
;
import
java.sql.Connection
;
import
java.sql.ResultSet
;
import
java.sql.ResultSet
;
import
java.sql.Statement
;
import
java.sql.Statement
;
...
@@ -30,17 +31,21 @@ public class TestInit extends TestBase {
...
@@ -30,17 +31,21 @@ public class TestInit extends TestBase {
public
void
test
()
throws
Exception
{
public
void
test
()
throws
Exception
{
String
init1
=
getBaseDir
()
+
"/test-init-1.sql"
;
String
init2
=
getBaseDir
()
+
"/test-init-2.sql"
;
// Create two scripts that we will run via "INIT"
// Create two scripts that we will run via "INIT"
IOUtils
.
createDirs
(
baseDir
+
"/test-init-1.sql"
);
IOUtils
.
createDirs
(
init1
);
FileWriter
fw
=
new
FileWriter
(
baseDir
+
"/test-init-1.sql"
);
Writer
w
=
new
OutputStreamWriter
(
IOUtils
.
openFileOutputStream
(
init1
,
false
));
PrintWriter
writer
=
new
PrintWriter
(
f
w
);
PrintWriter
writer
=
new
PrintWriter
(
w
);
writer
.
println
(
"create table test(id int identity, name varchar);"
);
writer
.
println
(
"create table test(id int identity, name varchar);"
);
writer
.
println
(
"insert into test(name) values('cat');"
);
writer
.
println
(
"insert into test(name) values('cat');"
);
writer
.
close
();
writer
.
close
();
fw
=
new
FileWriter
(
baseDir
+
"/test-init-2.sql"
);
w
=
new
OutputStreamWriter
(
IOUtils
.
openFileOutputStream
(
init2
,
false
)
);
writer
=
new
PrintWriter
(
f
w
);
writer
=
new
PrintWriter
(
w
);
writer
.
println
(
"insert into test(name) values('dog');"
);
writer
.
println
(
"insert into test(name) values('dog');"
);
writer
.
close
();
writer
.
close
();
...
@@ -48,8 +53,8 @@ public class TestInit extends TestBase {
...
@@ -48,8 +53,8 @@ public class TestInit extends TestBase {
deleteDb
(
"initDb"
);
deleteDb
(
"initDb"
);
Connection
conn
=
getConnection
(
"initDb;"
+
Connection
conn
=
getConnection
(
"initDb;"
+
"INIT="
+
"INIT="
+
"RUNSCRIPT FROM '"
+
baseDir
+
"/test-init-1.sql
'\\;"
+
"RUNSCRIPT FROM '"
+
init1
+
"
'\\;"
+
"RUNSCRIPT FROM '"
+
baseDir
+
"/test-init-2.sql
'"
);
"RUNSCRIPT FROM '"
+
init2
+
"
'"
);
Statement
stat
=
conn
.
createStatement
();
Statement
stat
=
conn
.
createStatement
();
...
@@ -67,8 +72,8 @@ public class TestInit extends TestBase {
...
@@ -67,8 +72,8 @@ public class TestInit extends TestBase {
conn
.
close
();
conn
.
close
();
deleteDb
(
"initDb"
);
deleteDb
(
"initDb"
);
IOUtils
.
delete
(
baseDir
+
"/test-init-1.sql"
);
IOUtils
.
delete
(
init1
);
IOUtils
.
delete
(
baseDir
+
"/test-init-2.sql"
);
IOUtils
.
delete
(
init2
);
}
}
}
}
h2/src/test/org/h2/test/synth/TestBtreeIndex.java
浏览文件 @
43fde846
...
@@ -62,13 +62,11 @@ public class TestBtreeIndex extends TestBase {
...
@@ -62,13 +62,11 @@ public class TestBtreeIndex extends TestBase {
}
finally
{
}
finally
{
conn
.
close
();
conn
.
close
();
}
}
deleteDb
(
"index"
);
}
}
public
void
testCase
(
int
seed
)
throws
SQLException
{
public
void
testCase
(
int
seed
)
throws
SQLException
{
String
old
=
baseDir
;
baseDir
=
TestBase
.
getTestDir
(
"index"
);
testOne
(
seed
);
testOne
(
seed
);
baseDir
=
old
;
}
}
private
void
testOne
(
int
seed
)
throws
SQLException
{
private
void
testOne
(
int
seed
)
throws
SQLException
{
...
@@ -96,7 +94,7 @@ public class TestBtreeIndex extends TestBase {
...
@@ -96,7 +94,7 @@ public class TestBtreeIndex extends TestBase {
}
}
}
}
String
prefix
=
buff
.
toString
().
substring
(
0
,
prefixLength
);
String
prefix
=
buff
.
toString
().
substring
(
0
,
prefixLength
);
DeleteDbFiles
.
execute
(
baseDir
,
null
,
true
);
DeleteDbFiles
.
execute
(
getBaseDir
()
+
"/index"
,
null
,
true
);
Connection
conn
=
getConnection
(
"index"
);
Connection
conn
=
getConnection
(
"index"
);
try
{
try
{
Statement
stat
=
conn
.
createStatement
();
Statement
stat
=
conn
.
createStatement
();
...
@@ -181,6 +179,7 @@ public class TestBtreeIndex extends TestBase {
...
@@ -181,6 +179,7 @@ public class TestBtreeIndex extends TestBase {
}
finally
{
}
finally
{
conn
.
close
();
conn
.
close
();
}
}
deleteDb
(
"index"
);
}
}
private
void
printError
(
int
seed
,
String
message
)
{
private
void
printError
(
int
seed
,
String
message
)
{
...
...
h2/src/test/org/h2/test/synth/TestCrashAPI.java
浏览文件 @
43fde846
...
@@ -129,7 +129,7 @@ public class TestCrashAPI extends TestBase {
...
@@ -129,7 +129,7 @@ public class TestCrashAPI extends TestBase {
private
void
deleteDb
()
{
private
void
deleteDb
()
{
try
{
try
{
deleteDb
(
baseDir
+
"/"
+
DIR
,
null
);
deleteDb
(
getBaseDir
()
+
"/"
+
DIR
,
null
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
// ignore
// ignore
}
}
...
@@ -166,7 +166,7 @@ public class TestCrashAPI extends TestBase {
...
@@ -166,7 +166,7 @@ public class TestCrashAPI extends TestBase {
Connection
conn
=
null
;
Connection
conn
=
null
;
String
fileName
=
"temp/backup/db-"
+
uniqueId
++
+
".zip"
;
String
fileName
=
"temp/backup/db-"
+
uniqueId
++
+
".zip"
;
Backup
.
execute
(
fileName
,
baseDir
+
"/"
+
DIR
,
dbName
,
true
);
Backup
.
execute
(
fileName
,
getBaseDir
()
+
"/"
+
DIR
,
dbName
,
true
);
// close databases earlier
// close databases earlier
System
.
gc
();
System
.
gc
();
try
{
try
{
...
@@ -470,7 +470,6 @@ public class TestCrashAPI extends TestBase {
...
@@ -470,7 +470,6 @@ public class TestCrashAPI extends TestBase {
if
(
config
.
mvcc
||
config
.
networked
)
{
if
(
config
.
mvcc
||
config
.
networked
)
{
return
this
;
return
this
;
}
}
baseDir
=
TestBase
.
getTestDir
(
"crash"
);
startServerIfRequired
();
startServerIfRequired
();
TestScript
script
=
new
TestScript
();
TestScript
script
=
new
TestScript
();
ArrayList
<
String
>
add
=
script
.
getAllStatements
(
config
);
ArrayList
<
String
>
add
=
script
.
getAllStatements
(
config
);
...
@@ -482,13 +481,10 @@ public class TestCrashAPI extends TestBase {
...
@@ -482,13 +481,10 @@ public class TestCrashAPI extends TestBase {
public
void
testCase
(
int
i
)
throws
SQLException
{
public
void
testCase
(
int
i
)
throws
SQLException
{
int
old
=
SysProperties
.
getMaxQueryTimeout
();
int
old
=
SysProperties
.
getMaxQueryTimeout
();
String
oldBaseDir
=
baseDir
;
try
{
try
{
System
.
setProperty
(
SysProperties
.
H2_MAX_QUERY_TIMEOUT
,
""
+
10000
);
System
.
setProperty
(
SysProperties
.
H2_MAX_QUERY_TIMEOUT
,
""
+
10000
);
baseDir
=
TestBase
.
getTestDir
(
"crash"
);
testOne
(
i
);
testOne
(
i
);
}
finally
{
}
finally
{
baseDir
=
oldBaseDir
;
System
.
setProperty
(
SysProperties
.
H2_MAX_QUERY_TIMEOUT
,
""
+
old
);
System
.
setProperty
(
SysProperties
.
H2_MAX_QUERY_TIMEOUT
,
""
+
old
);
}
}
}
}
...
...
h2/src/test/org/h2/test/synth/TestHalt.java
浏览文件 @
43fde846
...
@@ -62,11 +62,6 @@ public abstract class TestHalt extends TestBase {
...
@@ -62,11 +62,6 @@ public abstract class TestHalt extends TestBase {
*/
*/
protected
static
final
int
FLAG_LOBS
=
2
;
protected
static
final
int
FLAG_LOBS
=
2
;
/**
* The test directory.
*/
static
final
String
DIR
=
TestBase
.
getTestDir
(
"halt"
);
private
static
final
String
DATABASE_NAME
=
"halt"
;
private
static
final
String
DATABASE_NAME
=
"halt"
;
private
static
final
String
TRACE_FILE_NAME
=
"haltTrace.trace.db"
;
private
static
final
String
TRACE_FILE_NAME
=
"haltTrace.trace.db"
;
...
@@ -140,7 +135,7 @@ public abstract class TestHalt extends TestBase {
...
@@ -140,7 +135,7 @@ public abstract class TestHalt extends TestBase {
Connection
getConnection
()
throws
SQLException
{
Connection
getConnection
()
throws
SQLException
{
org
.
h2
.
Driver
.
load
();
org
.
h2
.
Driver
.
load
();
String
url
=
"jdbc:h2:"
+
baseDir
+
"/halt"
;
String
url
=
"jdbc:h2:"
+
getBaseDir
()
+
"/halt"
;
// String url = "jdbc:h2:" + baseDir + "/halt;TRACE_LEVEL_FILE=3";
// String url = "jdbc:h2:" + baseDir + "/halt;TRACE_LEVEL_FILE=3";
return
DriverManager
.
getConnection
(
url
,
"sa"
,
"sa"
);
return
DriverManager
.
getConnection
(
url
,
"sa"
,
"sa"
);
}
}
...
@@ -193,7 +188,7 @@ public abstract class TestHalt extends TestBase {
...
@@ -193,7 +188,7 @@ public abstract class TestHalt extends TestBase {
protected
void
traceOperation
(
String
s
,
Exception
e
)
{
protected
void
traceOperation
(
String
s
,
Exception
e
)
{
FileWriter
writer
=
null
;
FileWriter
writer
=
null
;
try
{
try
{
File
f
=
new
File
(
baseDir
+
"/"
+
TRACE_FILE_NAME
);
File
f
=
new
File
(
getBaseDir
()
+
"/"
+
TRACE_FILE_NAME
);
f
.
getParentFile
().
mkdirs
();
f
.
getParentFile
().
mkdirs
();
writer
=
new
FileWriter
(
f
,
true
);
writer
=
new
FileWriter
(
f
,
true
);
PrintWriter
w
=
new
PrintWriter
(
writer
);
PrintWriter
w
=
new
PrintWriter
(
writer
);
...
@@ -215,15 +210,15 @@ public abstract class TestHalt extends TestBase {
...
@@ -215,15 +210,15 @@ public abstract class TestHalt extends TestBase {
*/
*/
void
controllerTest
()
throws
Exception
{
void
controllerTest
()
throws
Exception
{
traceOperation
(
"delete database -----------------------------"
);
traceOperation
(
"delete database -----------------------------"
);
DeleteDbFiles
.
execute
(
baseDir
,
DATABASE_NAME
,
true
);
DeleteDbFiles
.
execute
(
getBaseDir
()
,
DATABASE_NAME
,
true
);
new
File
(
baseDir
+
"/"
+
TRACE_FILE_NAME
).
delete
();
new
File
(
getBaseDir
()
+
"/"
+
TRACE_FILE_NAME
).
delete
();
connect
();
connect
();
controllerInit
();
controllerInit
();
disconnect
();
disconnect
();
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
traceOperation
(
"backing up "
+
sequenceId
);
traceOperation
(
"backing up "
+
sequenceId
);
Backup
.
execute
(
baseDir
+
"/haltSeq"
+
sequenceId
+
".zip"
,
baseDir
,
null
,
true
);
Backup
.
execute
(
getBaseDir
()
+
"/haltSeq"
+
sequenceId
+
".zip"
,
getBaseDir
()
,
null
,
true
);
sequenceId
++;
sequenceId
++;
// int operations = OP_INSERT;
// int operations = OP_INSERT;
// OP_DELETE = 1, OP_UPDATE = 2, OP_SELECT = 4;
// OP_DELETE = 1, OP_UPDATE = 2, OP_SELECT = 4;
...
@@ -253,14 +248,14 @@ public abstract class TestHalt extends TestBase {
...
@@ -253,14 +248,14 @@ public abstract class TestHalt extends TestBase {
p
.
waitFor
();
p
.
waitFor
();
try
{
try
{
traceOperation
(
"backing up "
+
sequenceId
);
traceOperation
(
"backing up "
+
sequenceId
);
Backup
.
execute
(
baseDir
+
"/haltSeq"
+
sequenceId
+
".zip"
,
baseDir
,
null
,
true
);
Backup
.
execute
(
getBaseDir
()
+
"/haltSeq"
+
sequenceId
+
".zip"
,
getBaseDir
()
,
null
,
true
);
// new File(BASE_DIR + "/haltSeq" + (sequenceId-20) +
// new File(BASE_DIR + "/haltSeq" + (sequenceId-20) +
// ".zip").delete();
// ".zip").delete();
connect
();
connect
();
controllerCheckAfterCrash
();
controllerCheckAfterCrash
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
File
zip
=
new
File
(
baseDir
+
"/haltSeq"
+
sequenceId
+
".zip"
);
File
zip
=
new
File
(
getBaseDir
()
+
"/haltSeq"
+
sequenceId
+
".zip"
);
File
zipId
=
new
File
(
baseDir
+
"/haltSeq"
+
sequenceId
+
"-"
+
errorId
+
".zip"
);
File
zipId
=
new
File
(
getBaseDir
()
+
"/haltSeq"
+
sequenceId
+
"-"
+
errorId
+
".zip"
);
zip
.
renameTo
(
zipId
);
zip
.
renameTo
(
zipId
);
printTime
(
"ERROR: "
+
sequenceId
+
" "
+
errorId
+
" "
+
e
.
toString
());
printTime
(
"ERROR: "
+
sequenceId
+
" "
+
errorId
+
" "
+
e
.
toString
());
e
.
printStackTrace
();
e
.
printStackTrace
();
...
@@ -350,7 +345,6 @@ public abstract class TestHalt extends TestBase {
...
@@ -350,7 +345,6 @@ public abstract class TestHalt extends TestBase {
public
TestBase
init
(
TestAll
conf
)
throws
Exception
{
public
TestBase
init
(
TestAll
conf
)
throws
Exception
{
super
.
init
(
conf
);
super
.
init
(
conf
);
baseDir
=
DIR
;
return
this
;
return
this
;
}
}
...
...
h2/src/test/org/h2/test/synth/TestHaltApp.java
浏览文件 @
43fde846
...
@@ -28,7 +28,6 @@ public class TestHaltApp extends TestHalt {
...
@@ -28,7 +28,6 @@ public class TestHaltApp extends TestHalt {
*/
*/
public
static
void
main
(
String
...
args
)
throws
Exception
{
public
static
void
main
(
String
...
args
)
throws
Exception
{
SelfDestructor
.
startCountdown
(
60
);
SelfDestructor
.
startCountdown
(
60
);
baseDir
=
TestHalt
.
DIR
;
TestHaltApp
app
=
new
TestHaltApp
();
TestHaltApp
app
=
new
TestHaltApp
();
if
(
args
.
length
==
0
)
{
if
(
args
.
length
==
0
)
{
app
.
controllerTest
();
app
.
controllerTest
();
...
...
h2/src/test/org/h2/test/synth/TestJoin.java
浏览文件 @
43fde846
...
@@ -42,10 +42,7 @@ public class TestJoin extends TestBase {
...
@@ -42,10 +42,7 @@ public class TestJoin extends TestBase {
}
}
public
void
test
()
throws
Exception
{
public
void
test
()
throws
Exception
{
String
old
=
baseDir
;
baseDir
=
TestBase
.
getTestDir
(
"join"
);
testJoin
();
testJoin
();
baseDir
=
old
;
}
}
private
void
testJoin
()
throws
Exception
{
private
void
testJoin
()
throws
Exception
{
...
...
h2/src/test/org/h2/test/synth/TestKill.java
浏览文件 @
43fde846
...
@@ -51,7 +51,7 @@ public class TestKill extends TestBase {
...
@@ -51,7 +51,7 @@ public class TestKill extends TestBase {
"java"
,
selfDestruct
,
"java"
,
selfDestruct
,
"-cp"
,
getClassPath
(),
"-cp"
,
getClassPath
(),
"org.h2.test.synth.TestKillProcess"
,
url
,
user
,
"org.h2.test.synth.TestKillProcess"
,
url
,
user
,
password
,
baseDir
,
""
+
accounts
};
password
,
getBaseDir
()
,
""
+
accounts
};
for
(
int
i
=
0
;;
i
++)
{
for
(
int
i
=
0
;;
i
++)
{
printTime
(
"TestKill "
+
i
);
printTime
(
"TestKill "
+
i
);
...
...
h2/src/test/org/h2/test/synth/TestKillRestart.java
浏览文件 @
43fde846
...
@@ -26,6 +26,9 @@ public class TestKillRestart extends TestBase {
...
@@ -26,6 +26,9 @@ public class TestKillRestart extends TestBase {
if
(
config
.
networked
)
{
if
(
config
.
networked
)
{
return
;
return
;
}
}
if
(
getBaseDir
().
indexOf
(
':'
)
>
0
)
{
return
;
}
deleteDb
(
"killRestart"
);
deleteDb
(
"killRestart"
);
String
url
=
getURL
(
"killRestart"
,
true
);
String
url
=
getURL
(
"killRestart"
,
true
);
// String url = getURL(
// String url = getURL(
...
...
h2/src/test/org/h2/test/synth/TestKillRestartMulti.java
浏览文件 @
43fde846
...
@@ -40,6 +40,9 @@ public class TestKillRestartMulti extends TestBase {
...
@@ -40,6 +40,9 @@ public class TestKillRestartMulti extends TestBase {
if
(
config
.
networked
)
{
if
(
config
.
networked
)
{
return
;
return
;
}
}
if
(
getBaseDir
().
indexOf
(
':'
)
>
0
)
{
return
;
}
deleteDb
(
"killRestartMulti"
);
deleteDb
(
"killRestartMulti"
);
url
=
getURL
(
"killRestartMulti"
,
true
);
url
=
getURL
(
"killRestartMulti"
,
true
);
user
=
getUser
();
user
=
getUser
();
...
@@ -86,9 +89,9 @@ public class TestKillRestartMulti extends TestBase {
...
@@ -86,9 +89,9 @@ public class TestKillRestartMulti extends TestBase {
fail
(
"Failed: "
+
s
);
fail
(
"Failed: "
+
s
);
}
}
}
}
String
backup
=
baseDir
+
"/killRestartMulti-"
+
System
.
currentTimeMillis
()
+
".zip"
;
String
backup
=
getBaseDir
()
+
"/killRestartMulti-"
+
System
.
currentTimeMillis
()
+
".zip"
;
try
{
try
{
Backup
.
execute
(
backup
,
baseDir
,
"killRestartMulti"
,
true
);
Backup
.
execute
(
backup
,
getBaseDir
()
,
"killRestartMulti"
,
true
);
Connection
conn
=
null
;
Connection
conn
=
null
;
for
(
int
j
=
0
;;
j
++)
{
for
(
int
j
=
0
;;
j
++)
{
try
{
try
{
...
...
h2/src/test/org/h2/test/synth/TestPowerOffFs.java
浏览文件 @
43fde846
...
@@ -13,14 +13,14 @@ import java.sql.Statement;
...
@@ -13,14 +13,14 @@ import java.sql.Statement;
import
org.h2.constant.ErrorCode
;
import
org.h2.constant.ErrorCode
;
import
org.h2.store.fs.FileSystem
;
import
org.h2.store.fs.FileSystem
;
import
org.h2.test.TestBase
;
import
org.h2.test.TestBase
;
import
org.h2.test.utils.
FileSystemDebug
;
import
org.h2.test.utils.
DebugFileSystem
;
/**
/**
* Tests that use the debug file system to simulate power failure.
* Tests that use the debug file system to simulate power failure.
*/
*/
public
class
TestPowerOffFs
extends
TestBase
{
public
class
TestPowerOffFs
extends
TestBase
{
private
FileSystemDebug
fs
;
private
DebugFileSystem
fs
;
/**
/**
* Run just this test.
* Run just this test.
...
@@ -32,8 +32,8 @@ public class TestPowerOffFs extends TestBase {
...
@@ -32,8 +32,8 @@ public class TestPowerOffFs extends TestBase {
}
}
public
void
test
()
throws
Exception
{
public
void
test
()
throws
Exception
{
FileSystemDebug
.
register
();
DebugFileSystem
.
register
();
fs
=
(
FileSystemDebug
)
FileSystem
.
getInstance
(
"debug:/"
);
fs
=
(
DebugFileSystem
)
FileSystem
.
getInstance
(
"debug:/"
);
test
(
Integer
.
MAX_VALUE
);
test
(
Integer
.
MAX_VALUE
);
System
.
out
.
println
(
Integer
.
MAX_VALUE
-
fs
.
getPowerOffCount
());
System
.
out
.
println
(
Integer
.
MAX_VALUE
-
fs
.
getPowerOffCount
());
System
.
out
.
println
(
"done"
);
System
.
out
.
println
(
"done"
);
...
...
h2/src/test/org/h2/test/synth/TestPowerOffFs2.java
浏览文件 @
43fde846
...
@@ -16,7 +16,7 @@ import java.util.Random;
...
@@ -16,7 +16,7 @@ import java.util.Random;
import
org.h2.constant.ErrorCode
;
import
org.h2.constant.ErrorCode
;
import
org.h2.store.fs.FileSystem
;
import
org.h2.store.fs.FileSystem
;
import
org.h2.test.TestBase
;
import
org.h2.test.TestBase
;
import
org.h2.test.utils.
FileSystemDebug
;
import
org.h2.test.utils.
DebugFileSystem
;
import
org.h2.util.New
;
import
org.h2.util.New
;
/**
/**
...
@@ -25,7 +25,7 @@ import org.h2.util.New;
...
@@ -25,7 +25,7 @@ import org.h2.util.New;
*/
*/
public
class
TestPowerOffFs2
extends
TestBase
{
public
class
TestPowerOffFs2
extends
TestBase
{
private
FileSystemDebug
fs
;
private
DebugFileSystem
fs
;
private
String
url
;
private
String
url
;
private
String
user
=
"sa"
;
private
String
user
=
"sa"
;
...
@@ -44,9 +44,9 @@ public class TestPowerOffFs2 extends TestBase {
...
@@ -44,9 +44,9 @@ public class TestPowerOffFs2 extends TestBase {
}
}
public
void
test
()
throws
Exception
{
public
void
test
()
throws
Exception
{
FileSystemDebug
.
register
();
DebugFileSystem
.
register
();
url
=
"jdbc:h2:debug:memFS:powerOffFs;FILE_LOCK=NO;TRACE_LEVEL_FILE=0;WRITE_DELAY=0;CACHE_SIZE=32"
;
url
=
"jdbc:h2:debug:memFS:powerOffFs;FILE_LOCK=NO;TRACE_LEVEL_FILE=0;WRITE_DELAY=0;CACHE_SIZE=32"
;
fs
=
(
FileSystemDebug
)
FileSystem
.
getInstance
(
"debug:/"
);
fs
=
(
DebugFileSystem
)
FileSystem
.
getInstance
(
"debug:/"
);
for
(
int
i
=
0
;;
i
++)
{
for
(
int
i
=
0
;;
i
++)
{
test
(
i
);
test
(
i
);
}
}
...
...
h2/src/test/org/h2/test/synth/TestRandomSQL.java
浏览文件 @
43fde846
...
@@ -14,6 +14,7 @@ import org.h2.store.fs.FileSystemMemory;
...
@@ -14,6 +14,7 @@ import org.h2.store.fs.FileSystemMemory;
import
org.h2.test.TestAll
;
import
org.h2.test.TestAll
;
import
org.h2.test.TestBase
;
import
org.h2.test.TestBase
;
import
org.h2.tools.DeleteDbFiles
;
import
org.h2.tools.DeleteDbFiles
;
import
org.h2.util.IOUtils
;
import
org.h2.util.MathUtils
;
import
org.h2.util.MathUtils
;
/**
/**
...
@@ -57,7 +58,8 @@ public class TestRandomSQL extends TestBase {
...
@@ -57,7 +58,8 @@ public class TestRandomSQL extends TestBase {
if
(
name
.
startsWith
(
FileSystemMemory
.
PREFIX
))
{
if
(
name
.
startsWith
(
FileSystemMemory
.
PREFIX
))
{
DeleteDbFiles
.
execute
(
"memFS:/"
,
name
,
true
);
DeleteDbFiles
.
execute
(
"memFS:/"
,
name
,
true
);
}
else
{
}
else
{
DeleteDbFiles
.
execute
(
baseDir
+
"/dataRandomSQL"
,
null
,
true
);
DeleteDbFiles
.
execute
(
getBaseDir
()
+
"/dataRandomSQL"
,
null
,
true
);
IOUtils
.
delete
(
getBaseDir
()
+
"/dataRandomSQL"
);
}
}
}
}
...
...
h2/src/test/org/h2/test/synth/TestTimer.java
浏览文件 @
43fde846
...
@@ -35,7 +35,7 @@ public class TestTimer extends TestBase {
...
@@ -35,7 +35,7 @@ public class TestTimer extends TestBase {
public
void
test
()
throws
SQLException
{
public
void
test
()
throws
SQLException
{
validateOld
();
validateOld
();
DeleteDbFiles
.
execute
(
baseDir
,
"timer"
,
true
);
DeleteDbFiles
.
execute
(
getBaseDir
()
,
"timer"
,
true
);
loop
();
loop
();
}
}
...
@@ -132,7 +132,7 @@ public class TestTimer extends TestBase {
...
@@ -132,7 +132,7 @@ public class TestTimer extends TestBase {
continue
;
continue
;
}
}
try
{
try
{
Backup
.
execute
(
s
,
baseDir
,
"timer"
,
true
);
Backup
.
execute
(
s
,
getBaseDir
()
,
"timer"
,
true
);
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
logError
(
"backup"
,
e
);
logError
(
"backup"
,
e
);
}
}
...
...
h2/src/test/org/h2/test/synth/sql/TestSynth.java
浏览文件 @
43fde846
...
@@ -46,7 +46,6 @@ public class TestSynth extends TestBase {
...
@@ -46,7 +46,6 @@ public class TestSynth extends TestBase {
* A PostgreSQL database connection.
* A PostgreSQL database connection.
*/
*/
static
final
int
POSTGRESQL
=
4
;
static
final
int
POSTGRESQL
=
4
;
private
static
final
String
DIR
=
"synth"
;
private
DbState
dbState
=
new
DbState
(
this
);
private
DbState
dbState
=
new
DbState
(
this
);
private
ArrayList
<
DbInterface
>
databases
;
private
ArrayList
<
DbInterface
>
databases
;
...
@@ -274,9 +273,7 @@ public class TestSynth extends TestBase {
...
@@ -274,9 +273,7 @@ public class TestSynth extends TestBase {
public
TestBase
init
(
TestAll
conf
)
throws
Exception
{
public
TestBase
init
(
TestAll
conf
)
throws
Exception
{
super
.
init
(
conf
);
super
.
init
(
conf
);
String
old
=
baseDir
;
deleteDb
(
"synth/synth"
);
baseDir
=
TestBase
.
getTestDir
(
"synth"
);
deleteDb
(
"synth"
);
databases
=
New
.
arrayList
();
databases
=
New
.
arrayList
();
// mode = HSQLDB;
// mode = HSQLDB;
...
@@ -292,7 +289,7 @@ public class TestSynth extends TestBase {
...
@@ -292,7 +289,7 @@ public class TestSynth extends TestBase {
mode
=
H2_MEM
;
mode
=
H2_MEM
;
org
.
h2
.
Driver
.
load
();
org
.
h2
.
Driver
.
load
();
addDatabase
(
"org.h2.Driver"
,
"jdbc:h2:mem:synth"
,
"sa"
,
""
,
true
);
addDatabase
(
"org.h2.Driver"
,
"jdbc:h2:mem:synth"
,
"sa"
,
""
,
true
);
addDatabase
(
"org.h2.Driver"
,
"jdbc:h2:"
+
baseDir
+
"/"
+
DIR
+
"
/synth"
,
"sa"
,
""
,
false
);
addDatabase
(
"org.h2.Driver"
,
"jdbc:h2:"
+
getBaseDir
()
+
"/synth
/synth"
,
"sa"
,
""
,
false
);
// addDatabase("com.mysql.jdbc.Driver", "jdbc:mysql://localhost/test",
// addDatabase("com.mysql.jdbc.Driver", "jdbc:mysql://localhost/test",
// "sa", "");
// "sa", "");
...
@@ -319,14 +316,11 @@ public class TestSynth extends TestBase {
...
@@ -319,14 +316,11 @@ public class TestSynth extends TestBase {
// original (0):
// original (0):
// System.exit(0);
// System.exit(0);
baseDir
=
old
;
return
this
;
return
this
;
}
}
public
void
testCase
(
int
seed
)
throws
Exception
{
public
void
testCase
(
int
seed
)
throws
Exception
{
String
old
=
baseDir
;
deleteDb
(
"synth/synth"
);
baseDir
=
TestBase
.
getTestDir
(
"synth"
);
deleteDb
(
baseDir
,
DIR
+
"/synth"
);
try
{
try
{
printTime
(
"TestSynth "
+
seed
);
printTime
(
"TestSynth "
+
seed
);
testRun
(
seed
);
testRun
(
seed
);
...
@@ -334,7 +328,6 @@ public class TestSynth extends TestBase {
...
@@ -334,7 +328,6 @@ public class TestSynth extends TestBase {
TestBase
.
logError
(
"error"
,
e
);
TestBase
.
logError
(
"error"
,
e
);
System
.
exit
(
0
);
System
.
exit
(
0
);
}
}
baseDir
=
old
;
}
}
public
void
test
()
throws
Exception
{
public
void
test
()
throws
Exception
{
...
...
h2/src/test/org/h2/test/synth/thread/TestMulti.java
浏览文件 @
43fde846
...
@@ -54,7 +54,7 @@ public class TestMulti extends TestBase {
...
@@ -54,7 +54,7 @@ public class TestMulti extends TestBase {
}
}
Connection
getConnection
()
throws
SQLException
{
Connection
getConnection
()
throws
SQLException
{
final
String
url
=
"jdbc:h2:"
+
baseDir
+
"/openClose;LOCK_MODE=3;DB_CLOSE_DELAY=-1"
;
final
String
url
=
"jdbc:h2:"
+
getBaseDir
()
+
"/openClose;LOCK_MODE=3;DB_CLOSE_DELAY=-1"
;
Connection
conn
=
DriverManager
.
getConnection
(
url
,
"sa"
,
""
);
Connection
conn
=
DriverManager
.
getConnection
(
url
,
"sa"
,
""
);
return
conn
;
return
conn
;
}
}
...
...
h2/src/test/org/h2/test/trace/Player.java
浏览文件 @
43fde846
...
@@ -22,10 +22,11 @@
...
@@ -22,10 +22,11 @@
package
org
.
h2
.
test
.
trace
;
package
org
.
h2
.
test
.
trace
;
import
java.io.BufferedReader
;
import
java.io.BufferedReader
;
import
java.io.FileReader
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
import
java.io.LineNumberReader
;
import
java.io.LineNumberReader
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
org.h2.util.IOUtils
;
import
org.h2.util.New
;
import
org.h2.util.New
;
/**
/**
...
@@ -101,7 +102,7 @@ public class Player {
...
@@ -101,7 +102,7 @@ public class Player {
private
void
runFile
(
String
fileName
)
throws
IOException
{
private
void
runFile
(
String
fileName
)
throws
IOException
{
LineNumberReader
reader
=
new
LineNumberReader
(
new
BufferedReader
(
LineNumberReader
reader
=
new
LineNumberReader
(
new
BufferedReader
(
new
FileReader
(
fileName
)));
new
InputStreamReader
(
IOUtils
.
openFileInputStream
(
fileName
)
)));
while
(
true
)
{
while
(
true
)
{
String
line
=
reader
.
readLine
();
String
line
=
reader
.
readLine
();
if
(
line
==
null
)
{
if
(
line
==
null
)
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论