Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
82351d47
提交
82351d47
authored
12月 18, 2010
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Improve code coverage.
上级
6a8ec3a5
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
66 行增加
和
23 行删除
+66
-23
changelog.html
h2/src/docsrc/html/changelog.html
+3
-1
Console.java
h2/src/main/org/h2/tools/Console.java
+31
-22
TestTools.java
h2/src/test/org/h2/test/unit/TestTools.java
+32
-0
没有找到文件。
h2/src/docsrc/html/changelog.html
浏览文件 @
82351d47
...
...
@@ -18,7 +18,9 @@ Change Log
<h1>
Change Log
</h1>
<h2>
Next Version (unreleased)
</h2>
<ul><li>
Improved date / time arithmetics. Adding and subtracting a
<ul><li>
The org.h2.tools.Console no longer calls System.exit on shutdown
(this should not have any user visible effect, but should allow to integrate the tool easier into other applications).
</li><li>
Improved date / time arithmetics. Adding and subtracting a
floating point value from a date or timestamp is now supported.
</li><li>
When creating a BLOB with in InputStream or a CLOB with a Reader, and the InputStream or Reader
threw an non-IOException, then the LOB storage was broken when storing LOBs in the database.
...
...
h2/src/main/org/h2/tools/Console.java
浏览文件 @
82351d47
...
...
@@ -50,10 +50,12 @@ ShutdownHandler {
//## AWT begin ##
private
Frame
frame
;
private
boolean
trayIcon
;
private
boolean
trayIcon
Used
;
private
Font
font
;
private
Button
startBrowser
;
private
TextField
urlText
;
private
Object
tray
;
private
Object
trayIcon
;
//## AWT end ##
private
Server
web
,
tcp
,
pg
;
private
boolean
isWindows
;
...
...
@@ -229,16 +231,10 @@ ShutdownHandler {
}
/**
* INTERNAL
*/
public
void
shutdown
()
{
stopAll
();
}
/**
* INTERNAL.
* Stop all servers that were started using the console.
*/
void
stopAll
()
{
public
void
shutdown
()
{
if
(
web
!=
null
&&
web
.
isRunning
(
false
))
{
web
.
stop
();
web
=
null
;
...
...
@@ -256,8 +252,21 @@ ShutdownHandler {
frame
.
dispose
();
frame
=
null
;
}
if
(
trayIconUsed
)
{
try
{
// tray.remove(trayIcon);
Utils
.
callMethod
(
tray
,
"remove"
,
trayIcon
);
}
catch
(
Exception
e
)
{
// ignore
}
finally
{
trayIcon
=
null
;
tray
=
null
;
trayIconUsed
=
false
;
}
System
.
gc
();
}
//## AWT end ##
System
.
exit
(
0
);
//
System.exit(0);
}
//## AWT begin ##
...
...
@@ -293,8 +302,8 @@ ShutdownHandler {
itemExit
.
addActionListener
(
this
);
menuConsole
.
add
(
itemExit
);
//
SystemTray
tray = SystemTray.getSystemTray();
Object
tray
=
Utils
.
callStaticMethod
(
"java.awt.SystemTray.getSystemTray"
);
// tray = SystemTray.getSystemTray();
tray
=
Utils
.
callStaticMethod
(
"java.awt.SystemTray.getSystemTray"
);
// Dimension d = tray.getTrayIconSize();
Dimension
d
=
(
Dimension
)
Utils
.
callMethod
(
tray
,
"getTrayIconSize"
);
...
...
@@ -309,16 +318,16 @@ ShutdownHandler {
}
Image
icon
=
loadImage
(
iconFile
);
//
TrayIcon ti
= new TrayIcon(image, "H2 Database Engine", menuConsole);
Object
ti
=
Utils
.
newInstance
(
"java.awt.TrayIcon"
,
icon
,
"H2 Database Engine"
,
menuConsole
);
//
trayIcon
= new TrayIcon(image, "H2 Database Engine", menuConsole);
trayIcon
=
Utils
.
newInstance
(
"java.awt.TrayIcon"
,
icon
,
"H2 Database Engine"
,
menuConsole
);
// t
i
.addMouseListener(this);
Utils
.
callMethod
(
t
i
,
"addMouseListener"
,
this
);
// t
rayIcon
.addMouseListener(this);
Utils
.
callMethod
(
t
rayIcon
,
"addMouseListener"
,
this
);
// tray.add(t
i
);
Utils
.
callMethod
(
tray
,
"add"
,
t
i
);
// tray.add(t
rayIcon
);
Utils
.
callMethod
(
tray
,
"add"
,
t
rayIcon
);
this
.
trayIcon
=
true
;
this
.
trayIcon
Used
=
true
;
return
true
;
}
catch
(
Exception
e
)
{
...
...
@@ -442,7 +451,7 @@ ShutdownHandler {
public
void
actionPerformed
(
ActionEvent
e
)
{
String
command
=
e
.
getActionCommand
();
if
(
"exit"
.
equals
(
command
))
{
s
topAll
();
s
hutdown
();
}
else
if
(
"console"
.
equals
(
command
))
{
startBrowser
();
}
else
if
(
"status"
.
equals
(
command
))
{
...
...
@@ -506,11 +515,11 @@ ShutdownHandler {
*/
//## AWT begin ##
public
void
windowClosing
(
WindowEvent
e
)
{
if
(
trayIcon
)
{
if
(
trayIcon
Used
)
{
frame
.
dispose
();
frame
=
null
;
}
else
{
s
topAll
();
s
hutdown
();
}
}
//## AWT end ##
...
...
h2/src/test/org/h2/test/unit/TestTools.java
浏览文件 @
82351d47
...
...
@@ -26,12 +26,14 @@ import java.sql.Types;
import
java.util.ArrayList
;
import
java.util.Random
;
import
org.h2.constant.ErrorCode
;
import
org.h2.constant.SysProperties
;
import
org.h2.store.FileLister
;
import
org.h2.store.fs.FileSystem
;
import
org.h2.test.TestBase
;
import
org.h2.test.trace.Player
;
import
org.h2.tools.Backup
;
import
org.h2.tools.ChangeFileEncryption
;
import
org.h2.tools.Console
;
import
org.h2.tools.ConvertTraceFile
;
import
org.h2.tools.DeleteDbFiles
;
import
org.h2.tools.Recover
;
...
...
@@ -49,6 +51,7 @@ import org.h2.util.Task;
*/
public
class
TestTools
extends
TestBase
{
private
static
String
lastUrl
;
private
Server
server
;
/**
...
...
@@ -65,6 +68,7 @@ public class TestTools extends TestBase {
return
;
}
org
.
h2
.
Driver
.
load
();
testConsole
();
testJdbcDriverUtils
();
testWrongServer
();
deleteDb
(
"utils"
);
...
...
@@ -90,6 +94,34 @@ public class TestTools extends TestBase {
IOUtils
.
delete
(
getBaseDir
()
+
"/b2.zip"
);
}
private
void
testConsole
()
throws
Exception
{
String
old
=
System
.
getProperty
(
SysProperties
.
H2_BROWSER
);
Console
c
=
new
Console
();
c
.
setOut
(
new
PrintStream
(
new
ByteArrayOutputStream
()));
try
{
lastUrl
=
"-"
;
System
.
setProperty
(
SysProperties
.
H2_BROWSER
,
"call:"
+
TestTools
.
class
.
getName
()
+
".openBrowser"
);
c
.
runTool
(
"-web"
,
"-webPort"
,
"9002"
,
"-tool"
,
"-browser"
,
"-tcp"
,
"-tcpPort"
,
"9003"
,
"-pg"
,
"-pgPort"
,
"9004"
,
"-browser"
,
"-quiet"
);
c
.
shutdown
();
assertContains
(
lastUrl
,
":9002"
);
}
finally
{
if
(
old
!=
null
)
{
System
.
setProperty
(
SysProperties
.
H2_BROWSER
,
old
);
}
else
{
System
.
clearProperty
(
SysProperties
.
H2_BROWSER
);
}
}
}
/**
* This method is called via reflection.
*
* @param url the browser url
*/
public
static
void
openBrowser
(
String
url
)
{
lastUrl
=
url
;
}
private
void
testSimpleResultSet
()
throws
Exception
{
SimpleResultSet
rs
;
rs
=
new
SimpleResultSet
();
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论