Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
91f283da
提交
91f283da
authored
12月 20, 2010
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Improve code coverage.
上级
b95ea354
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
112 行增加
和
7 行删除
+112
-7
changelog.html
h2/src/docsrc/html/changelog.html
+2
-1
TraceSystem.java
h2/src/main/org/h2/message/TraceSystem.java
+14
-3
TestAll.java
h2/src/test/org/h2/test/TestAll.java
+4
-2
TestConnectionInfo.java
h2/src/test/org/h2/test/unit/TestConnectionInfo.java
+24
-1
TestTraceSystem.java
h2/src/test/org/h2/test/unit/TestTraceSystem.java
+68
-0
没有找到文件。
h2/src/docsrc/html/changelog.html
浏览文件 @
91f283da
...
...
@@ -18,7 +18,8 @@ Change Log
<h1>
Change Log
</h1>
<h2>
Next Version (unreleased)
</h2>
<ul><li>
The org.h2.tools.Console no longer calls System.exit on shutdown
<ul><li>
The SLF4J 1.6 API is now used by default (this should not have any user visible effect).
</li><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.
...
...
h2/src/main/org/h2/message/TraceSystem.java
浏览文件 @
91f283da
...
...
@@ -7,6 +7,7 @@
package
org
.
h2
.
message
;
import
java.io.IOException
;
import
java.io.PrintStream
;
import
java.io.PrintWriter
;
import
java.io.Writer
;
import
java.sql.DriverManager
;
...
...
@@ -92,6 +93,7 @@ public class TraceSystem implements TraceWriter {
private
boolean
closed
;
private
boolean
writingErrorLogged
;
private
TraceWriter
writer
=
this
;
private
PrintStream
sysOut
=
System
.
out
;
/**
* Create a new trace system object.
...
...
@@ -107,6 +109,15 @@ public class TraceSystem implements TraceWriter {
levelMax
=
Math
.
max
(
levelSystemOut
,
levelFile
);
}
/**
* Set the print stream to use instead of System.out.
*
* @param out the new print stream
*/
public
void
setSysOut
(
PrintStream
out
)
{
this
.
sysOut
=
out
;
}
/**
* Write the exception to the driver manager log writer if configured.
*
...
...
@@ -220,9 +231,9 @@ public class TraceSystem implements TraceWriter {
if
(
level
<=
levelSystemOut
||
level
>
this
.
levelMax
)
{
// level <= levelSystemOut: the system out level is set higher
// level > this.level: the level for this module is set higher
System
.
o
ut
.
println
(
format
(
module
,
s
));
sysO
ut
.
println
(
format
(
module
,
s
));
if
(
t
!=
null
&&
levelSystemOut
==
DEBUG
)
{
t
.
printStackTrace
();
t
.
printStackTrace
(
sysOut
);
}
}
if
(
fileName
!=
null
)
{
...
...
@@ -279,7 +290,7 @@ public class TraceSystem implements TraceWriter {
Exception
se
=
DbException
.
get
(
ErrorCode
.
TRACE_FILE_ERROR_2
,
e
,
fileName
,
e
.
toString
());
// print this error only once
fileName
=
null
;
System
.
o
ut
.
println
(
se
);
sysO
ut
.
println
(
se
);
se
.
printStackTrace
();
}
...
...
h2/src/test/org/h2/test/TestAll.java
浏览文件 @
91f283da
...
...
@@ -116,6 +116,7 @@ import org.h2.test.unit.TestBitField;
import
org.h2.test.unit.TestCache
;
import
org.h2.test.unit.TestClearReferences
;
import
org.h2.test.unit.TestCompress
;
import
org.h2.test.unit.TestConnectionInfo
;
import
org.h2.test.unit.TestDataPage
;
import
org.h2.test.unit.TestDate
;
import
org.h2.test.unit.TestDateIso8601
;
...
...
@@ -128,6 +129,7 @@ import org.h2.test.unit.TestFtp;
import
org.h2.test.unit.TestIntArray
;
import
org.h2.test.unit.TestIntIntHashMap
;
import
org.h2.test.unit.TestJmx
;
import
org.h2.test.unit.TestTraceSystem
;
import
org.h2.test.unit.TestMathUtils
;
import
org.h2.test.unit.TestNetUtils
;
import
org.h2.test.unit.TestOldVersion
;
...
...
@@ -154,7 +156,6 @@ import org.h2.test.unit.TestValueMemory;
import
org.h2.test.utils.OutputCatcher
;
import
org.h2.test.utils.RecordingFileSystem
;
import
org.h2.test.utils.SelfDestructor
;
import
org.h2.test.db.TestConnectionInfo
;
import
org.h2.tools.DeleteDbFiles
;
import
org.h2.tools.Server
;
import
org.h2.util.Profiler
;
...
...
@@ -535,7 +536,6 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1`
new
TestCases
().
runTest
(
this
);
new
TestCheckpoint
().
runTest
(
this
);
new
TestCluster
().
runTest
(
this
);
new
TestConnectionInfo
().
runTest
(
this
);
new
TestCompatibility
().
runTest
(
this
);
new
TestCsv
().
runTest
(
this
);
new
TestDeadlock
().
runTest
(
this
);
...
...
@@ -638,6 +638,7 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1`
new
TestCache
().
runTest
(
this
);
new
TestClearReferences
().
runTest
(
this
);
new
TestCompress
().
runTest
(
this
);
new
TestConnectionInfo
().
runTest
(
this
);
new
TestDataPage
().
runTest
(
this
);
new
TestDate
().
runTest
(
this
);
new
TestDateIso8601
().
runTest
(
this
);
...
...
@@ -670,6 +671,7 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1`
new
TestStringCache
().
runTest
(
this
);
new
TestStringUtils
().
runTest
(
this
);
new
TestTools
().
runTest
(
this
);
new
TestTraceSystem
().
runTest
(
this
);
new
TestUpgrade
().
runTest
(
this
);
new
TestUtils
().
runTest
(
this
);
new
TestValue
().
runTest
(
this
);
...
...
h2/src/test/org/h2/test/
db
/TestConnectionInfo.java
→
h2/src/test/org/h2/test/
unit
/TestConnectionInfo.java
浏览文件 @
91f283da
...
...
@@ -4,11 +4,14 @@
* (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package
org
.
h2
.
test
.
db
;
package
org
.
h2
.
test
.
unit
;
import
org.h2.test.TestBase
;
import
org.h2.constant.ErrorCode
;
import
org.h2.engine.ConnectionInfo
;
import
java.sql.DriverManager
;
import
java.sql.SQLException
;
import
java.util.Properties
;
/**
...
...
@@ -28,6 +31,26 @@ public class TestConnectionInfo extends TestBase {
}
public
void
test
()
throws
Exception
{
testConnectInitError
();
testConnectionInfo
();
}
private
void
testConnectInitError
()
throws
Exception
{
try
{
DriverManager
.
getConnection
(
"jdbc:h2:mem:;init=error"
);
fail
();
}
catch
(
SQLException
e
)
{
assertEquals
(
ErrorCode
.
SYNTAX_ERROR_2
,
e
.
getErrorCode
());
}
try
{
DriverManager
.
getConnection
(
"jdbc:h2:mem:;init=runscript from 'wrong.file'"
);
fail
();
}
catch
(
SQLException
e
)
{
assertEquals
(
ErrorCode
.
IO_EXCEPTION_2
,
e
.
getErrorCode
());
}
}
private
void
testConnectionInfo
()
throws
Exception
{
Properties
info
=
new
Properties
();
ConnectionInfo
connectionInfo
=
new
ConnectionInfo
(
"jdbc:h2:mem:testdb"
+
...
...
h2/src/test/org/h2/test/unit/TestTraceSystem.java
0 → 100644
浏览文件 @
91f283da
/*
* Copyright 2004-2010 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
.
unit
;
import
java.io.ByteArrayOutputStream
;
import
java.io.PrintStream
;
import
org.h2.message.TraceSystem
;
import
org.h2.store.fs.FileSystem
;
import
org.h2.test.TestBase
;
import
org.h2.util.IOUtils
;
/**
* Tests the trace system
*/
public
class
TestTraceSystem
extends
TestBase
{
/**
* Run just this test.
*
* @param a ignored
*/
public
static
void
main
(
String
...
a
)
throws
Exception
{
TestBase
.
createCaller
().
init
().
test
();
}
public
void
test
()
throws
Exception
{
testTraceDebug
();
testReadOnly
();
testAdapter
();
}
private
void
testAdapter
()
{
TraceSystem
ts
=
new
TraceSystem
(
null
);
ts
.
setLevelFile
(
TraceSystem
.
ADAPTER
);
ts
.
getTrace
(
"test"
).
info
(
"test"
);
ts
.
close
();
}
private
void
testTraceDebug
()
{
TraceSystem
ts
=
new
TraceSystem
(
null
);
ByteArrayOutputStream
out
=
new
ByteArrayOutputStream
();
ts
.
setSysOut
(
new
PrintStream
(
out
));
ts
.
setLevelSystemOut
(
TraceSystem
.
DEBUG
);
ts
.
getTrace
(
"test"
).
debug
(
new
Exception
(
"error"
),
"test"
);
ts
.
close
();
String
outString
=
new
String
(
out
.
toByteArray
());
assertContains
(
outString
,
"error"
);
assertContains
(
outString
,
"Exception"
);
assertContains
(
outString
,
"test"
);
}
private
void
testReadOnly
()
throws
Exception
{
String
readOnlyFile
=
getBaseDir
()
+
"/readOnly.log"
;
IOUtils
.
delete
(
readOnlyFile
);
IOUtils
.
openFileOutputStream
(
readOnlyFile
,
false
).
close
();
FileSystem
.
getInstance
(
getBaseDir
()).
setReadOnly
(
readOnlyFile
);
TraceSystem
ts
=
new
TraceSystem
(
readOnlyFile
);
ts
.
setLevelFile
(
TraceSystem
.
INFO
);
ts
.
getTrace
(
"test"
).
info
(
"test"
);
IOUtils
.
delete
(
readOnlyFile
);
ts
.
close
();
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论