Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
06b743c0
提交
06b743c0
authored
6月 24, 2013
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Enable tests; formatting.
上级
676a5a2d
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
29 行增加
和
12 行删除
+29
-12
TestPgServer.java
h2/src/test/org/h2/test/unit/TestPgServer.java
+29
-12
没有找到文件。
h2/src/test/org/h2/test/unit/TestPgServer.java
浏览文件 @
06b743c0
...
@@ -6,8 +6,21 @@
...
@@ -6,8 +6,21 @@
*/
*/
package
org
.
h2
.
test
.
unit
;
package
org
.
h2
.
test
.
unit
;
import
java.sql.*
;
import
java.sql.Connection
;
import
java.util.concurrent.*
;
import
java.sql.DatabaseMetaData
;
import
java.sql.DriverManager
;
import
java.sql.ParameterMetaData
;
import
java.sql.PreparedStatement
;
import
java.sql.ResultSet
;
import
java.sql.ResultSetMetaData
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
java.sql.Types
;
import
java.util.concurrent.Callable
;
import
java.util.concurrent.ExecutionException
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.Future
;
import
org.h2.test.TestBase
;
import
org.h2.test.TestBase
;
import
org.h2.tools.Server
;
import
org.h2.tools.Server
;
...
@@ -27,9 +40,11 @@ public class TestPgServer extends TestBase {
...
@@ -27,9 +40,11 @@ public class TestPgServer extends TestBase {
}
}
@Override
@Override
public
void
test
()
throws
SQL
Exception
{
public
void
test
()
throws
Exception
{
testPGAdapter
();
testPGAdapter
();
testKeyAlias
();
testKeyAlias
();
testCancelQuery
();
testBinaryTypes
();
}
}
private
void
testPGAdapter
()
throws
SQLException
{
private
void
testPGAdapter
()
throws
SQLException
{
...
@@ -63,12 +78,13 @@ public class TestPgServer extends TestBase {
...
@@ -63,12 +78,13 @@ public class TestPgServer extends TestBase {
// create a table with 200 rows (cancel interval is 127)
// create a table with 200 rows (cancel interval is 127)
stat
.
execute
(
"create table test(id int)"
);
stat
.
execute
(
"create table test(id int)"
);
for
(
int
i
=
0
;
i
<
200
;
i
++)
{
for
(
int
i
=
0
;
i
<
200
;
i
++)
{
stat
.
execute
(
"insert into test (id) values (rand())"
);
stat
.
execute
(
"insert into test (id) values (rand())"
);
}
}
Future
<
Boolean
>
future
=
executor
.
submit
(
new
Callable
<
Boolean
>()
{
Future
<
Boolean
>
future
=
executor
.
submit
(
new
Callable
<
Boolean
>()
{
public
Boolean
call
()
throws
Exception
{
@Override
public
Boolean
call
()
throws
SQLException
{
return
stat
.
execute
(
"select id, sleep(5) from test"
);
return
stat
.
execute
(
"select id, sleep(5) from test"
);
}
}
});
});
...
@@ -81,7 +97,7 @@ public class TestPgServer extends TestBase {
...
@@ -81,7 +97,7 @@ public class TestPgServer extends TestBase {
future
.
get
();
future
.
get
();
throw
new
IllegalStateException
();
throw
new
IllegalStateException
();
}
catch
(
ExecutionException
e
)
{
}
catch
(
ExecutionException
e
)
{
assertStartsWith
(
e
.
getCause
().
getMessage
(),
"ERROR:
Statement was canceled
"
);
assertStartsWith
(
e
.
getCause
().
getMessage
(),
"ERROR:
canceling statement due to user request
"
);
}
finally
{
}
finally
{
conn
.
close
();
conn
.
close
();
}
}
...
@@ -293,28 +309,29 @@ public class TestPgServer extends TestBase {
...
@@ -293,28 +309,29 @@ public class TestPgServer extends TestBase {
PreparedStatement
ps
=
conn
.
prepareStatement
(
"insert into test values (?,?,?,?,?,?,?,?,?,?)"
);
PreparedStatement
ps
=
conn
.
prepareStatement
(
"insert into test values (?,?,?,?,?,?,?,?,?,?)"
);
ps
.
setString
(
1
,
"test"
);
ps
.
setString
(
1
,
"test"
);
ps
.
setInt
(
2
,
12345678
);
ps
.
setInt
(
2
,
12345678
);
ps
.
setShort
(
3
,
(
short
)
12345
);
ps
.
setShort
(
3
,
(
short
)
12345
);
ps
.
setLong
(
4
,
1234567890123L
);
ps
.
setLong
(
4
,
1234567890123L
);
ps
.
setDouble
(
5
,
123.456
);
ps
.
setDouble
(
5
,
123.456
);
ps
.
setFloat
(
6
,
123.456f
);
ps
.
setFloat
(
6
,
123.456f
);
ps
.
setDouble
(
7
,
123.456
);
ps
.
setDouble
(
7
,
123.456
);
ps
.
setBoolean
(
8
,
true
);
ps
.
setBoolean
(
8
,
true
);
ps
.
setByte
(
9
,
(
byte
)
0xfe
);
ps
.
setByte
(
9
,
(
byte
)
0xfe
);
ps
.
setBytes
(
10
,
new
byte
[]
{
'a'
,(
byte
)
0xfe
,
'\
127
'
});
ps
.
setBytes
(
10
,
new
byte
[]
{
'a'
,
(
byte
)
0xfe
,
'\
127
'
});
ps
.
execute
();
ps
.
execute
();
ResultSet
rs
=
stat
.
executeQuery
(
"select * from test"
);
ResultSet
rs
=
stat
.
executeQuery
(
"select * from test"
);
assertTrue
(
rs
.
next
());
assertTrue
(
rs
.
next
());
assertEquals
(
"test"
,
rs
.
getString
(
1
));
assertEquals
(
"test"
,
rs
.
getString
(
1
));
assertEquals
(
12345678
,
rs
.
getInt
(
2
));
assertEquals
(
12345678
,
rs
.
getInt
(
2
));
assertEquals
((
short
)
12345
,
rs
.
getShort
(
3
));
assertEquals
((
short
)
12345
,
rs
.
getShort
(
3
));
assertEquals
(
1234567890123L
,
rs
.
getLong
(
4
));
assertEquals
(
1234567890123L
,
rs
.
getLong
(
4
));
assertEquals
(
123.456
,
rs
.
getDouble
(
5
));
assertEquals
(
123.456
,
rs
.
getDouble
(
5
));
assertEquals
(
123.456f
,
rs
.
getFloat
(
6
));
assertEquals
(
123.456f
,
rs
.
getFloat
(
6
));
assertEquals
(
123.456
,
rs
.
getDouble
(
7
));
assertEquals
(
123.456
,
rs
.
getDouble
(
7
));
assertEquals
(
true
,
rs
.
getBoolean
(
8
));
assertEquals
(
true
,
rs
.
getBoolean
(
8
));
assertEquals
((
byte
)
0xfe
,
rs
.
getByte
(
9
));
assertEquals
((
byte
)
0xfe
,
rs
.
getByte
(
9
));
assertEquals
(
new
byte
[]{
'a'
,(
byte
)
0xfe
,
'\
127
'
},
rs
.
getBytes
(
10
));
assertEquals
(
new
byte
[]
{
'a'
,
(
byte
)
0xfe
,
'\
127
'
},
rs
.
getBytes
(
10
));
conn
.
close
();
conn
.
close
();
}
catch
(
ClassNotFoundException
e
)
{
}
catch
(
ClassNotFoundException
e
)
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论