Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
d28d8c3a
提交
d28d8c3a
authored
7 年前
作者:
andrei
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Issue#556 close connections in tests (at least in case of successful execution)
上级
1a04f20c
全部展开
显示空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
446 行增加
和
441 行删除
+446
-441
TestFullText.java
h2/src/test/org/h2/test/db/TestFullText.java
+4
-6
TestFunctions.java
h2/src/test/org/h2/test/db/TestFunctions.java
+18
-15
TestMultiThread.java
h2/src/test/org/h2/test/db/TestMultiThread.java
+244
-251
TestQueryCache.java
h2/src/test/org/h2/test/db/TestQueryCache.java
+62
-62
TestShow.java
h2/src/test/org/h2/test/db/TestShow.java
+24
-22
TestSpatial.java
h2/src/test/org/h2/test/db/TestSpatial.java
+88
-85
TestConnection.java
h2/src/test/org/h2/test/jdbc/TestConnection.java
+6
-0
没有找到文件。
h2/src/test/org/h2/test/db/TestFullText.java
浏览文件 @
d28d8c3a
...
@@ -92,7 +92,7 @@ public class TestFullText extends TestBase {
...
@@ -92,7 +92,7 @@ public class TestFullText extends TestBase {
private
static
void
close
(
Collection
<
Connection
>
list
)
throws
SQLException
{
private
static
void
close
(
Collection
<
Connection
>
list
)
throws
SQLException
{
for
(
Connection
conn
:
list
)
{
for
(
Connection
conn
:
list
)
{
conn
.
close
();
try
{
conn
.
close
();
}
catch
(
SQLException
ignore
)
{
/**/
}
}
}
}
}
...
@@ -491,8 +491,7 @@ public class TestFullText extends TestBase {
...
@@ -491,8 +491,7 @@ public class TestFullText extends TestBase {
return
;
return
;
}
}
deleteDb
(
"fullText"
);
deleteDb
(
"fullText"
);
ArrayList
<
Connection
>
connList
=
new
ArrayList
<
Connection
>();
Connection
conn
=
getConnection
(
"fullText"
);
Connection
conn
=
getConnection
(
"fullText"
,
connList
);
String
prefix
=
lucene
?
"FTL_"
:
"FT_"
;
String
prefix
=
lucene
?
"FTL_"
:
"FT_"
;
Statement
stat
=
conn
.
createStatement
();
Statement
stat
=
conn
.
createStatement
();
String
className
=
lucene
?
"FullTextLucene"
:
"FullText"
;
String
className
=
lucene
?
"FullTextLucene"
:
"FullText"
;
...
@@ -590,15 +589,15 @@ public class TestFullText extends TestBase {
...
@@ -590,15 +589,15 @@ public class TestFullText extends TestBase {
if
(!
config
.
memory
)
{
if
(!
config
.
memory
)
{
conn
.
close
();
conn
.
close
();
conn
=
getConnection
(
"fullText"
);
}
}
conn
=
getConnection
(
"fullText"
,
connList
);
stat
=
conn
.
createStatement
();
stat
=
conn
.
createStatement
();
stat
.
executeQuery
(
"SELECT * FROM "
+
prefix
+
"SEARCH('World', 0, 0)"
);
stat
.
executeQuery
(
"SELECT * FROM "
+
prefix
+
"SEARCH('World', 0, 0)"
);
stat
.
execute
(
"CALL "
+
prefix
+
"DROP_ALL()"
);
stat
.
execute
(
"CALL "
+
prefix
+
"DROP_ALL()"
);
c
lose
(
connList
);
c
onn
.
close
(
);
}
}
private
void
testDropIndex
(
boolean
lucene
)
throws
SQLException
{
private
void
testDropIndex
(
boolean
lucene
)
throws
SQLException
{
...
@@ -625,7 +624,6 @@ public class TestFullText extends TestBase {
...
@@ -625,7 +624,6 @@ public class TestFullText extends TestBase {
"_CREATE_INDEX('PUBLIC', 'TEST', 'NAME1, NAME2')"
);
"_CREATE_INDEX('PUBLIC', 'TEST', 'NAME1, NAME2')"
);
stat
.
execute
(
"UPDATE TEST SET NAME2=NULL WHERE ID=1"
);
stat
.
execute
(
"UPDATE TEST SET NAME2=NULL WHERE ID=1"
);
stat
.
execute
(
"UPDATE TEST SET NAME2='Hello World' WHERE ID=1"
);
stat
.
execute
(
"UPDATE TEST SET NAME2='Hello World' WHERE ID=1"
);
conn
.
close
();
conn
.
close
();
conn
.
close
();
FileUtils
.
deleteRecursive
(
getBaseDir
()
+
"/fullTextDropIndex"
,
false
);
FileUtils
.
deleteRecursive
(
getBaseDir
()
+
"/fullTextDropIndex"
,
false
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/db/TestFunctions.java
浏览文件 @
d28d8c3a
...
@@ -1285,6 +1285,7 @@ public class TestFunctions extends TestBase implements AggregateFunction {
...
@@ -1285,6 +1285,7 @@ public class TestFunctions extends TestBase implements AggregateFunction {
String
.
format
(
"SELECT ORA_HASH('%s', 0) FROM DUAL"
,
testStr
));
String
.
format
(
"SELECT ORA_HASH('%s', 0) FROM DUAL"
,
testStr
));
assertResult
(
String
.
valueOf
(
"foo"
.
hashCode
()),
stat
,
assertResult
(
String
.
valueOf
(
"foo"
.
hashCode
()),
stat
,
String
.
format
(
"SELECT ORA_HASH('%s', 0, 0) FROM DUAL"
,
testStr
));
String
.
format
(
"SELECT ORA_HASH('%s', 0, 0) FROM DUAL"
,
testStr
));
conn
.
close
();
}
}
private
void
testToDateException
()
{
private
void
testToDateException
()
{
...
@@ -2058,6 +2059,7 @@ public class TestFunctions extends TestBase implements AggregateFunction {
...
@@ -2058,6 +2059,7 @@ public class TestFunctions extends TestBase implements AggregateFunction {
assertFalse
(
parsed
.
before
(
before
));
assertFalse
(
parsed
.
before
(
before
));
assertFalse
(
parsed
.
after
(
after
));
assertFalse
(
parsed
.
after
(
after
));
conn
.
close
();
}
}
...
@@ -2083,6 +2085,7 @@ public class TestFunctions extends TestBase implements AggregateFunction {
...
@@ -2083,6 +2085,7 @@ public class TestFunctions extends TestBase implements AggregateFunction {
rs
.
close
();
rs
.
close
();
assertEquals
(
first
,
second
);
assertEquals
(
first
,
second
);
conn
.
close
();
}
}
private
void
testThatCurrentTimestampUpdatesOutsideATransaction
()
private
void
testThatCurrentTimestampUpdatesOutsideATransaction
()
...
@@ -2107,11 +2110,12 @@ public class TestFunctions extends TestBase implements AggregateFunction {
...
@@ -2107,11 +2110,12 @@ public class TestFunctions extends TestBase implements AggregateFunction {
rs
.
close
();
rs
.
close
();
assertTrue
(
second
.
after
(
first
));
assertTrue
(
second
.
after
(
first
));
conn
.
close
();
}
}
private
void
callCompiledFunction
(
String
functionName
)
throws
SQLException
{
private
void
callCompiledFunction
(
String
functionName
)
throws
SQLException
{
deleteDb
(
"functions"
);
deleteDb
(
"functions"
);
Connection
conn
=
getConnection
(
"functions"
);
try
(
Connection
conn
=
getConnection
(
"functions"
))
{
Statement
stat
=
conn
.
createStatement
();
Statement
stat
=
conn
.
createStatement
();
ResultSet
rs
;
ResultSet
rs
;
stat
.
execute
(
"create alias "
+
functionName
+
" AS "
stat
.
execute
(
"create alias "
+
functionName
+
" AS "
...
@@ -2125,8 +2129,7 @@ public class TestFunctions extends TestBase implements AggregateFunction {
...
@@ -2125,8 +2129,7 @@ public class TestFunctions extends TestBase implements AggregateFunction {
assertEquals
(
Boolean
.
class
.
getName
(),
rs
.
getObject
(
1
).
getClass
().
getName
());
assertEquals
(
Boolean
.
class
.
getName
(),
rs
.
getObject
(
1
).
getClass
().
getName
());
stat
.
execute
(
"drop alias "
+
functionName
+
""
);
stat
.
execute
(
"drop alias "
+
functionName
+
""
);
}
conn
.
close
();
}
}
private
void
assertCallResult
(
String
expected
,
Statement
stat
,
String
sql
)
private
void
assertCallResult
(
String
expected
,
Statement
stat
,
String
sql
)
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/db/TestMultiThread.java
浏览文件 @
d28d8c3a
差异被折叠。
点击展开。
h2/src/test/org/h2/test/db/TestQueryCache.java
浏览文件 @
d28d8c3a
...
@@ -36,7 +36,7 @@ public class TestQueryCache extends TestBase {
...
@@ -36,7 +36,7 @@ public class TestQueryCache extends TestBase {
}
}
private
void
test1
()
throws
Exception
{
private
void
test1
()
throws
Exception
{
Connection
conn
=
getConnection
(
"queryCache;QUERY_CACHE_SIZE=10"
);
try
(
Connection
conn
=
getConnection
(
"queryCache;QUERY_CACHE_SIZE=10"
))
{
Statement
stat
=
conn
.
createStatement
();
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"create table test(id int, name varchar)"
);
stat
.
execute
(
"create table test(id int, name varchar)"
);
PreparedStatement
prep
;
PreparedStatement
prep
;
...
@@ -91,11 +91,11 @@ public class TestQueryCache extends TestBase {
...
@@ -91,11 +91,11 @@ public class TestQueryCache extends TestBase {
// usually this is true
// usually this is true
assertSmaller
(
firstSmaller
,
firstGreater
);
assertSmaller
(
firstSmaller
,
firstGreater
);
stat
.
execute
(
"drop table test"
);
stat
.
execute
(
"drop table test"
);
conn
.
close
();
}
}
}
private
void
testClearingCacheWithTableStructureChanges
()
throws
Exception
{
private
void
testClearingCacheWithTableStructureChanges
()
throws
Exception
{
Connection
conn
=
getConnection
(
"queryCache;QUERY_CACHE_SIZE=10"
);
try
(
Connection
conn
=
getConnection
(
"queryCache;QUERY_CACHE_SIZE=10"
))
{
assertThrows
(
ErrorCode
.
TABLE_OR_VIEW_NOT_FOUND_1
,
conn
).
assertThrows
(
ErrorCode
.
TABLE_OR_VIEW_NOT_FOUND_1
,
conn
).
prepareStatement
(
"SELECT * FROM TEST"
);
prepareStatement
(
"SELECT * FROM TEST"
);
Statement
stat
=
conn
.
createStatement
();
Statement
stat
=
conn
.
createStatement
();
...
@@ -105,6 +105,6 @@ public class TestQueryCache extends TestBase {
...
@@ -105,6 +105,6 @@ public class TestQueryCache extends TestBase {
stat
.
executeUpdate
(
"DROP TABLE TEST"
);
stat
.
executeUpdate
(
"DROP TABLE TEST"
);
assertThrows
(
ErrorCode
.
TABLE_OR_VIEW_NOT_FOUND_1
,
conn
).
assertThrows
(
ErrorCode
.
TABLE_OR_VIEW_NOT_FOUND_1
,
conn
).
prepareStatement
(
"SELECT * FROM TEST"
);
prepareStatement
(
"SELECT * FROM TEST"
);
conn
.
close
();
}
}
}
}
}
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/db/TestShow.java
浏览文件 @
d28d8c3a
...
@@ -33,7 +33,7 @@ public class TestShow extends TestBase {
...
@@ -33,7 +33,7 @@ public class TestShow extends TestBase {
}
}
private
void
testPgCompatibility
()
throws
SQLException
{
private
void
testPgCompatibility
()
throws
SQLException
{
Connection
conn
=
getConnection
(
"mem:pg"
);
try
(
Connection
conn
=
getConnection
(
"mem:pg"
))
{
Statement
stat
=
conn
.
createStatement
();
Statement
stat
=
conn
.
createStatement
();
assertResult
(
"UNICODE"
,
stat
,
"SHOW CLIENT_ENCODING"
);
assertResult
(
"UNICODE"
,
stat
,
"SHOW CLIENT_ENCODING"
);
...
@@ -43,9 +43,10 @@ public class TestShow extends TestBase {
...
@@ -43,9 +43,10 @@ public class TestShow extends TestBase {
assertResult
(
"8.1.4"
,
stat
,
"SHOW SERVER_VERSION"
);
assertResult
(
"8.1.4"
,
stat
,
"SHOW SERVER_VERSION"
);
assertResult
(
"UTF8"
,
stat
,
"SHOW SERVER_ENCODING"
);
assertResult
(
"UTF8"
,
stat
,
"SHOW SERVER_ENCODING"
);
}
}
}
private
void
testMysqlCompatibility
()
throws
SQLException
{
private
void
testMysqlCompatibility
()
throws
SQLException
{
Connection
conn
=
getConnection
(
"mem:pg"
);
try
(
Connection
conn
=
getConnection
(
"mem:pg"
))
{
Statement
stat
=
conn
.
createStatement
();
Statement
stat
=
conn
.
createStatement
();
ResultSet
rs
;
ResultSet
rs
;
...
@@ -63,4 +64,5 @@ public class TestShow extends TestBase {
...
@@ -63,4 +64,5 @@ public class TestShow extends TestBase {
// columns
// columns
assertResultRowCount
(
2
,
stat
.
executeQuery
(
"SHOW COLUMNS FROM person"
));
assertResultRowCount
(
2
,
stat
.
executeQuery
(
"SHOW COLUMNS FROM person"
));
}
}
}
}
}
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/db/TestSpatial.java
浏览文件 @
d28d8c3a
...
@@ -1064,7 +1064,7 @@ public class TestSpatial extends TestBase {
...
@@ -1064,7 +1064,7 @@ public class TestSpatial extends TestBase {
private
void
testInsertNull
()
throws
SQLException
{
private
void
testInsertNull
()
throws
SQLException
{
deleteDb
(
"spatial"
);
deleteDb
(
"spatial"
);
Connection
conn
=
getConnection
(
URL
);
try
(
Connection
conn
=
getConnection
(
URL
))
{
Statement
stat
=
conn
.
createStatement
();
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"\n"
+
stat
.
execute
(
"\n"
+
"drop table if exists PUBLIC.DUMMY_12;\n"
+
"drop table if exists PUBLIC.DUMMY_12;\n"
+
...
@@ -1137,12 +1137,13 @@ public class TestSpatial extends TestBase {
...
@@ -1137,12 +1137,13 @@ public class TestSpatial extends TestBase {
try
(
ResultSet
rs
=
stat
.
executeQuery
(
"select * from DUMMY_12"
))
{
try
(
ResultSet
rs
=
stat
.
executeQuery
(
"select * from DUMMY_12"
))
{
assertTrue
(
rs
.
next
());
assertTrue
(
rs
.
next
());
}
}
}
deleteDb
(
"spatial"
);
}
}
private
void
testSpatialIndexWithOrder
()
throws
SQLException
{
private
void
testSpatialIndexWithOrder
()
throws
SQLException
{
deleteDb
(
"spatial"
);
deleteDb
(
"spatial"
);
Connection
conn
=
getConnection
(
URL
);
try
(
Connection
conn
=
getConnection
(
URL
))
{
Statement
stat
=
conn
.
createStatement
();
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"DROP TABLE IF EXISTS BUILDINGS;"
+
stat
.
execute
(
"DROP TABLE IF EXISTS BUILDINGS;"
+
"CREATE TABLE BUILDINGS (PK serial, THE_GEOM geometry);"
+
"CREATE TABLE BUILDINGS (PK serial, THE_GEOM geometry);"
+
...
@@ -1156,4 +1157,6 @@ public class TestSpatial extends TestBase {
...
@@ -1156,4 +1157,6 @@ public class TestSpatial extends TestBase {
assertTrue
(
rs
.
getString
(
1
).
contains
(
"PRIMARY_KEY"
));
assertTrue
(
rs
.
getString
(
1
).
contains
(
"PRIMARY_KEY"
));
}
}
}
}
deleteDb
(
"spatial"
);
}
}
}
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/jdbc/TestConnection.java
浏览文件 @
d28d8c3a
...
@@ -45,6 +45,7 @@ public class TestConnection extends TestBase {
...
@@ -45,6 +45,7 @@ public class TestConnection extends TestBase {
assertThrows
(
SQLClientInfoException
.
class
,
conn
).
setClientInfo
(
"numServers"
,
"SomeValue"
);
assertThrows
(
SQLClientInfoException
.
class
,
conn
).
setClientInfo
(
"numServers"
,
"SomeValue"
);
assertThrows
(
SQLClientInfoException
.
class
,
conn
).
setClientInfo
(
"server23"
,
"SomeValue"
);
assertThrows
(
SQLClientInfoException
.
class
,
conn
).
setClientInfo
(
"server23"
,
"SomeValue"
);
conn
.
close
();
}
}
private
void
testSetUnsupportedClientInfoProperties
()
throws
SQLException
{
private
void
testSetUnsupportedClientInfoProperties
()
throws
SQLException
{
...
@@ -54,6 +55,7 @@ public class TestConnection extends TestBase {
...
@@ -54,6 +55,7 @@ public class TestConnection extends TestBase {
properties
.
put
(
"ClientUser"
,
"someUser"
);
properties
.
put
(
"ClientUser"
,
"someUser"
);
assertThrows
(
SQLClientInfoException
.
class
,
conn
).
setClientInfo
(
properties
);
assertThrows
(
SQLClientInfoException
.
class
,
conn
).
setClientInfo
(
properties
);
conn
.
close
();
}
}
private
void
testSetSupportedClientInfoProperties
()
throws
SQLException
{
private
void
testSetSupportedClientInfoProperties
()
throws
SQLException
{
...
@@ -67,6 +69,7 @@ public class TestConnection extends TestBase {
...
@@ -67,6 +69,7 @@ public class TestConnection extends TestBase {
assertNull
(
conn
.
getClientInfo
(
"ApplicationName"
));
assertNull
(
conn
.
getClientInfo
(
"ApplicationName"
));
// new property has been set
// new property has been set
assertEquals
(
conn
.
getClientInfo
(
"ClientUser"
),
"someUser"
);
assertEquals
(
conn
.
getClientInfo
(
"ClientUser"
),
"someUser"
);
conn
.
close
();
}
}
private
void
testSetSupportedClientInfo
()
throws
SQLException
{
private
void
testSetSupportedClientInfo
()
throws
SQLException
{
...
@@ -74,17 +77,20 @@ public class TestConnection extends TestBase {
...
@@ -74,17 +77,20 @@ public class TestConnection extends TestBase {
conn
.
setClientInfo
(
"ApplicationName"
,
"Connection Test"
);
conn
.
setClientInfo
(
"ApplicationName"
,
"Connection Test"
);
assertEquals
(
conn
.
getClientInfo
(
"ApplicationName"
),
"Connection Test"
);
assertEquals
(
conn
.
getClientInfo
(
"ApplicationName"
),
"Connection Test"
);
conn
.
close
();
}
}
private
void
testSetUnsupportedClientInfo
()
throws
SQLException
{
private
void
testSetUnsupportedClientInfo
()
throws
SQLException
{
Connection
conn
=
getConnection
(
"clientInfoDB2;MODE=DB2"
);
Connection
conn
=
getConnection
(
"clientInfoDB2;MODE=DB2"
);
assertThrows
(
SQLClientInfoException
.
class
,
conn
).
setClientInfo
(
assertThrows
(
SQLClientInfoException
.
class
,
conn
).
setClientInfo
(
"UnsupportedName"
,
"SomeValue"
);
"UnsupportedName"
,
"SomeValue"
);
conn
.
close
();
}
}
private
void
testGetUnsupportedClientInfo
()
throws
SQLException
{
private
void
testGetUnsupportedClientInfo
()
throws
SQLException
{
Connection
conn
=
getConnection
(
"clientInfo"
);
Connection
conn
=
getConnection
(
"clientInfo"
);
assertNull
(
conn
.
getClientInfo
(
"UnknownProperty"
));
assertNull
(
conn
.
getClientInfo
(
"UnknownProperty"
));
conn
.
close
();
}
}
private
void
testSetGetSchema
()
throws
SQLException
{
private
void
testSetGetSchema
()
throws
SQLException
{
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论