Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
edcd07a7
Unverified
提交
edcd07a7
authored
7 年前
作者:
Evgenij Ryazanov
提交者:
GitHub
7 年前
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1130 from katzyn/tests
Improve TestScript and TestCrashAPI
上级
5ea9741e
ba0d540b
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
41 行增加
和
13 行删除
+41
-13
TestTableEngines.java
h2/src/test/org/h2/test/db/TestTableEngines.java
+10
-0
TestScript.java
h2/src/test/org/h2/test/scripts/TestScript.java
+17
-8
dateadd.sql
...est/org/h2/test/scripts/functions/timeanddate/dateadd.sql
+0
-1
TestCrashAPI.java
h2/src/test/org/h2/test/synth/TestCrashAPI.java
+14
-4
没有找到文件。
h2/src/test/org/h2/test/db/TestTableEngines.java
浏览文件 @
edcd07a7
...
...
@@ -132,6 +132,8 @@ public class TestTableEngines extends TestBase {
EndlessTableEngine
.
createTableData
.
tableEngineParams
.
get
(
1
));
conn
.
close
();
}
// Prevent memory leak
EndlessTableEngine
.
createTableData
=
null
;
deleteDb
(
"tableEngine"
);
}
...
...
@@ -150,6 +152,8 @@ public class TestTableEngines extends TestBase {
assertEquals
(
"param2"
,
EndlessTableEngine
.
createTableData
.
tableEngineParams
.
get
(
1
));
conn
.
close
();
// Prevent memory leak
EndlessTableEngine
.
createTableData
=
null
;
deleteDb
(
"tableEngine"
);
}
...
...
@@ -513,6 +517,8 @@ public class TestTableEngines extends TestBase {
stat
.
executeUpdate
(
"CREATE TABLE T(ID INT AFFINITY PRIMARY KEY, NAME VARCHAR, AGE INT)"
+
" ENGINE \""
+
AffinityTableEngine
.
class
.
getName
()
+
"\""
);
Table
tbl
=
AffinityTableEngine
.
createdTbl
;
// Prevent memory leak
AffinityTableEngine
.
createdTbl
=
null
;
assertNotNull
(
tbl
);
assertEquals
(
3
,
tbl
.
getIndexes
().
size
());
Index
aff
=
tbl
.
getIndexes
().
get
(
2
);
...
...
@@ -552,6 +558,8 @@ public class TestTableEngines extends TestBase {
}
stat
.
execute
(
"CREATE TABLE u (a int, b int) ENGINE "
+
engine
);
TreeSetTable
u
=
TreeSetIndexTableEngine
.
created
;
// Prevent memory leak
TreeSetIndexTableEngine
.
created
=
null
;
stat
.
execute
(
"CREATE INDEX U_IDX_A ON u(a)"
);
stat
.
execute
(
"CREATE INDEX U_IDX_B ON u(b)"
);
setBatchSize
(
u
,
0
);
...
...
@@ -704,6 +712,8 @@ public class TestTableEngines extends TestBase {
assertEquals
(
10
,
table
.
getRowCount
(
null
));
}
}
// Prevent memory leak
TreeSetIndexTableEngine
.
created
=
null
;
int
[]
zeroBatchSizes
=
new
int
[
batchSizes
.
length
];
int
tests
=
1
<<
(
batchSizes
.
length
*
4
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/scripts/TestScript.java
浏览文件 @
edcd07a7
...
...
@@ -40,7 +40,8 @@ public class TestScript extends TestBase {
/** If set to true, the test will exit at the first failure. */
private
boolean
failFast
;
private
final
ArrayList
<
String
>
statements
=
new
ArrayList
<>();
/** If set to a value the test will add all executed statements to this list */
private
ArrayList
<
String
>
statements
;
private
boolean
reconnectOften
;
private
Connection
conn
;
...
...
@@ -71,10 +72,14 @@ public class TestScript extends TestBase {
*/
public
ArrayList
<
String
>
getAllStatements
(
TestAll
conf
)
throws
Exception
{
config
=
conf
;
if
(
statements
.
isEmpty
())
{
ArrayList
<
String
>
result
=
new
ArrayList
<>(
4000
);
try
{
statements
=
result
;
test
();
}
finally
{
this
.
statements
=
null
;
}
return
statements
;
return
result
;
}
@Override
...
...
@@ -181,7 +186,9 @@ public class TestScript extends TestBase {
putBack
=
null
;
errors
=
null
;
if
(
statements
==
null
)
{
println
(
"Running commands in "
+
scriptFileName
);
}
final
String
outFile
=
"test.out.txt"
;
conn
=
getConnection
(
"script"
);
stat
=
conn
.
createStatement
();
...
...
@@ -260,7 +267,7 @@ public class TestScript extends TestBase {
if
(
sql
.
startsWith
(
"--"
))
{
write
(
sql
);
}
else
if
(
sql
.
startsWith
(
">"
))
{
// do nothing
addWriteResultError
(
"<command>"
,
sql
);
}
else
if
(
sql
.
endsWith
(
";"
))
{
write
(
sql
);
buff
.
append
(
sql
,
0
,
sql
.
length
()
-
1
);
...
...
@@ -302,7 +309,9 @@ public class TestScript extends TestBase {
}
}
}
if
(
statements
!=
null
)
{
statements
.
add
(
sql
);
}
if
(
sql
.
indexOf
(
'?'
)
==
-
1
)
{
processStatement
(
sql
);
}
else
{
...
...
@@ -526,7 +535,6 @@ public class TestScript extends TestBase {
if
(
ex
!=
null
)
{
TestBase
.
logError
(
"script"
,
ex
);
}
TestBase
.
logErrorMessage
(
errors
.
toString
());
if
(
failFast
)
{
conn
.
close
();
System
.
exit
(
1
);
...
...
@@ -534,17 +542,18 @@ public class TestScript extends TestBase {
}
}
else
{
addWriteResultError
(
"<nothing>"
,
s
);
TestBase
.
logErrorMessage
(
errors
.
toString
());
putBack
=
compare
;
}
write
(
s
);
}
private
void
addWriteResultError
(
String
expected
,
String
got
)
{
int
idx
=
errors
.
length
();
errors
.
append
(
fileName
).
append
(
'\n'
);
errors
.
append
(
"line: "
).
append
(
in
.
getLineNumber
()).
append
(
'\n'
);
errors
.
append
(
"exp: "
).
append
(
expected
).
append
(
'\n'
);
errors
.
append
(
"got: "
).
append
(
got
).
append
(
'\n'
);
TestBase
.
logErrorMessage
(
errors
.
substring
(
idx
));
}
private
void
write
(
String
s
)
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/scripts/functions/timeanddate/dateadd.sql
浏览文件 @
edcd07a7
...
...
@@ -107,4 +107,3 @@ SELECT TIMESTAMPADD('TIMEZONE_MINUTE', -45, TIMESTAMP WITH TIME ZONE '2010-01-01
SELECT
DATEADD
(
HOUR
,
1
,
TIME
'23:00:00'
);
>>
00
:
00
:
00
>
rows
:
1
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/synth/TestCrashAPI.java
浏览文件 @
edcd07a7
...
...
@@ -11,6 +11,7 @@ import java.io.StringWriter;
import
java.lang.reflect.Array
;
import
java.lang.reflect.InvocationTargetException
;
import
java.lang.reflect.Method
;
import
java.lang.reflect.Modifier
;
import
java.sql.BatchUpdateException
;
import
java.sql.Blob
;
import
java.sql.CallableStatement
;
...
...
@@ -65,7 +66,7 @@ public class TestCrashAPI extends TestBase implements Runnable {
private
final
HashMap
<
Class
<?>,
ArrayList
<
Method
>>
classMethods
=
new
HashMap
<>();
private
RandomGen
random
=
new
RandomGen
();
private
final
ArrayList
<
String
>
statements
=
new
ArrayList
<>()
;
private
ArrayList
<
String
>
statements
;
private
int
openCount
;
private
long
callCount
;
private
volatile
long
maxWait
=
60
;
...
...
@@ -370,6 +371,10 @@ public class TestCrashAPI extends TestBase implements Runnable {
}
private
Object
callRandom
(
int
seed
,
int
id
,
int
objectId
,
Object
o
,
Method
m
)
{
// TODO m.isDefault() can be used on Java 8
boolean
isDefault
=
(
m
.
getModifiers
()
&
(
Modifier
.
ABSTRACT
|
Modifier
.
PUBLIC
|
Modifier
.
STATIC
))
==
Modifier
.
PUBLIC
&&
m
.
getDeclaringClass
().
isInterface
();
Class
<?>[]
paramClasses
=
m
.
getParameterTypes
();
Object
[]
params
=
new
Object
[
paramClasses
.
length
];
for
(
int
i
=
0
;
i
<
params
.
length
;
i
++)
{
...
...
@@ -385,7 +390,7 @@ public class TestCrashAPI extends TestBase implements Runnable {
TestBase
.
logError
(
"error"
,
e
);
}
catch
(
InvocationTargetException
e
)
{
Throwable
t
=
e
.
getTargetException
();
printIfBad
(
seed
,
id
,
objectId
,
t
);
printIfBad
(
seed
,
id
,
objectId
,
t
,
isDefault
);
}
if
(
result
==
null
)
{
return
null
;
...
...
@@ -398,6 +403,10 @@ public class TestCrashAPI extends TestBase implements Runnable {
}
private
void
printIfBad
(
int
seed
,
int
id
,
int
objectId
,
Throwable
t
)
{
printIfBad
(
seed
,
id
,
objectId
,
t
,
false
);
}
private
void
printIfBad
(
int
seed
,
int
id
,
int
objectId
,
Throwable
t
,
boolean
isDefault
)
{
if
(
t
instanceof
BatchUpdateException
)
{
// do nothing
}
else
if
(
t
.
getClass
().
getName
().
contains
(
"SQLClientInfoException"
))
{
...
...
@@ -421,6 +430,8 @@ public class TestCrashAPI extends TestBase implements Runnable {
// General error [HY000]
printError
(
seed
,
id
,
s
);
}
}
else
if
(
isDefault
&&
t
instanceof
NullPointerException
)
{
// do nothing, default methods may throw this exception
}
else
{
printError
(
seed
,
id
,
t
);
}
...
...
@@ -525,10 +536,9 @@ public class TestCrashAPI extends TestBase implements Runnable {
}
startServerIfRequired
();
TestScript
script
=
new
TestScript
();
ArrayList
<
String
>
add
=
script
.
getAllStatements
(
config
);
statements
=
script
.
getAllStatements
(
config
);
initMethods
();
org
.
h2
.
Driver
.
load
();
statements
.
addAll
(
add
);
return
this
;
}
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论