Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
527757ce
提交
527757ce
authored
12月 21, 2013
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
More tests
上级
428f1f59
显示空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
67 行增加
和
3 行删除
+67
-3
JdbcArray.java
h2/src/main/org/h2/jdbc/JdbcArray.java
+1
-1
TestCallableStatement.java
h2/src/test/org/h2/test/jdbc/TestCallableStatement.java
+7
-1
TestPreparedStatement.java
h2/src/test/org/h2/test/jdbc/TestPreparedStatement.java
+33
-0
TestResultSet.java
h2/src/test/org/h2/test/jdbc/TestResultSet.java
+16
-1
TestUpdatableResultSet.java
h2/src/test/org/h2/test/jdbc/TestUpdatableResultSet.java
+10
-0
没有找到文件。
h2/src/main/org/h2/jdbc/JdbcArray.java
浏览文件 @
527757ce
...
@@ -285,6 +285,6 @@ public class JdbcArray extends TraceObject implements Array {
...
@@ -285,6 +285,6 @@ public class JdbcArray extends TraceObject implements Array {
*/
*/
@Override
@Override
public
String
toString
()
{
public
String
toString
()
{
return
getTraceObjectName
()
+
": "
+
value
.
getTraceSQL
(
);
return
value
==
null
?
"null"
:
(
getTraceObjectName
()
+
": "
+
value
.
getTraceSQL
()
);
}
}
}
}
h2/src/test/org/h2/test/jdbc/TestCallableStatement.java
浏览文件 @
527757ce
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
*/
*/
package
org
.
h2
.
test
.
jdbc
;
package
org
.
h2
.
test
.
jdbc
;
import
java.math.BigDecimal
;
import
java.sql.CallableStatement
;
import
java.sql.CallableStatement
;
import
java.sql.Connection
;
import
java.sql.Connection
;
import
java.sql.ResultSet
;
import
java.sql.ResultSet
;
...
@@ -111,6 +112,10 @@ public class TestCallableStatement extends TestBase {
...
@@ -111,6 +112,10 @@ public class TestCallableStatement extends TestBase {
call
.
execute
();
call
.
execute
();
assertEquals
(
123
,
call
.
getShort
(
1
));
assertEquals
(
123
,
call
.
getShort
(
1
));
call
.
setBigDecimal
(
2
,
BigDecimal
.
TEN
);
call
.
registerOutParameter
(
1
,
Types
.
DECIMAL
);
call
.
execute
();
assertEquals
(
"10"
,
call
.
getBigDecimal
(
1
).
toString
());
}
}
private
void
testCallWithResult
(
Connection
conn
)
throws
SQLException
{
private
void
testCallWithResult
(
Connection
conn
)
throws
SQLException
{
...
@@ -222,6 +227,7 @@ public class TestCallableStatement extends TestBase {
...
@@ -222,6 +227,7 @@ public class TestCallableStatement extends TestBase {
public
static
Boolean
testClassF
(
Boolean
b
)
{
public
static
Boolean
testClassF
(
Boolean
b
)
{
return
!
b
;
return
!
b
;
}
}
/**
/**
* This method is called via reflection from the database.
* This method is called via reflection from the database.
*
*
...
...
h2/src/test/org/h2/test/jdbc/TestPreparedStatement.java
浏览文件 @
527757ce
...
@@ -10,12 +10,14 @@ import java.io.ByteArrayInputStream;
...
@@ -10,12 +10,14 @@ import java.io.ByteArrayInputStream;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.StringReader
;
import
java.io.StringReader
;
import
java.math.BigDecimal
;
import
java.math.BigDecimal
;
import
java.net.URL
;
import
java.sql.Connection
;
import
java.sql.Connection
;
import
java.sql.Date
;
import
java.sql.Date
;
import
java.sql.ParameterMetaData
;
import
java.sql.ParameterMetaData
;
import
java.sql.PreparedStatement
;
import
java.sql.PreparedStatement
;
import
java.sql.ResultSet
;
import
java.sql.ResultSet
;
import
java.sql.ResultSetMetaData
;
import
java.sql.ResultSetMetaData
;
import
java.sql.RowId
;
import
java.sql.SQLException
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
java.sql.Statement
;
import
java.sql.Time
;
import
java.sql.Time
;
...
@@ -26,6 +28,7 @@ import java.util.GregorianCalendar;
...
@@ -26,6 +28,7 @@ import java.util.GregorianCalendar;
import
java.util.SimpleTimeZone
;
import
java.util.SimpleTimeZone
;
import
java.util.TimeZone
;
import
java.util.TimeZone
;
import
java.util.UUID
;
import
java.util.UUID
;
import
org.h2.api.Trigger
;
import
org.h2.api.Trigger
;
import
org.h2.constant.ErrorCode
;
import
org.h2.constant.ErrorCode
;
import
org.h2.test.TestBase
;
import
org.h2.test.TestBase
;
...
@@ -52,6 +55,7 @@ public class TestPreparedStatement extends TestBase {
...
@@ -52,6 +55,7 @@ public class TestPreparedStatement extends TestBase {
public
void
test
()
throws
Exception
{
public
void
test
()
throws
Exception
{
deleteDb
(
"preparedStatement"
);
deleteDb
(
"preparedStatement"
);
Connection
conn
=
getConnection
(
"preparedStatement"
);
Connection
conn
=
getConnection
(
"preparedStatement"
);
testUnsupportedOperations
(
conn
);
testChangeType
(
conn
);
testChangeType
(
conn
);
testDateTimeTimestampWithCalendar
(
conn
);
testDateTimeTimestampWithCalendar
(
conn
);
testCallTablePrepared
(
conn
);
testCallTablePrepared
(
conn
);
...
@@ -91,6 +95,35 @@ public class TestPreparedStatement extends TestBase {
...
@@ -91,6 +95,35 @@ public class TestPreparedStatement extends TestBase {
deleteDb
(
"preparedStatement"
);
deleteDb
(
"preparedStatement"
);
}
}
private
void
testUnsupportedOperations
(
Connection
conn
)
throws
Exception
{
PreparedStatement
prep
=
conn
.
prepareStatement
(
"select ? from dual"
);
assertThrows
(
ErrorCode
.
METHOD_NOT_ALLOWED_FOR_PREPARED_STATEMENT
,
prep
).
addBatch
(
"select 1"
);
assertThrows
(
ErrorCode
.
METHOD_NOT_ALLOWED_FOR_PREPARED_STATEMENT
,
prep
).
executeUpdate
(
"create table test(id int)"
);
assertThrows
(
ErrorCode
.
METHOD_NOT_ALLOWED_FOR_PREPARED_STATEMENT
,
prep
).
executeUpdate
(
"create table test(id int)"
,
new
int
[
0
]);
assertThrows
(
ErrorCode
.
METHOD_NOT_ALLOWED_FOR_PREPARED_STATEMENT
,
prep
).
executeUpdate
(
"create table test(id int)"
,
new
String
[
0
]);
assertThrows
(
ErrorCode
.
METHOD_NOT_ALLOWED_FOR_PREPARED_STATEMENT
,
prep
).
executeUpdate
(
"create table test(id int)"
,
Statement
.
RETURN_GENERATED_KEYS
);
assertThrows
(
ErrorCode
.
METHOD_NOT_ALLOWED_FOR_PREPARED_STATEMENT
,
prep
).
execute
(
"create table test(id int)"
);
assertThrows
(
ErrorCode
.
METHOD_NOT_ALLOWED_FOR_PREPARED_STATEMENT
,
prep
).
execute
(
"create table test(id int)"
,
new
int
[
0
]);
assertThrows
(
ErrorCode
.
METHOD_NOT_ALLOWED_FOR_PREPARED_STATEMENT
,
prep
).
execute
(
"create table test(id int)"
,
new
String
[
0
]);
assertThrows
(
ErrorCode
.
METHOD_NOT_ALLOWED_FOR_PREPARED_STATEMENT
,
prep
).
execute
(
"create table test(id int)"
,
Statement
.
RETURN_GENERATED_KEYS
);
assertThrows
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
prep
).
setURL
(
1
,
new
URL
(
"http://www.acme.com"
));
assertThrows
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
prep
).
setRowId
(
1
,
(
RowId
)
null
);
}
private
static
void
testChangeType
(
Connection
conn
)
throws
SQLException
{
private
static
void
testChangeType
(
Connection
conn
)
throws
SQLException
{
PreparedStatement
prep
=
conn
.
prepareStatement
(
"select (? || ? || ?) from dual"
);
PreparedStatement
prep
=
conn
.
prepareStatement
(
"select (? || ? || ?) from dual"
);
prep
.
setString
(
1
,
"a"
);
prep
.
setString
(
1
,
"a"
);
...
...
h2/src/test/org/h2/test/jdbc/TestResultSet.java
浏览文件 @
527757ce
...
@@ -25,6 +25,7 @@ import java.sql.Time;
...
@@ -25,6 +25,7 @@ import java.sql.Time;
import
java.sql.Timestamp
;
import
java.sql.Timestamp
;
import
java.sql.Types
;
import
java.sql.Types
;
import
java.util.Calendar
;
import
java.util.Calendar
;
import
java.util.Collections
;
import
java.util.Locale
;
import
java.util.Locale
;
import
java.util.TimeZone
;
import
java.util.TimeZone
;
import
org.h2.constant.ErrorCode
;
import
org.h2.constant.ErrorCode
;
...
@@ -1084,6 +1085,7 @@ public class TestResultSet extends TestBase {
...
@@ -1084,6 +1085,7 @@ public class TestResultSet extends TestBase {
Object
[]
list
=
(
Object
[])
rs
.
getObject
(
2
);
Object
[]
list
=
(
Object
[])
rs
.
getObject
(
2
);
assertEquals
(
1
,
((
Integer
)
list
[
0
]).
intValue
());
assertEquals
(
1
,
((
Integer
)
list
[
0
]).
intValue
());
assertEquals
(
2
,
((
Integer
)
list
[
1
]).
intValue
());
assertEquals
(
2
,
((
Integer
)
list
[
1
]).
intValue
());
Array
array
=
rs
.
getArray
(
2
);
Array
array
=
rs
.
getArray
(
2
);
Object
[]
list2
=
(
Object
[])
array
.
getArray
();
Object
[]
list2
=
(
Object
[])
array
.
getArray
();
assertEquals
(
1
,
((
Integer
)
list2
[
0
]).
intValue
());
assertEquals
(
1
,
((
Integer
)
list2
[
0
]).
intValue
());
...
@@ -1095,12 +1097,25 @@ public class TestResultSet extends TestBase {
...
@@ -1095,12 +1097,25 @@ public class TestResultSet extends TestBase {
list
=
(
Object
[])
rs
.
getObject
(
2
);
list
=
(
Object
[])
rs
.
getObject
(
2
);
assertEquals
(
11
,
((
Integer
)
list
[
0
]).
intValue
());
assertEquals
(
11
,
((
Integer
)
list
[
0
]).
intValue
());
assertEquals
(
12
,
((
Integer
)
list
[
1
]).
intValue
());
assertEquals
(
12
,
((
Integer
)
list
[
1
]).
intValue
());
array
=
rs
.
getArray
(
2
);
array
=
rs
.
getArray
(
"VALUE"
);
list2
=
(
Object
[])
array
.
getArray
();
list2
=
(
Object
[])
array
.
getArray
();
assertEquals
(
11
,
((
Integer
)
list2
[
0
]).
intValue
());
assertEquals
(
11
,
((
Integer
)
list2
[
0
]).
intValue
());
assertEquals
(
12
,
((
Integer
)
list2
[
1
]).
intValue
());
assertEquals
(
12
,
((
Integer
)
list2
[
1
]).
intValue
());
list2
=
(
Object
[])
array
.
getArray
(
2
,
1
);
list2
=
(
Object
[])
array
.
getArray
(
2
,
1
);
assertEquals
(
12
,
((
Integer
)
list2
[
0
]).
intValue
());
assertEquals
(
12
,
((
Integer
)
list2
[
0
]).
intValue
());
list2
=
(
Object
[])
array
.
getArray
(
Collections
.<
String
,
Class
<?>>
emptyMap
());
assertEquals
(
11
,
((
Integer
)
list2
[
0
]).
intValue
());
assertEquals
(
Types
.
NULL
,
array
.
getBaseType
());
assertEquals
(
"NULL"
,
array
.
getBaseTypeName
());
assertEquals
(
"ar1: (11, 12)"
,
array
.
toString
());
array
.
free
();
assertEquals
(
"null"
,
array
.
toString
());
assertFalse
(
rs
.
next
());
assertFalse
(
rs
.
next
());
stat
.
execute
(
"DROP TABLE TEST"
);
stat
.
execute
(
"DROP TABLE TEST"
);
}
}
...
...
h2/src/test/org/h2/test/jdbc/TestUpdatableResultSet.java
浏览文件 @
527757ce
...
@@ -155,7 +155,11 @@ public class TestUpdatableResultSet extends TestBase {
...
@@ -155,7 +155,11 @@ public class TestUpdatableResultSet extends TestBase {
rs
.
updateInt
(
1
,
10
);
rs
.
updateInt
(
1
,
10
);
rs
.
updateRow
();
rs
.
updateRow
();
rs
.
next
();
rs
.
next
();
rs
.
updateString
(
2
,
"Welt"
);
rs
.
cancelRowUpdates
();
rs
.
updateString
(
2
,
"Welt"
);
rs
.
updateString
(
2
,
"Welt"
);
rs
.
updateRow
();
rs
.
updateRow
();
rs
.
beforeFirst
();
rs
.
beforeFirst
();
rs
.
next
();
rs
.
next
();
...
@@ -164,6 +168,11 @@ public class TestUpdatableResultSet extends TestBase {
...
@@ -164,6 +168,11 @@ public class TestUpdatableResultSet extends TestBase {
rs
.
next
();
rs
.
next
();
assertEquals
(
2
,
rs
.
getInt
(
1
));
assertEquals
(
2
,
rs
.
getInt
(
1
));
assertEquals
(
"Welt"
,
rs
.
getString
(
2
));
assertEquals
(
"Welt"
,
rs
.
getString
(
2
));
assertFalse
(
rs
.
isClosed
());
rs
.
close
();
assertTrue
(
rs
.
isClosed
());
conn
.
close
();
conn
.
close
();
}
}
...
@@ -294,6 +303,7 @@ public class TestUpdatableResultSet extends TestBase {
...
@@ -294,6 +303,7 @@ public class TestUpdatableResultSet extends TestBase {
rs
.
updateNull
(
2
);
rs
.
updateNull
(
2
);
rs
.
updateNull
(
"DEC"
);
rs
.
updateNull
(
"DEC"
);
// 'not set' values are set to null
// 'not set' values are set to null
assertThrows
(
ErrorCode
.
NO_DATA_AVAILABLE
,
rs
).
cancelRowUpdates
();
rs
.
insertRow
();
rs
.
insertRow
();
rs
.
moveToInsertRow
();
rs
.
moveToInsertRow
();
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论