Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
d48aa1ba
提交
d48aa1ba
authored
11 年前
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
More tests
上级
9934cd5d
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
89 行增加
和
1 行删除
+89
-1
TestCallableStatement.java
h2/src/test/org/h2/test/jdbc/TestCallableStatement.java
+2
-1
TestLobApi.java
h2/src/test/org/h2/test/jdbc/TestLobApi.java
+34
-0
TestPreparedStatement.java
h2/src/test/org/h2/test/jdbc/TestPreparedStatement.java
+7
-0
TestResultSet.java
h2/src/test/org/h2/test/jdbc/TestResultSet.java
+46
-0
没有找到文件。
h2/src/test/org/h2/test/jdbc/TestCallableStatement.java
浏览文件 @
d48aa1ba
...
...
@@ -82,7 +82,7 @@ public class TestCallableStatement extends TestBase {
assertThrows
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
call
).
getObject
(
"a"
,
Collections
.<
String
,
Class
<?>>
emptyMap
());
assertThrows
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
call
).
getRef
(
"a"
);
assertThrows
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
call
).
getRowId
(
"a"
);
assertThrows
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
call
).
getSQLXML
(
1
);
assertThrows
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
call
).
getSQLXML
(
"a"
);
assertThrows
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
call
).
setURL
(
1
,
(
URL
)
null
);
assertThrows
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
call
).
setRef
(
1
,
(
Ref
)
null
);
...
...
@@ -312,4 +312,5 @@ public class TestCallableStatement extends TestBase {
return
TestCallableStatement
.
class
;
}
}
}
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/jdbc/TestLobApi.java
浏览文件 @
d48aa1ba
...
...
@@ -45,6 +45,7 @@ public class TestLobApi extends TestBase {
@Override
public
void
test
()
throws
Exception
{
deleteDb
(
"lob"
);
testUnsupportedOperations
();
testLobStaysOpenUntilCommitted
();
testInputStreamThrowsException
(
true
);
testInputStreamThrowsException
(
false
);
...
...
@@ -65,6 +66,39 @@ public class TestLobApi extends TestBase {
conn
.
close
();
}
private
void
testUnsupportedOperations
()
throws
Exception
{
Connection
conn
=
getConnection
(
"lob"
);
stat
=
conn
.
createStatement
();
stat
.
execute
(
"create table test(id int, c clob, b blob)"
);
stat
.
execute
(
"insert into test values(1, 'x', x'00')"
);
ResultSet
rs
=
stat
.
executeQuery
(
"select * from test order by id"
);
rs
.
next
();
Clob
clob
=
rs
.
getClob
(
2
);
assertTrue
(
clob
.
toString
().
endsWith
(
"'x'"
));
clob
.
free
();
assertTrue
(
clob
.
toString
().
endsWith
(
"null"
));
assertThrows
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
clob
).
truncate
(
0
);
assertThrows
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
clob
).
setAsciiStream
(
1
);
assertThrows
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
clob
).
setString
(
1
,
""
,
0
,
1
);
assertThrows
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
clob
).
position
(
""
,
0
);
assertThrows
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
clob
).
position
((
Clob
)
null
,
0
);
assertThrows
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
clob
).
getCharacterStream
(
1
,
1
);
Blob
blob
=
rs
.
getBlob
(
3
);
assertThrows
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
blob
).
truncate
(
0
);
assertThrows
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
blob
).
setBytes
(
1
,
new
byte
[
0
],
0
,
0
);
assertThrows
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
blob
).
position
(
new
byte
[
1
],
0
);
assertThrows
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
blob
).
position
((
Blob
)
null
,
0
);
assertThrows
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
blob
).
getBinaryStream
(
1
,
1
);
assertTrue
(
blob
.
toString
().
endsWith
(
"X'00'"
));
blob
.
free
();
assertTrue
(
blob
.
toString
().
endsWith
(
"null"
));
stat
.
execute
(
"drop table test"
);
conn
.
close
();
}
/**
* According to the JDBC spec, BLOB and CLOB objects must stay open even if
* the result set is closed (see ResultSet.close).
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/jdbc/TestPreparedStatement.java
浏览文件 @
d48aa1ba
...
...
@@ -8,9 +8,11 @@ package org.h2.test.jdbc;
import
java.io.ByteArrayInputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.StringReader
;
import
java.math.BigDecimal
;
import
java.net.URL
;
import
java.sql.Array
;
import
java.sql.Connection
;
import
java.sql.Date
;
import
java.sql.ParameterMetaData
;
...
...
@@ -95,6 +97,7 @@ public class TestPreparedStatement extends TestBase {
deleteDb
(
"preparedStatement"
);
}
@SuppressWarnings
(
"deprecation"
)
private
void
testUnsupportedOperations
(
Connection
conn
)
throws
Exception
{
PreparedStatement
prep
=
conn
.
prepareStatement
(
"select ? from dual"
);
assertThrows
(
ErrorCode
.
METHOD_NOT_ALLOWED_FOR_PREPARED_STATEMENT
,
prep
).
...
...
@@ -122,6 +125,10 @@ public class TestPreparedStatement extends TestBase {
setURL
(
1
,
new
URL
(
"http://www.acme.com"
));
assertThrows
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
prep
).
setRowId
(
1
,
(
RowId
)
null
);
assertThrows
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
prep
).
setUnicodeStream
(
1
,
(
InputStream
)
null
,
0
);
assertThrows
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
prep
).
setArray
(
1
,
(
Array
)
null
);
}
private
static
void
testChangeType
(
Connection
conn
)
throws
SQLException
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/jdbc/TestResultSet.java
浏览文件 @
d48aa1ba
...
...
@@ -16,10 +16,14 @@ import java.sql.Array;
import
java.sql.Connection
;
import
java.sql.DatabaseMetaData
;
import
java.sql.Date
;
import
java.sql.NClob
;
import
java.sql.PreparedStatement
;
import
java.sql.Ref
;
import
java.sql.ResultSet
;
import
java.sql.ResultSetMetaData
;
import
java.sql.RowId
;
import
java.sql.SQLException
;
import
java.sql.SQLXML
;
import
java.sql.Statement
;
import
java.sql.Time
;
import
java.sql.Timestamp
;
...
...
@@ -55,6 +59,7 @@ public class TestResultSet extends TestBase {
stat
=
conn
.
createStatement
();
testUnsupportedOperations
();
testAmbiguousColumnNames
();
testInsertRowWithUpdatableResultSetDefault
();
testBeforeFirstAfterLast
();
...
...
@@ -92,6 +97,39 @@ public class TestResultSet extends TestBase {
}
@SuppressWarnings
(
"deprecation"
)
private
void
testUnsupportedOperations
()
throws
SQLException
{
ResultSet
rs
=
stat
.
executeQuery
(
"select 1 as x from dual"
);
assertThrows
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
rs
).
getUnicodeStream
(
1
);
assertThrows
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
rs
).
getUnicodeStream
(
"x"
);
assertThrows
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
rs
).
getObject
(
1
,
Collections
.<
String
,
Class
<?>>
emptyMap
());
assertThrows
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
rs
).
getObject
(
"x"
,
Collections
.<
String
,
Class
<?>>
emptyMap
());
assertThrows
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
rs
).
getRef
(
1
);
assertThrows
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
rs
).
getRef
(
"x"
);
assertThrows
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
rs
).
getURL
(
1
);
assertThrows
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
rs
).
getURL
(
"x"
);
assertThrows
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
rs
).
getRowId
(
1
);
assertThrows
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
rs
).
getRowId
(
"x"
);
assertThrows
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
rs
).
getSQLXML
(
1
);
assertThrows
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
rs
).
getSQLXML
(
"x"
);
assertThrows
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
rs
).
updateRef
(
1
,
(
Ref
)
null
);
assertThrows
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
rs
).
updateRef
(
"x"
,
(
Ref
)
null
);
assertThrows
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
rs
).
updateArray
(
1
,
(
Array
)
null
);
assertThrows
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
rs
).
updateArray
(
"x"
,
(
Array
)
null
);
assertThrows
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
rs
).
updateRowId
(
1
,
(
RowId
)
null
);
assertThrows
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
rs
).
updateRowId
(
"x"
,
(
RowId
)
null
);
assertThrows
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
rs
).
updateNClob
(
1
,
(
NClob
)
null
);
assertThrows
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
rs
).
updateNClob
(
"x"
,
(
NClob
)
null
);
assertThrows
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
rs
).
updateSQLXML
(
1
,
(
SQLXML
)
null
);
assertThrows
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
rs
).
updateSQLXML
(
"x"
,
(
SQLXML
)
null
);
assertThrows
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
rs
).
getCursorName
();
assertThrows
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
rs
).
setFetchDirection
(
ResultSet
.
FETCH_FORWARD
);
assertThrows
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
rs
).
unwrap
(
Object
.
class
);
assertThrows
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
rs
).
isWrapperFor
(
Object
.
class
);
}
private
void
testAmbiguousColumnNames
()
throws
SQLException
{
stat
.
execute
(
"create table test(id int)"
);
stat
.
execute
(
"insert into test values(1)"
);
...
...
@@ -664,6 +702,7 @@ public class TestResultSet extends TestBase {
assertResultSetMeta
(
rs
,
2
,
new
String
[]
{
"ID"
,
"VALUE"
},
new
int
[]
{
Types
.
INTEGER
,
Types
.
DECIMAL
},
new
int
[]
{
10
,
10
},
new
int
[]
{
0
,
2
});
BigDecimal
bd
;
rs
.
next
();
assertTrue
(
rs
.
getInt
(
1
)
==
1
);
assertTrue
(!
rs
.
wasNull
());
...
...
@@ -676,6 +715,7 @@ public class TestResultSet extends TestBase {
trace
(
o
.
getClass
().
getName
());
assertTrue
(
o
instanceof
BigDecimal
);
assertTrue
(((
BigDecimal
)
o
).
compareTo
(
new
BigDecimal
(
"-1.00"
))
==
0
);
rs
.
next
();
assertTrue
(
rs
.
getInt
(
1
)
==
2
);
assertTrue
(!
rs
.
wasNull
());
...
...
@@ -684,16 +724,22 @@ public class TestResultSet extends TestBase {
bd
=
rs
.
getBigDecimal
(
2
);
assertTrue
(
bd
.
compareTo
(
new
BigDecimal
(
"0.00"
))
==
0
);
assertTrue
(!
rs
.
wasNull
());
rs
.
next
();
checkColumnBigDecimal
(
rs
,
2
,
1
,
"1.00"
);
rs
.
next
();
checkColumnBigDecimal
(
rs
,
2
,
12345679
,
"12345678.89"
);
rs
.
next
();
checkColumnBigDecimal
(
rs
,
2
,
99999999
,
"99999998.99"
);
rs
.
next
();
checkColumnBigDecimal
(
rs
,
2
,
-
99999999
,
"-99999998.99"
);
rs
.
next
();
checkColumnBigDecimal
(
rs
,
2
,
0
,
null
);
assertTrue
(!
rs
.
next
());
stat
.
execute
(
"DROP TABLE TEST"
);
}
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论