Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
9d752889
提交
9d752889
authored
10月 03, 2008
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
--no commit message
--no commit message
上级
a01c023e
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
7 行增加
和
82 行删除
+7
-82
TestAutoServer.java
h2/src/test/org/h2/test/server/TestAutoServer.java
+7
-16
TestAutoServer2.java
h2/src/test/org/h2/test/server/TestAutoServer2.java
+0
-66
没有找到文件。
h2/src/test/org/h2/test/server/TestAutoServer.java
浏览文件 @
9d752889
...
...
@@ -6,14 +6,12 @@
*/
package
org
.
h2
.
test
.
server
;
import
java.io.File
;
import
java.sql.Connection
;
import
java.sql.DriverManager
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
org.h2.test.TestBase
;
import
org.h2.test.unit.SelfDestructor
;
import
org.h2.util.SortedProperties
;
/**
...
...
@@ -42,14 +40,7 @@ public class TestAutoServer extends TestBase {
deleteDb
(
"autoServer"
);
String
url
=
getURL
(
"autoServer;AUTO_SERVER=TRUE"
,
true
);
String
user
=
getUser
(),
password
=
getPassword
();
Connection
conn
=
getConnection
(
url
,
user
,
password
);
conn
.
close
();
String
selfDestruct
=
SelfDestructor
.
getPropertyString
(
60
);
String
[]
procDef
=
new
String
[]
{
"java"
,
selfDestruct
,
"-cp"
,
"bin"
+
File
.
pathSeparator
+
"."
,
TestAutoServer2
.
class
.
getName
(),
url
,
user
,
password
};
// TestAutoServer2.main(new String[]{url, user, password});
Process
proc
=
Runtime
.
getRuntime
().
exec
(
procDef
);
Connection
connServer
=
getConnection
(
url
+
";OPEN_NEW=TRUE"
,
user
,
password
);
int
i
=
SLOW
?
Integer
.
MAX_VALUE
:
30
;
for
(;
i
>
0
;
i
--)
{
...
...
@@ -60,7 +51,7 @@ public class TestAutoServer extends TestBase {
if
(
server
!=
null
)
{
String
u2
=
url
.
substring
(
url
.
indexOf
(
";"
));
u2
=
"jdbc:h2:tcp://"
+
server
+
"/"
+
key
+
u2
;
conn
=
DriverManager
.
getConnection
(
u2
,
user
,
password
);
Connection
conn
=
DriverManager
.
getConnection
(
u2
,
user
,
password
);
conn
.
close
();
break
;
}
...
...
@@ -69,17 +60,17 @@ public class TestAutoServer extends TestBase {
fail
();
}
conn
=
getConnection
(
url
);
Connection
conn
=
getConnection
(
url
+
";OPEN_NEW=TRUE"
);
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"CREATE ALIAS HALT FOR \""
+
getClass
().
getName
()
+
".halt\""
);
try
{
stat
.
execute
(
"
CALL HALT(11)
"
);
stat
.
execute
(
"
SHUTDOWN
"
);
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
// the connection is closed
}
conn
.
close
();
assertEquals
(
11
,
proc
.
exitValue
());
// proc.destroy
();
connServer
.
close
();
}
/**
...
...
h2/src/test/org/h2/test/server/TestAutoServer2.java
deleted
100644 → 0
浏览文件 @
a01c023e
/*
* Copyright 2004-2008 H2 Group. Multiple-Licensed under the H2 License,
* Version 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package
org
.
h2
.
test
.
server
;
import
java.io.ByteArrayOutputStream
;
import
java.io.PrintStream
;
import
java.sql.Connection
;
import
java.sql.DriverManager
;
import
org.h2.test.TestBase
;
/**
* Tests automatic embedded/server mode.
*/
public
class
TestAutoServer2
extends
TestBase
{
/**
* Run just this test.
*
* @param a the connection information or empty
*/
public
static
void
main
(
String
[]
a
)
throws
Exception
{
if
(
a
.
length
==
3
)
{
// PrintStream ps = new PrintStream(new File("test.txt"));
PrintStream
ps
=
new
PrintStream
(
new
ByteArrayOutputStream
());
System
.
setErr
(
ps
);
System
.
setOut
(
ps
);
ps
.
println
(
new
java
.
sql
.
Timestamp
(
System
.
currentTimeMillis
()).
toString
());
ps
.
flush
();
try
{
ps
.
println
(
"loading"
);
ps
.
flush
();
org
.
h2
.
Driver
.
load
();
ps
.
println
(
"connecting url:"
+
a
[
0
]
+
" user:"
+
a
[
1
]
+
" pwd:"
+
a
[
2
]);
ps
.
flush
();
Connection
conn
=
DriverManager
.
getConnection
(
a
[
0
],
a
[
1
],
a
[
2
]);
ps
.
println
(
"waiting"
);
ps
.
flush
();
Thread
.
sleep
(
TestAutoServer
.
SLOW
?
60000
:
5000
);
ps
.
println
(
"closing"
);
ps
.
flush
();
conn
.
close
();
ps
.
println
(
"closed"
);
ps
.
flush
();
}
catch
(
Throwable
t
)
{
t
.
printStackTrace
(
ps
);
t
.
printStackTrace
();
}
ps
.
close
();
System
.
exit
(
0
);
}
else
{
new
TestAutoServer2
().
init
().
test
();
}
}
public
void
test
()
throws
Exception
{
deleteDb
(
"autoServer"
);
String
url
=
getURL
(
"autoServer;AUTO_SERVER=TRUE"
,
true
);
String
user
=
getUser
(),
password
=
getPassword
();
main
(
new
String
[]{
url
,
user
,
password
});
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论