Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
87792db5
提交
87792db5
authored
11月 13, 2016
作者:
Noel Grandin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
improve unit test cleanup
上级
7f3e1936
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
107 行增加
和
103 行删除
+107
-103
TestFullText.java
h2/src/test/org/h2/test/db/TestFullText.java
+64
-61
TestRights.java
h2/src/test/org/h2/test/db/TestRights.java
+35
-35
TestMVTableEngine.java
h2/src/test/org/h2/test/store/TestMVTableEngine.java
+8
-7
没有找到文件。
h2/src/test/org/h2/test/db/TestFullText.java
浏览文件 @
87792db5
...
...
@@ -245,71 +245,74 @@ public class TestFullText extends TestBase {
trace
(
"Testing multithreaded "
+
prefix
);
deleteDb
(
"fullText"
);
ArrayList
<
Connection
>
connList
=
new
ArrayList
<
Connection
>();
int
len
=
2
;
Task
[]
task
=
new
Task
[
len
];
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
// final Connection conn =
// getConnection("fullText;MULTI_THREADED=1;LOCK_TIMEOUT=10000");
final
Connection
conn
=
getConnection
(
"fullText"
,
connList
);
Statement
stat
=
conn
.
createStatement
();
initFullText
(
stat
,
lucene
);
initFullText
(
stat
,
lucene
);
final
String
tableName
=
"TEST"
+
i
;
stat
.
execute
(
"CREATE TABLE "
+
tableName
+
"(ID INT PRIMARY KEY, DATA VARCHAR)"
);
stat
.
execute
(
"CALL "
+
prefix
+
"_CREATE_INDEX('PUBLIC', '"
+
tableName
+
"', NULL)"
);
task
[
i
]
=
new
Task
()
{
@Override
public
void
call
()
throws
SQLException
{
trace
(
"starting thread "
+
Thread
.
currentThread
());
PreparedStatement
prep
=
conn
.
prepareStatement
(
"INSERT INTO "
+
tableName
+
" VALUES(?, ?)"
);
Statement
stat
=
conn
.
createStatement
();
Random
random
=
new
Random
();
int
x
=
0
;
while
(!
stop
)
{
trace
(
"stop = "
+
stop
+
" for "
+
Thread
.
currentThread
());
StringBuilder
buff
=
new
StringBuilder
();
for
(
int
j
=
0
;
j
<
1000
;
j
++)
{
buff
.
append
(
" "
).
append
(
random
.
nextInt
(
10000
));
buff
.
append
(
" x"
).
append
(
j
);
buff
.
append
(
" "
).
append
(
KNOWN_WORDS
[
j
%
KNOWN_WORDS
.
length
]);
try
{
int
len
=
2
;
Task
[]
task
=
new
Task
[
len
];
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
// final Connection conn =
// getConnection("fullText;MULTI_THREADED=1;LOCK_TIMEOUT=10000");
final
Connection
conn
=
getConnection
(
"fullText"
,
connList
);
Statement
stat
=
conn
.
createStatement
();
initFullText
(
stat
,
lucene
);
initFullText
(
stat
,
lucene
);
final
String
tableName
=
"TEST"
+
i
;
stat
.
execute
(
"CREATE TABLE "
+
tableName
+
"(ID INT PRIMARY KEY, DATA VARCHAR)"
);
stat
.
execute
(
"CALL "
+
prefix
+
"_CREATE_INDEX('PUBLIC', '"
+
tableName
+
"', NULL)"
);
task
[
i
]
=
new
Task
()
{
@Override
public
void
call
()
throws
SQLException
{
trace
(
"starting thread "
+
Thread
.
currentThread
());
PreparedStatement
prep
=
conn
.
prepareStatement
(
"INSERT INTO "
+
tableName
+
" VALUES(?, ?)"
);
Statement
stat
=
conn
.
createStatement
();
Random
random
=
new
Random
();
int
x
=
0
;
while
(!
stop
)
{
trace
(
"stop = "
+
stop
+
" for "
+
Thread
.
currentThread
());
StringBuilder
buff
=
new
StringBuilder
();
for
(
int
j
=
0
;
j
<
1000
;
j
++)
{
buff
.
append
(
" "
).
append
(
random
.
nextInt
(
10000
));
buff
.
append
(
" x"
).
append
(
j
);
buff
.
append
(
" "
).
append
(
KNOWN_WORDS
[
j
%
KNOWN_WORDS
.
length
]);
}
prep
.
setInt
(
1
,
x
);
prep
.
setString
(
2
,
buff
.
toString
());
prep
.
execute
();
x
++;
for
(
String
knownWord
:
KNOWN_WORDS
)
{
trace
(
"searching for "
+
knownWord
+
" with "
+
Thread
.
currentThread
());
ResultSet
rs
=
stat
.
executeQuery
(
"SELECT * FROM "
+
prefix
+
"_SEARCH('"
+
knownWord
+
"', 0, 0)"
);
assertTrue
(
rs
.
next
());
}
}
prep
.
setInt
(
1
,
x
);
prep
.
setString
(
2
,
buff
.
toString
());
prep
.
execute
();
x
++;
for
(
String
knownWord
:
KNOWN_WORDS
)
{
trace
(
"searching for "
+
knownWord
+
" with "
+
Thread
.
currentThread
());
ResultSet
rs
=
stat
.
executeQuery
(
"SELECT * FROM "
+
prefix
+
"_SEARCH('"
+
knownWord
+
"', 0, 0)"
);
assertTrue
(
rs
.
next
());
trace
(
"closing connection"
);
if
(!
config
.
memory
)
{
conn
.
close
();
}
trace
(
"completed thread "
+
Thread
.
currentThread
());
}
trace
(
"closing connection"
);
if
(!
config
.
memory
)
{
conn
.
close
();
}
trace
(
"completed thread "
+
Thread
.
currentThread
());
}
};
}
for
(
Task
t
:
task
)
{
t
.
execute
();
}
trace
(
"sleeping"
);
Thread
.
sleep
(
1000
);
trace
(
"setting stop to true"
);
for
(
Task
t
:
task
)
{
trace
(
"joining "
+
t
);
t
.
get
();
trace
(
"done joining "
+
t
);
};
}
for
(
Task
t
:
task
)
{
t
.
execute
();
}
trace
(
"sleeping"
);
Thread
.
sleep
(
1000
);
trace
(
"setting stop to true"
);
for
(
Task
t
:
task
)
{
trace
(
"joining "
+
t
);
t
.
get
();
trace
(
"done joining "
+
t
);
}
}
finally
{
close
(
connList
);
}
close
(
connList
);
}
private
void
testStreamLob
()
throws
SQLException
{
...
...
h2/src/test/org/h2/test/db/TestRights.java
浏览文件 @
87792db5
...
...
@@ -64,43 +64,43 @@ public class TestRights extends TestBase {
private
void
testLinkedTableMeta
()
throws
SQLException
{
deleteDb
(
"rights"
);
Connection
conn
=
getConnection
(
"rights"
);
stat
=
conn
.
createStatement
();
stat
.
execute
(
"create user test password 'test'"
);
stat
.
execute
(
"create linked table test"
+
"(null, 'jdbc:h2:mem:', 'sa', 'sa', 'DUAL')"
);
// password is invisible to non-admin
Connection
conn2
=
getConnection
(
"rights"
,
"test"
,
getPassword
(
"test"
));
Statement
stat2
=
conn2
.
createStatement
();
ResultSet
rs
=
stat2
.
executeQuery
(
"select * from information_schema.tables "
+
"where table_name = 'TEST'"
);
assertTrue
(
rs
.
next
());
ResultSetMetaData
meta
=
rs
.
getMetaData
();
for
(
int
i
=
1
;
i
<=
meta
.
getColumnCount
();
i
++)
{
String
s
=
rs
.
getString
(
i
);
assertFalse
(
s
!=
null
&&
s
.
contains
(
"'sa'"
));
}
conn2
.
close
();
// password is visible to admin
rs
=
stat
.
executeQuery
(
"select * from information_schema.tables "
+
"where table_name = 'TEST'"
);
assertTrue
(
rs
.
next
());
meta
=
rs
.
getMetaData
();
boolean
foundPassword
=
false
;
for
(
int
i
=
1
;
i
<=
meta
.
getColumnCount
();
i
++)
{
String
s
=
rs
.
getString
(
i
);
if
(
s
!=
null
&&
s
.
contains
(
"'sa'"
))
{
foundPassword
=
true
;
try
(
Connection
conn
=
getConnection
(
"rights"
))
{
stat
=
conn
.
createStatement
();
stat
.
execute
(
"create user test password 'test'"
);
stat
.
execute
(
"create linked table test"
+
"(null, 'jdbc:h2:mem:', 'sa', 'sa', 'DUAL')"
);
// password is invisible to non-admin
Connection
conn2
=
getConnection
(
"rights"
,
"test"
,
getPassword
(
"test"
));
Statement
stat2
=
conn2
.
createStatement
();
ResultSet
rs
=
stat2
.
executeQuery
(
"select * from information_schema.tables "
+
"where table_name = 'TEST'"
);
assertTrue
(
rs
.
next
());
ResultSetMetaData
meta
=
rs
.
getMetaData
();
for
(
int
i
=
1
;
i
<=
meta
.
getColumnCount
();
i
++)
{
String
s
=
rs
.
getString
(
i
);
assertFalse
(
s
!=
null
&&
s
.
contains
(
"'sa'"
));
}
conn2
.
close
();
// password is visible to admin
rs
=
stat
.
executeQuery
(
"select * from information_schema.tables "
+
"where table_name = 'TEST'"
);
assertTrue
(
rs
.
next
());
meta
=
rs
.
getMetaData
();
boolean
foundPassword
=
false
;
for
(
int
i
=
1
;
i
<=
meta
.
getColumnCount
();
i
++)
{
String
s
=
rs
.
getString
(
i
);
if
(
s
!=
null
&&
s
.
contains
(
"'sa'"
))
{
foundPassword
=
true
;
}
}
assertTrue
(
foundPassword
);
conn2
.
close
();
stat
.
execute
(
"drop table test"
);
}
assertTrue
(
foundPassword
);
conn2
.
close
();
stat
.
execute
(
"drop table test"
);
conn
.
close
();
}
private
void
testGrantMore
()
throws
SQLException
{
...
...
h2/src/test/org/h2/test/store/TestMVTableEngine.java
浏览文件 @
87792db5
...
...
@@ -111,17 +111,16 @@ public class TestMVTableEngine extends TestBase {
private
void
testLobReuse
()
throws
Exception
{
deleteDb
(
getTestName
());
Connection
conn
=
getConnection
(
getTestName
());
Statement
stat
=
conn
.
createStatement
();
Connection
conn
1
=
getConnection
(
getTestName
());
Statement
stat
=
conn
1
.
createStatement
();
stat
.
execute
(
"create table test(id identity primary key, lob clob)"
);
conn
.
close
();
byte
[]
buffer
=
new
byte
[
8192
];
for
(
int
i
=
0
;
i
<
20
;
i
++)
{
conn
=
getConnection
(
getTestName
());
stat
=
conn
.
createStatement
();
Connection
conn2
=
getConnection
(
getTestName
());
stat
=
conn
2
.
createStatement
();
stat
.
execute
(
"insert into test(lob) select space(1025) from system_range(1, 10)"
);
stat
.
execute
(
"delete from test where random() > 0.5"
);
ResultSet
rs
=
conn
.
createStatement
().
executeQuery
(
ResultSet
rs
=
conn
2
.
createStatement
().
executeQuery
(
"select lob from test"
);
while
(
rs
.
next
())
{
InputStream
is
=
rs
.
getBinaryStream
(
1
);
...
...
@@ -129,8 +128,9 @@ public class TestMVTableEngine extends TestBase {
// ignore
}
}
conn
.
close
();
conn
2
.
close
();
}
conn1
.
close
();
}
private
void
testShutdownDuringLobCreation
()
throws
Exception
{
...
...
@@ -175,6 +175,7 @@ public class TestMVTableEngine extends TestBase {
stat
.
execute
(
"shutdown immediately"
);
Exception
ex
=
t
.
getException
();
assertTrue
(
ex
!=
null
);
ex
.
printStackTrace
();
try
{
conn
.
close
();
}
catch
(
Exception
e
)
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论