Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
43e768fc
Unverified
提交
43e768fc
authored
7 年前
作者:
Noel Grandin
提交者:
GitHub
7 年前
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #804 from katzyn/misc
Use new ArrayList(Collection) and assertThrows()
上级
79b5e027
ba92ed5c
隐藏空白字符变更
内嵌
并排
正在显示
11 个修改的文件
包含
19 行增加
和
95 行删除
+19
-95
QueryStatisticsData.java
h2/src/main/org/h2/engine/QueryStatisticsData.java
+2
-4
TestCases.java
h2/src/test/org/h2/test/db/TestCases.java
+3
-24
TestFunctions.java
h2/src/test/org/h2/test/db/TestFunctions.java
+3
-18
TestIndexHints.java
h2/src/test/org/h2/test/db/TestIndexHints.java
+2
-8
TestLob.java
h2/src/test/org/h2/test/db/TestLob.java
+2
-12
TestOutOfMemory.java
h2/src/test/org/h2/test/db/TestOutOfMemory.java
+1
-6
TestTriggersConstraints.java
h2/src/test/org/h2/test/db/TestTriggersConstraints.java
+2
-7
TestMvcc3.java
h2/src/test/org/h2/test/mvcc/TestMvcc3.java
+1
-10
TestIntPerfectHash.java
h2/src/test/org/h2/test/unit/TestIntPerfectHash.java
+1
-2
MinimalPerfectHash.java
h2/src/tools/org/h2/dev/hash/MinimalPerfectHash.java
+1
-2
ClassReader.java
h2/src/tools/org/h2/jaqu/bytecode/ClassReader.java
+1
-2
没有找到文件。
h2/src/main/org/h2/engine/QueryStatisticsData.java
浏览文件 @
43e768fc
...
...
@@ -43,8 +43,7 @@ public class QueryStatisticsData {
public
synchronized
List
<
QueryEntry
>
getQueries
()
{
// return a copy of the map so we don't have to
// worry about external synchronization
ArrayList
<
QueryEntry
>
list
=
new
ArrayList
<>();
list
.
addAll
(
map
.
values
());
ArrayList
<
QueryEntry
>
list
=
new
ArrayList
<>(
map
.
values
());
// only return the newest 100 entries
Collections
.
sort
(
list
,
QUERY_ENTRY_COMPARATOR
);
return
list
.
subList
(
0
,
Math
.
min
(
list
.
size
(),
maxQueryEntries
));
...
...
@@ -71,8 +70,7 @@ public class QueryStatisticsData {
// Test against 1.5 x max-size so we don't do this too often
if
(
map
.
size
()
>
maxQueryEntries
*
1.5f
)
{
// Sort the entries by age
ArrayList
<
QueryEntry
>
list
=
new
ArrayList
<>();
list
.
addAll
(
map
.
values
());
ArrayList
<
QueryEntry
>
list
=
new
ArrayList
<>(
map
.
values
());
Collections
.
sort
(
list
,
QUERY_ENTRY_COMPARATOR
);
// Create a set of the oldest 1/3 of the entries
HashSet
<
QueryEntry
>
oldestSet
=
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/db/TestCases.java
浏览文件 @
43e768fc
...
...
@@ -158,12 +158,7 @@ public class TestCases extends TestBase {
private
void
testClearSyntaxException
()
throws
SQLException
{
Connection
conn
=
getConnection
(
"cases"
);
Statement
stat
=
conn
.
createStatement
();
try
{
stat
.
execute
(
"select t.x, t.x t.y from dual t"
);
fail
();
}
catch
(
SQLException
e
)
{
assertEquals
(
"42000"
,
e
.
getSQLState
());
}
assertThrows
(
42000
,
stat
).
execute
(
"select t.x, t.x t.y from dual t"
);
conn
.
close
();
}
...
...
@@ -240,24 +235,8 @@ public class TestCases extends TestBase {
Connection
conn
=
getConnection
(
"selfreferential"
);
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"create table sr(id integer, usecount integer as usecount + 1)"
);
check:
{
try
{
stat
.
execute
(
"insert into sr(id) values (1)"
);
}
catch
(
SQLException
ex
)
{
assertEquals
(
ErrorCode
.
getState
(
ErrorCode
.
NULL_NOT_ALLOWED
),
ex
.
getSQLState
());
break
check
;
}
fail
(
"Exception expected"
);
}
check:
{
try
{
stat
.
execute
(
"select max(id), usecount from sr"
);
}
catch
(
SQLException
ex
)
{
assertEquals
(
ErrorCode
.
getState
(
ErrorCode
.
MUST_GROUP_BY_COLUMN_1
),
ex
.
getSQLState
());
break
check
;
}
fail
(
"Exception expected"
);
}
assertThrows
(
ErrorCode
.
NULL_NOT_ALLOWED
,
stat
).
execute
(
"insert into sr(id) values (1)"
);
assertThrows
(
ErrorCode
.
MUST_GROUP_BY_COLUMN_1
,
stat
).
execute
(
"select max(id), usecount from sr"
);
conn
.
close
();
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/db/TestFunctions.java
浏览文件 @
43e768fc
...
...
@@ -1211,28 +1211,13 @@ public class TestFunctions extends TestBase implements AggregateFunction {
java
.
util
.
Date
nowDate
=
c
.
getTime
();
assertEquals
(
nowDate
,
rs
.
getTimestamp
(
2
));
try
{
rs
=
stat
.
executeQuery
(
"SELECT TRUNCATE('bad', 1) FROM dual"
);
fail
(
"expected exception"
);
}
catch
(
SQLException
ex
)
{
// expected
}
assertThrows
(
SQLException
.
class
,
stat
).
executeQuery
(
"SELECT TRUNCATE('bad', 1) FROM dual"
);
// check for passing wrong data type
try
{
rs
=
stat
.
executeQuery
(
"SELECT TRUNCATE('bad') FROM dual"
);
fail
(
"expected exception"
);
}
catch
(
SQLException
ex
)
{
// expected
}
rs
=
assertThrows
(
SQLException
.
class
,
stat
).
executeQuery
(
"SELECT TRUNCATE('bad') FROM dual"
);
// check for too many parameters
try
{
rs
=
stat
.
executeQuery
(
"SELECT TRUNCATE(1,2,3) FROM dual"
);
fail
(
"expected exception"
);
}
catch
(
SQLException
ex
)
{
// expected
}
rs
=
assertThrows
(
SQLException
.
class
,
stat
).
executeQuery
(
"SELECT TRUNCATE(1,2,3) FROM dual"
);
conn
.
close
();
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/db/TestIndexHints.java
浏览文件 @
43e768fc
...
...
@@ -128,14 +128,8 @@ public class TestIndexHints extends TestBase {
private
void
testWithInvalidIndexName
()
throws
SQLException
{
Statement
stat
=
conn
.
createStatement
();
try
{
stat
.
executeQuery
(
"explain analyze select * "
+
"from test use index(idx_doesnt_exist) where x=1 and y=1"
);
fail
(
"Expected exception: "
+
"Index \"IDX_DOESNT_EXIST\" not found"
);
}
catch
(
SQLException
e
)
{
assertEquals
(
ErrorCode
.
INDEX_NOT_FOUND_1
,
e
.
getErrorCode
());
}
assertThrows
(
ErrorCode
.
INDEX_NOT_FOUND_1
,
stat
).
executeQuery
(
"explain analyze select * "
+
"from test use index(idx_doesnt_exist) where x=1 and y=1"
);
}
}
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/db/TestLob.java
浏览文件 @
43e768fc
...
...
@@ -192,12 +192,7 @@ public class TestLob extends TestBase {
Thread
.
sleep
(
100
);
// start a new transaction, to be sure
stat
.
execute
(
"delete from test"
);
try
{
c1
.
getSubString
(
1
,
3
);
fail
();
}
catch
(
SQLException
e
)
{
// expected
}
assertThrows
(
SQLException
.
class
,
c1
).
getSubString
(
1
,
3
);
conn
.
close
();
}
...
...
@@ -641,12 +636,7 @@ public class TestLob extends TestBase {
Statement
stat
;
conn
=
getConnection
(
"lob"
);
stat
=
conn
.
createStatement
();
try
{
stat
.
execute
(
"create memory table test(x clob unique)"
);
fail
();
}
catch
(
SQLException
e
)
{
assertEquals
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
e
.
getErrorCode
());
}
assertThrows
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
stat
).
execute
(
"create memory table test(x clob unique)"
);
conn
.
close
();
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/db/TestOutOfMemory.java
浏览文件 @
43e768fc
...
...
@@ -148,12 +148,7 @@ public class TestOutOfMemory extends TestBase {
stat
.
execute
(
"checkpoint"
);
eatMemory
(
80
);
try
{
try
{
prep
.
execute
();
fail
();
}
catch
(
SQLException
e
)
{
assertEquals
(
ErrorCode
.
OUT_OF_MEMORY
,
e
.
getErrorCode
());
}
assertThrows
(
ErrorCode
.
OUT_OF_MEMORY
,
prep
).
execute
();
assertThrows
(
ErrorCode
.
DATABASE_IS_CLOSED
,
conn
).
close
();
freeMemory
();
conn
=
null
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/db/TestTriggersConstraints.java
浏览文件 @
43e768fc
...
...
@@ -165,14 +165,9 @@ public class TestTriggersConstraints extends TestBase implements Trigger {
stat
=
conn
.
createStatement
();
stat
.
execute
(
"drop table if exists test"
);
stat
.
execute
(
"create table test(id int)"
);
try
{
stat
.
execute
(
"create trigger test_insert before select on test "
+
assertThrows
(
ErrorCode
.
TRIGGER_SELECT_AND_ROW_BASED_NOT_SUPPORTED
,
stat
)
.
execute
(
"create trigger test_insert before select on test "
+
"for each row call \""
+
TestTriggerAdapter
.
class
.
getName
()
+
"\""
);
fail
();
}
catch
(
SQLException
ex
)
{
assertEquals
(
ErrorCode
.
TRIGGER_SELECT_AND_ROW_BASED_NOT_SUPPORTED
,
ex
.
getErrorCode
());
}
conn
.
close
();
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/mvcc/TestMvcc3.java
浏览文件 @
43e768fc
...
...
@@ -79,12 +79,7 @@ public class TestMvcc3 extends TestBase {
s1
.
execute
(
"create unique index on test(name)"
);
s1
.
executeUpdate
(
"update test set name = 100 where id = 1"
);
try
{
s2
.
executeUpdate
(
"update test set name = 100 where id = 2"
);
fail
();
}
catch
(
SQLException
e
)
{
// expected
}
assertThrows
(
SQLException
.
class
,
s2
).
executeUpdate
(
"update test set name = 100 where id = 2"
);
ResultSet
rs
=
s1
.
executeQuery
(
"select * from test order by id"
);
assertTrue
(
rs
.
next
());
...
...
@@ -268,7 +263,3 @@ public class TestMvcc3 extends TestBase {
}
}
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/unit/TestIntPerfectHash.java
浏览文件 @
43e768fc
...
...
@@ -84,8 +84,7 @@ public class TestIntPerfectHash extends TestBase {
while
(
set
.
size
()
<
size
)
{
set
.
add
(
r
.
nextInt
());
}
ArrayList
<
Integer
>
list
=
new
ArrayList
<>();
list
.
addAll
(
set
);
ArrayList
<
Integer
>
list
=
new
ArrayList
<>(
set
);
byte
[]
desc
=
IntPerfectHash
.
generate
(
list
);
int
max
=
test
(
desc
,
set
);
assertEquals
(
size
-
1
,
max
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/tools/org/h2/dev/hash/MinimalPerfectHash.java
浏览文件 @
43e768fc
...
...
@@ -330,8 +330,7 @@ public class MinimalPerfectHash<K> {
* @return the hash function description
*/
public
static
<
K
>
byte
[]
generate
(
Set
<
K
>
set
,
UniversalHash
<
K
>
hash
)
{
ArrayList
<
K
>
list
=
new
ArrayList
<>();
list
.
addAll
(
set
);
ArrayList
<
K
>
list
=
new
ArrayList
<>(
set
);
ByteArrayOutputStream
out
=
new
ByteArrayOutputStream
();
int
seed
=
RANDOM
.
nextInt
();
out
.
write
(
seed
>>>
24
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/tools/org/h2/jaqu/bytecode/ClassReader.java
浏览文件 @
43e768fc
...
...
@@ -246,8 +246,7 @@ public class ClassReader {
Token
c
=
stack
.
pop
();
Stack
<
Token
>
currentStack
=
new
Stack
<>();
currentStack
.
addAll
(
stack
);
ArrayList
<
Token
>
currentVariables
=
new
ArrayList
<>();
currentVariables
.
addAll
(
variables
);
ArrayList
<
Token
>
currentVariables
=
new
ArrayList
<>(
variables
);
int
branch
=
nextPc
;
Token
a
=
getResult
();
stack
=
currentStack
;
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论