Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
57106638
提交
57106638
authored
11 年前
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
More tests
上级
a662ec86
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
59 行增加
和
5 行删除
+59
-5
TestLobApi.java
h2/src/test/org/h2/test/jdbc/TestLobApi.java
+55
-5
TestPreparedStatement.java
h2/src/test/org/h2/test/jdbc/TestPreparedStatement.java
+4
-0
没有找到文件。
h2/src/test/org/h2/test/jdbc/TestLobApi.java
浏览文件 @
57106638
...
...
@@ -16,6 +16,7 @@ import java.io.Writer;
import
java.sql.Blob
;
import
java.sql.Clob
;
import
java.sql.Connection
;
import
java.sql.NClob
;
import
java.sql.PreparedStatement
;
import
java.sql.ResultSet
;
import
java.sql.Statement
;
...
...
@@ -23,6 +24,7 @@ import java.util.Random;
import
org.h2.constant.ErrorCode
;
import
org.h2.jdbc.JdbcConnection
;
import
org.h2.test.TestBase
;
import
org.h2.upgrade.v1_1.util.IOUtils
;
/**
* Test the Blob, Clob, and NClob implementations.
...
...
@@ -74,6 +76,8 @@ public class TestLobApi extends TestBase {
ResultSet
rs
=
stat
.
executeQuery
(
"select * from test order by id"
);
rs
.
next
();
Clob
clob
=
rs
.
getClob
(
2
);
byte
[]
data
=
IOUtils
.
readBytesAndClose
(
clob
.
getAsciiStream
(),
-
1
);
assertEquals
(
"x"
,
new
String
(
data
,
"UTF-8"
));
assertTrue
(
clob
.
toString
().
endsWith
(
"'x'"
));
clob
.
free
();
assertTrue
(
clob
.
toString
().
endsWith
(
"null"
));
...
...
@@ -213,15 +217,26 @@ public class TestLobApi extends TestBase {
out
.
write
(
data
,
0
,
data
.
length
);
out
.
close
();
stat
.
execute
(
"delete from test"
);
PreparedStatement
prep
=
conn
.
prepareStatement
(
"insert into test values(?, ?)"
);
prep
.
setInt
(
1
,
1
);
prep
.
setBlob
(
2
,
b
);
prep
.
execute
();
prep
.
setInt
(
1
,
2
);
b
=
conn
.
createBlob
();
b
.
setBytes
(
1
,
data
);
prep
.
setBlob
(
2
,
b
);
prep
.
execute
();
prep
.
setInt
(
1
,
3
);
prep
.
setBlob
(
2
,
new
ByteArrayInputStream
(
data
));
prep
.
execute
();
prep
.
setInt
(
1
,
4
);
prep
.
setBlob
(
2
,
new
ByteArrayInputStream
(
data
),
-
1
);
prep
.
execute
();
ResultSet
rs
;
rs
=
stat
.
executeQuery
(
"select * from test"
);
rs
.
next
();
...
...
@@ -235,6 +250,10 @@ public class TestLobApi extends TestBase {
assertEquals
(
length
,
b2
.
length
());
bytes2
=
b2
.
getBytes
(
1
,
length
);
assertEquals
(
bytes
,
bytes2
);
while
(
rs
.
next
())
{
bytes2
=
rs
.
getBytes
(
2
);
assertEquals
(
bytes
,
bytes2
);
}
}
private
void
testClob
(
int
length
)
throws
Exception
{
...
...
@@ -259,14 +278,44 @@ public class TestLobApi extends TestBase {
out
.
close
();
stat
.
execute
(
"delete from test"
);
PreparedStatement
prep
=
conn
.
prepareStatement
(
"insert into test values(?, ?)"
);
prep
.
setInt
(
1
,
1
);
prep
.
setClob
(
2
,
c
);
prep
.
execute
();
c
=
conn
.
createClob
();
c
.
setString
(
1
,
new
String
(
data
));
prep
.
setInt
(
1
,
2
);
prep
.
setClob
(
2
,
c
);
prep
.
execute
();
prep
.
setInt
(
1
,
3
);
prep
.
setCharacterStream
(
2
,
new
StringReader
(
new
String
(
data
)));
prep
.
execute
();
prep
.
setInt
(
1
,
4
);
prep
.
setCharacterStream
(
2
,
new
StringReader
(
new
String
(
data
)),
-
1
);
prep
.
execute
();
NClob
nc
;
nc
=
conn
.
createNClob
();
nc
.
setString
(
1
,
new
String
(
data
));
prep
.
setInt
(
1
,
5
);
prep
.
setNClob
(
2
,
nc
);
prep
.
execute
();
prep
.
setInt
(
1
,
5
);
prep
.
setNClob
(
2
,
new
StringReader
(
new
String
(
data
)));
prep
.
execute
();
prep
.
setInt
(
1
,
6
);
prep
.
setNClob
(
2
,
new
StringReader
(
new
String
(
data
)),
-
1
);
prep
.
execute
();
prep
.
setInt
(
1
,
7
);
prep
.
setNString
(
2
,
new
String
(
data
));
prep
.
execute
();
ResultSet
rs
;
rs
=
stat
.
executeQuery
(
"select * from test"
);
rs
.
next
();
...
...
@@ -274,11 +323,12 @@ public class TestLobApi extends TestBase {
assertEquals
(
length
,
c2
.
length
());
String
s
=
c
.
getSubString
(
1
,
length
);
String
s2
=
c2
.
getSubString
(
1
,
length
);
rs
.
next
();
c2
=
rs
.
getClob
(
2
);
assertEquals
(
length
,
c2
.
length
());
s2
=
c2
.
getSubString
(
1
,
length
);
assertEquals
(
s
,
s2
);
while
(
rs
.
next
())
{
c2
=
rs
.
getClob
(
2
);
assertEquals
(
length
,
c2
.
length
());
s2
=
c2
.
getSubString
(
1
,
length
);
assertEquals
(
s
,
s2
);
}
}
}
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/jdbc/TestPreparedStatement.java
浏览文件 @
57106638
...
...
@@ -121,6 +121,9 @@ public class TestPreparedStatement extends TestBase {
assertThrows
(
ErrorCode
.
METHOD_NOT_ALLOWED_FOR_PREPARED_STATEMENT
,
prep
).
execute
(
"create table test(id int)"
,
Statement
.
RETURN_GENERATED_KEYS
);
assertThrows
(
ErrorCode
.
METHOD_NOT_ALLOWED_FOR_PREPARED_STATEMENT
,
prep
).
executeQuery
(
"select * from dual"
);
assertThrows
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
prep
).
setURL
(
1
,
new
URL
(
"http://www.acme.com"
));
assertThrows
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
prep
).
...
...
@@ -841,6 +844,7 @@ public class TestPreparedStatement extends TestBase {
prep
.
setInt
(
2
,
3
);
prep
.
executeUpdate
();
prep
.
setInt
(
1
,
4
);
prep
.
setNull
(
2
,
Types
.
INTEGER
,
"INTEGER"
);
prep
.
setNull
(
2
,
Types
.
INTEGER
);
prep
.
executeUpdate
();
prep
.
setInt
(
1
,
5
);
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论