Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
3120065b
提交
3120065b
authored
8月 08, 2014
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Issue 573: Add implementation for Methods "isWrapperFor()" and "unwrap()" in other JDBC classes.
上级
7ad78c92
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
57 行增加
和
21 行删除
+57
-21
TestMetaData.java
h2/src/test/org/h2/test/jdbc/TestMetaData.java
+19
-4
TestPreparedStatement.java
h2/src/test/org/h2/test/jdbc/TestPreparedStatement.java
+12
-11
TestResultSet.java
h2/src/test/org/h2/test/jdbc/TestResultSet.java
+14
-4
TestStatement.java
h2/src/test/org/h2/test/jdbc/TestStatement.java
+12
-2
没有找到文件。
h2/src/test/org/h2/test/jdbc/TestMetaData.java
浏览文件 @
3120065b
...
...
@@ -39,6 +39,7 @@ public class TestMetaData extends TestBase {
@Override
public
void
test
()
throws
SQLException
{
deleteDb
(
"metaData"
);
testUnwrap
();
testUnsupportedOperations
();
testTempTable
();
testColumnResultSetMeta
();
...
...
@@ -56,16 +57,29 @@ public class TestMetaData extends TestBase {
testSessionsUncommitted
();
testQueryStatistics
();
}
private
void
testUnwrap
()
throws
SQLException
{
Connection
conn
=
getConnection
(
"metaData"
);
Statement
stat
=
conn
.
createStatement
();
ResultSet
rs
=
stat
.
executeQuery
(
"select 1 as x from dual"
);
ResultSetMetaData
meta
=
rs
.
getMetaData
();
assertTrue
(
meta
.
isWrapperFor
(
Object
.
class
));
assertTrue
(
meta
.
isWrapperFor
(
ResultSetMetaData
.
class
));
assertTrue
(
meta
.
isWrapperFor
(
meta
.
getClass
()));
assertTrue
(
meta
==
meta
.
unwrap
(
Object
.
class
));
assertTrue
(
meta
==
meta
.
unwrap
(
ResultSetMetaData
.
class
));
assertTrue
(
meta
==
meta
.
unwrap
(
meta
.
getClass
()));
assertFalse
(
meta
.
isWrapperFor
(
Integer
.
class
));
assertThrows
(
ErrorCode
.
INVALID_VALUE_2
,
meta
).
unwrap
(
Integer
.
class
);
conn
.
close
();
}
private
void
testUnsupportedOperations
()
throws
SQLException
{
Connection
conn
=
getConnection
(
"metaData"
);
Statement
stat
=
conn
.
createStatement
();
ResultSet
rs
=
stat
.
executeQuery
(
"select 1 as x from dual"
);
ResultSetMetaData
meta
=
rs
.
getMetaData
();
assertThrows
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
meta
).
isWrapperFor
(
Object
.
class
);
assertThrows
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
meta
).
unwrap
(
Object
.
class
);
assertThrows
(
ErrorCode
.
INVALID_VALUE_2
,
meta
).
getColumnLabel
(
0
);
assertThrows
(
ErrorCode
.
INVALID_VALUE_2
,
meta
).
getColumnName
(
0
);
assertThrows
(
ErrorCode
.
INVALID_VALUE_2
,
meta
).
getColumnType
(
0
);
...
...
@@ -971,6 +985,7 @@ public class TestMetaData extends TestBase {
private
void
testGeneral
()
throws
SQLException
{
Connection
conn
=
getConnection
(
"metaData"
);
DatabaseMetaData
meta
=
conn
.
getMetaData
();
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"CREATE TABLE TEST(ID INT PRIMARY KEY, NAME VARCHAR(255))"
);
...
...
h2/src/test/org/h2/test/jdbc/TestPreparedStatement.java
浏览文件 @
3120065b
...
...
@@ -56,6 +56,7 @@ public class TestPreparedStatement extends TestBase {
public
void
test
()
throws
Exception
{
deleteDb
(
"preparedStatement"
);
Connection
conn
=
getConnection
(
"preparedStatement"
);
testUnwrap
(
conn
);
testUnsupportedOperations
(
conn
);
testChangeType
(
conn
);
testDateTimeTimestampWithCalendar
(
conn
);
...
...
@@ -95,6 +96,17 @@ public class TestPreparedStatement extends TestBase {
testPreparedStatementWithLiteralsNone
();
deleteDb
(
"preparedStatement"
);
}
private
void
testUnwrap
(
Connection
conn
)
throws
SQLException
{
assertTrue
(
conn
.
isWrapperFor
(
Object
.
class
));
assertTrue
(
conn
.
isWrapperFor
(
Connection
.
class
));
assertTrue
(
conn
.
isWrapperFor
(
conn
.
getClass
()));
assertFalse
(
conn
.
isWrapperFor
(
String
.
class
));
assertTrue
(
conn
==
conn
.
unwrap
(
Object
.
class
));
assertTrue
(
conn
==
conn
.
unwrap
(
Connection
.
class
));
assertThrows
(
ErrorCode
.
INVALID_VALUE_2
,
conn
).
unwrap
(
String
.
class
);
}
@SuppressWarnings
(
"deprecation"
)
private
void
testUnsupportedOperations
(
Connection
conn
)
throws
Exception
{
...
...
@@ -134,17 +146,6 @@ public class TestPreparedStatement extends TestBase {
ParameterMetaData
meta
=
prep
.
getParameterMetaData
();
assertTrue
(
meta
.
toString
(),
meta
.
toString
().
endsWith
(
"parameterCount=1"
));
assertThrows
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
meta
).
isWrapperFor
(
Object
.
class
);
assertThrows
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
meta
).
unwrap
(
Object
.
class
);
assertTrue
(
conn
.
isWrapperFor
(
Object
.
class
));
assertTrue
(
conn
.
isWrapperFor
(
Connection
.
class
));
assertFalse
(
conn
.
isWrapperFor
(
String
.
class
));
assertTrue
(
conn
==
conn
.
unwrap
(
Object
.
class
));
assertTrue
(
conn
==
conn
.
unwrap
(
Connection
.
class
));
assertThrows
(
ErrorCode
.
INVALID_VALUE_2
,
conn
).
unwrap
(
String
.
class
);
assertThrows
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
conn
).
createSQLXML
();
assertThrows
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
conn
).
...
...
h2/src/test/org/h2/test/jdbc/TestResultSet.java
浏览文件 @
3120065b
...
...
@@ -63,6 +63,7 @@ public class TestResultSet extends TestBase {
stat
=
conn
.
createStatement
();
testUnwrap
();
testReuseSimpleResult
();
testUnsupportedOperations
();
testAmbiguousColumnNames
();
...
...
@@ -101,6 +102,19 @@ public class TestResultSet extends TestBase {
deleteDb
(
"resultSet"
);
}
private
void
testUnwrap
()
throws
SQLException
{
ResultSet
rs
=
stat
.
executeQuery
(
"select 1"
);
assertTrue
(
rs
.
isWrapperFor
(
Object
.
class
));
assertTrue
(
rs
.
isWrapperFor
(
ResultSet
.
class
));
assertTrue
(
rs
.
isWrapperFor
(
rs
.
getClass
()));
assertFalse
(
rs
.
isWrapperFor
(
Integer
.
class
));
assertTrue
(
rs
==
rs
.
unwrap
(
Object
.
class
));
assertTrue
(
rs
==
rs
.
unwrap
(
ResultSet
.
class
));
assertTrue
(
rs
==
rs
.
unwrap
(
rs
.
getClass
()));
assertThrows
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
rs
).
unwrap
(
Object
.
class
);
}
private
void
testReuseSimpleResult
()
throws
SQLException
{
ResultSet
rs
=
stat
.
executeQuery
(
"select table(x array=((1)))"
);
...
...
@@ -166,10 +180,6 @@ public class TestResultSet extends TestBase {
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
{
...
...
h2/src/test/org/h2/test/jdbc/TestStatement.java
浏览文件 @
3120065b
...
...
@@ -6,6 +6,7 @@
package
org
.
h2
.
test
.
jdbc
;
import
java.sql.Connection
;
import
java.sql.DatabaseMetaData
;
import
java.sql.ResultSet
;
import
java.sql.SQLClientInfoException
;
import
java.sql.SQLException
;
...
...
@@ -41,6 +42,7 @@ public class TestStatement extends TestBase {
public
void
test
()
throws
Exception
{
deleteDb
(
"statement"
);
conn
=
getConnection
(
"statement"
);
testUnwrap
();
testUnsupportedOperations
();
testTraceError
();
testSavepoint
();
...
...
@@ -51,14 +53,22 @@ public class TestStatement extends TestBase {
conn
.
close
();
deleteDb
(
"statement"
);
}
private
void
testUn
supportedOperations
()
throws
Exception
{
private
void
testUn
wrap
()
throws
SQL
Exception
{
Statement
stat
=
conn
.
createStatement
();
assertTrue
(
stat
.
isWrapperFor
(
Object
.
class
));
assertTrue
(
stat
.
isWrapperFor
(
DatabaseMetaData
.
class
));
assertTrue
(
stat
.
isWrapperFor
(
stat
.
getClass
()));
assertTrue
(
stat
==
stat
.
unwrap
(
Object
.
class
));
assertTrue
(
stat
==
stat
.
unwrap
(
DatabaseMetaData
.
class
));
assertTrue
(
stat
==
stat
.
unwrap
(
stat
.
getClass
()));
assertThrows
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
stat
).
isWrapperFor
(
Object
.
class
);
assertThrows
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
stat
).
unwrap
(
Object
.
class
);
}
private
void
testUnsupportedOperations
()
throws
Exception
{
conn
.
setTypeMap
(
null
);
HashMap
<
String
,
Class
<?>>
map
=
New
.
hashMap
();
conn
.
setTypeMap
(
map
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论