Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
0302903b
提交
0302903b
authored
1月 24, 2014
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Additional tests for the new LOB storage
上级
7648963e
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
70 行增加
和
26 行删除
+70
-26
TestBase.java
h2/src/test/org/h2/test/TestBase.java
+36
-0
TestMVTableEngine.java
h2/src/test/org/h2/test/store/TestMVTableEngine.java
+32
-3
TestStreamStore.java
h2/src/test/org/h2/test/store/TestStreamStore.java
+2
-23
没有找到文件。
h2/src/test/org/h2/test/TestBase.java
浏览文件 @
0302903b
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
*/
*/
package
org
.
h2
.
test
;
package
org
.
h2
.
test
;
import
java.io.ByteArrayInputStream
;
import
java.io.File
;
import
java.io.File
;
import
java.io.FileWriter
;
import
java.io.FileWriter
;
import
java.io.IOException
;
import
java.io.IOException
;
...
@@ -1499,5 +1500,40 @@ public abstract class TestBase {
...
@@ -1499,5 +1500,40 @@ public abstract class TestBase {
throw
new
RuntimeException
(
e
);
throw
new
RuntimeException
(
e
);
}
}
}
}
/**
* Construct a stream of 20 KB that fails while reading with the provided
* exception.
*
* @param e the exception
* @return the stream
*/
public
static
ByteArrayInputStream
createFailingStream
(
final
Exception
e
)
{
return
new
ByteArrayInputStream
(
new
byte
[
20
*
1024
])
{
@Override
public
int
read
(
byte
[]
buffer
,
int
off
,
int
len
)
{
if
(
this
.
pos
>
10
*
1024
)
{
throwException
(
e
);
}
return
super
.
read
(
buffer
,
off
,
len
);
}
};
}
/**
* Throw a checked exception, without having to declare the method as
* throwing a checked exception.
*
* @param e the exception to throw
*/
public
static
void
throwException
(
Throwable
e
)
{
TestBase
.<
RuntimeException
>
throwThis
(
e
);
}
@SuppressWarnings
(
"unchecked"
)
private
static
<
E
extends
Throwable
>
void
throwThis
(
Throwable
e
)
throws
E
{
throw
(
E
)
e
;
}
}
}
h2/src/test/org/h2/test/store/TestMVTableEngine.java
浏览文件 @
0302903b
...
@@ -21,6 +21,7 @@ import org.h2.constant.ErrorCode;
...
@@ -21,6 +21,7 @@ import org.h2.constant.ErrorCode;
import
org.h2.engine.Constants
;
import
org.h2.engine.Constants
;
import
org.h2.engine.Database
;
import
org.h2.engine.Database
;
import
org.h2.jdbc.JdbcConnection
;
import
org.h2.jdbc.JdbcConnection
;
import
org.h2.mvstore.MVMap
;
import
org.h2.mvstore.MVStore
;
import
org.h2.mvstore.MVStore
;
import
org.h2.mvstore.db.TransactionStore
;
import
org.h2.mvstore.db.TransactionStore
;
import
org.h2.store.fs.FileUtils
;
import
org.h2.store.fs.FileUtils
;
...
@@ -75,9 +76,37 @@ public class TestMVTableEngine extends TestBase {
...
@@ -75,9 +76,37 @@ public class TestMVTableEngine extends TestBase {
}
}
private
void
testGarbageCollectionForLOB
()
throws
SQLException
{
private
void
testGarbageCollectionForLOB
()
throws
SQLException
{
FileUtils
.
deleteRecursive
(
getBaseDir
(),
true
);
// TODO Auto-generated method stub
Connection
conn
;
Statement
stat
;
String
url
=
"mvstore;MV_STORE=TRUE"
;
url
=
getURL
(
url
,
true
);
conn
=
getConnection
(
url
);
stat
=
conn
.
createStatement
();
stat
.
execute
(
"create table test(id int, data blob)"
);
stat
.
execute
(
"insert into test select x, repeat('0', 10000) from system_range(1, 10)"
);
stat
.
execute
(
"drop table test"
);
stat
.
equals
(
"call @temp := cast(repeat('0', 10000) as blob)"
);
stat
.
execute
(
"create table test2(id int, data blob)"
);
PreparedStatement
prep
=
conn
.
prepareStatement
(
"insert into test2 values(?, ?)"
);
prep
.
setInt
(
1
,
1
);
assertThrows
(
ErrorCode
.
IO_EXCEPTION_1
,
prep
).
setBinaryStream
(
1
,
createFailingStream
(
new
IOException
()));
prep
.
setInt
(
1
,
2
);
assertThrows
(
ErrorCode
.
IO_EXCEPTION_1
,
prep
).
setBinaryStream
(
1
,
createFailingStream
(
new
IllegalStateException
()));
conn
.
close
();
MVStore
s
=
MVStore
.
open
(
getBaseDir
()+
"/mvstore.mv.db"
);
assertTrue
(
s
.
hasMap
(
"lobData"
));
MVMap
<
Long
,
byte
[]>
lobData
=
s
.
openMap
(
"lobData"
);
assertEquals
(
0
,
lobData
.
sizeAsLong
());
assertTrue
(
s
.
hasMap
(
"lobMap"
));
MVMap
<
Long
,
byte
[]>
lobMap
=
s
.
openMap
(
"lobMap"
);
assertEquals
(
0
,
lobMap
.
sizeAsLong
());
assertTrue
(
s
.
hasMap
(
"lobRef"
));
MVMap
<
Long
,
byte
[]>
lobRef
=
s
.
openMap
(
"lobRef"
);
assertEquals
(
0
,
lobRef
.
sizeAsLong
());
s
.
close
();
}
}
private
void
testSpatial
()
throws
SQLException
{
private
void
testSpatial
()
throws
SQLException
{
...
...
h2/src/test/org/h2/test/store/TestStreamStore.java
浏览文件 @
0302903b
...
@@ -61,34 +61,13 @@ public class TestStreamStore extends TestBase {
...
@@ -61,34 +61,13 @@ public class TestStreamStore extends TestBase {
StreamStore
s
=
new
StreamStore
(
map
);
StreamStore
s
=
new
StreamStore
(
map
);
s
.
setMaxBlockSize
(
1024
);
s
.
setMaxBlockSize
(
1024
);
assertThrows
(
IOException
.
class
,
s
).
assertThrows
(
IOException
.
class
,
s
).
put
(
f
ailingStream
(
new
IOException
()));
put
(
createF
ailingStream
(
new
IOException
()));
assertEquals
(
0
,
map
.
size
());
assertEquals
(
0
,
map
.
size
());
// the runtime exception is converted to an IOException
// the runtime exception is converted to an IOException
assertThrows
(
IOException
.
class
,
s
).
assertThrows
(
IOException
.
class
,
s
).
put
(
f
ailingStream
(
new
IllegalStateException
()));
put
(
createF
ailingStream
(
new
IllegalStateException
()));
assertEquals
(
0
,
map
.
size
());
assertEquals
(
0
,
map
.
size
());
}
}
static
void
throwUnchecked
(
Throwable
e
)
{
TestStreamStore
.<
RuntimeException
>
throwThis
(
e
);
}
@SuppressWarnings
(
"unchecked"
)
private
static
<
E
extends
Throwable
>
void
throwThis
(
Throwable
e
)
throws
E
{
throw
(
E
)
e
;
}
private
static
ByteArrayInputStream
failingStream
(
final
Exception
e
)
{
return
new
ByteArrayInputStream
(
new
byte
[
20
*
1024
])
{
@Override
public
int
read
(
byte
[]
buffer
,
int
off
,
int
len
)
{
if
(
this
.
pos
>
10
*
1024
)
{
throwUnchecked
(
e
);
}
return
super
.
read
(
buffer
,
off
,
len
);
}
};
}
private
void
testReadCount
()
throws
IOException
{
private
void
testReadCount
()
throws
IOException
{
String
fileName
=
getBaseDir
()
+
"/testReadCount.h3"
;
String
fileName
=
getBaseDir
()
+
"/testReadCount.h3"
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论