Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
梦中观雨
cat
提交
3402d929
C
cat
项目概览
梦中观雨
/
cat
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
cat
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
3402d929
编写于
11月 22, 2013
作者:
Y
yong.you
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
modify the HtmlMessageCodecTest
上级
17e2e294
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
41 addition
and
32 deletion
+41
-32
cat-core/src/test/java/com/dianping/cat/message/spi/core/HtmlMessageCodecTest.java
...m/dianping/cat/message/spi/core/HtmlMessageCodecTest.java
+35
-21
cat-core/src/test/resources/com/dianping/cat/message/spi/core/MessageTree.txt
...sources/com/dianping/cat/message/spi/core/MessageTree.txt
+6
-11
未找到文件。
cat-core/src/test/java/com/dianping/cat/message/spi/core/HtmlMessageCodecTest.java
浏览文件 @
3402d929
...
...
@@ -13,15 +13,16 @@ import org.junit.runners.JUnit4;
import
org.unidal.lookup.ComponentTestCase
;
import
org.unidal.webres.helper.Files
;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.message.Event
;
import
com.dianping.cat.message.Heartbeat
;
import
com.dianping.cat.message.Message
;
import
com.dianping.cat.message.Metric
;
import
com.dianping.cat.message.Trace
;
import
com.dianping.cat.message.Transaction
;
import
com.dianping.cat.message.internal.AbstractMessage
;
import
com.dianping.cat.message.internal.DefaultEvent
;
import
com.dianping.cat.message.internal.DefaultHeartbeat
;
import
com.dianping.cat.message.internal.DefaultMetric
;
import
com.dianping.cat.message.internal.DefaultTrace
;
import
com.dianping.cat.message.internal.DefaultTransaction
;
import
com.dianping.cat.message.spi.MessageCodec
;
...
...
@@ -33,24 +34,18 @@ public class HtmlMessageCodecTest extends ComponentTestCase {
private
DefaultMessageTree
buildMessageTree
()
{
long
timestamp
=
1325489621987L
;
Transaction
transaction
=
Cat
.
newTransaction
(
"transaction"
,
"transaction"
);
Cat
.
logTrace
(
"logTrace"
,
"<trace>"
);
Cat
.
logTrace
(
"logTrace"
,
"<trace>"
,
Trace
.
SUCCESS
,
"data"
);
Cat
.
logMetric
(
"logMetric"
,
"test"
,
"test"
);
Cat
.
logMetricForCount
(
"logMetricForCount"
);
Cat
.
logMetricForCount
(
"logMetricForCount"
,
4
);
Cat
.
logMetricForDuration
(
"logMetricForDuration"
,
100
);
Cat
.
logMetricForSum
(
"logMetricForSum"
,
100
);
Cat
.
logMetricForSum
(
"logMetricForSum"
,
100
,
100
);
Cat
.
logEvent
(
"RemoteLink"
,
"Call"
,
Message
.
SUCCESS
,
"Cat-0a010680-384736-2061"
);
Cat
.
logEvent
(
"EventType"
,
"EventName"
);
Cat
.
logHeartbeat
(
"logHeartbeat"
,
"logHeartbeat"
,
Message
.
SUCCESS
,
null
);
DefaultMessageTree
tree
=
(
DefaultMessageTree
)
Cat
.
getManager
().
getThreadLocalMessageTree
();
((
DefaultTransaction
)
transaction
).
setDurationInMicros
(
8000
);
((
DefaultTransaction
)
transaction
).
setTimestamp
(
timestamp
);
Transaction
transaction
=
newTransaction
(
"transaction"
,
"transaction"
,
timestamp
,
Message
.
SUCCESS
,
8000
,
null
);
transaction
.
addChild
(
newTrace
(
"logTrace"
,
"<trace>"
,
timestamp
,
Trace
.
SUCCESS
,
null
));
transaction
.
addChild
(
newTrace
(
"logTrace"
,
"<trace>"
,
timestamp
,
Trace
.
SUCCESS
,
"data"
));
transaction
.
addChild
(
newEvent
(
"logEvent"
,
"<event>"
,
timestamp
,
Trace
.
SUCCESS
,
"data"
));
transaction
.
addChild
(
newEvent
(
"RemoteLink"
,
"<event>"
,
timestamp
,
Trace
.
SUCCESS
,
"data"
));
transaction
.
addChild
(
newMetric
(
"logEvent"
,
"<event>"
,
timestamp
,
Trace
.
SUCCESS
,
"data"
));
transaction
.
addChild
(
newHeartbeat
(
"logHeartbeat"
,
"<event>"
,
timestamp
,
Trace
.
SUCCESS
,
"data"
));
DefaultMessageTree
tree
=
new
DefaultMessageTree
();
tree
.
setMessage
(
transaction
);
String
messageId
=
"Cat-0a010680-384736-2061"
;
String
parentMessageId
=
"Cat-0a010680-384736-2062"
;
...
...
@@ -95,6 +90,15 @@ public class HtmlMessageCodecTest extends ComponentTestCase {
return
event
;
}
private
Metric
newMetric
(
String
type
,
String
name
,
long
timestamp
,
String
status
,
String
data
)
{
DefaultMetric
metric
=
new
DefaultMetric
(
type
,
name
);
metric
.
setStatus
(
status
);
metric
.
addData
(
data
);
metric
.
setTimestamp
(
timestamp
);
return
metric
;
}
private
Heartbeat
newHeartbeat
(
String
type
,
String
name
,
long
timestamp
,
String
status
,
String
data
)
{
DefaultHeartbeat
heartbeat
=
new
DefaultHeartbeat
(
type
,
name
);
...
...
@@ -142,7 +146,6 @@ public class HtmlMessageCodecTest extends ComponentTestCase {
}
@Test
@Ignore
public
void
testEncode
()
throws
Exception
{
MessageTree
tree
=
buildMessageTree
();
HtmlMessageCodec
codec
=
(
HtmlMessageCodec
)
lookup
(
MessageCodec
.
class
,
"html"
);
...
...
@@ -152,7 +155,7 @@ public class HtmlMessageCodecTest extends ComponentTestCase {
String
content
=
Files
.
forIO
().
readFrom
(
HtmlMessageCodecTest
.
class
.
getResourceAsStream
(
"MessageTree.txt"
),
"utf-8"
);
Assert
.
assertEquals
(
content
.
trim
(),
tree
.
toString
().
trim
());
Assert
.
assertEquals
(
1
929
,
buf
.
readableBytes
());
Assert
.
assertEquals
(
1
237
,
buf
.
readableBytes
());
}
@Test
...
...
@@ -166,6 +169,17 @@ public class HtmlMessageCodecTest extends ComponentTestCase {
"<tr><td>E15:33:41.987</td><td>type</td><td>name</td><td> </td><td>here is the data.</td></tr>\r\n"
);
}
@Test
public
void
testMetric
()
throws
Exception
{
long
timestamp
=
1325489621987L
;
Metric
Metric
=
newMetric
(
"type"
,
"name"
,
timestamp
,
"0"
,
"here is the data."
);
MessageTree
tree
=
new
DefaultMessageTree
();
tree
.
setMessage
(
Metric
);
check
(
tree
,
Metric
,
"<tr><td>M15:33:41.987</td><td>type</td><td>name</td><td> </td><td>here is the data.</td></tr>\r\n"
);
}
@Test
public
void
testEventForRawData
()
throws
Exception
{
long
timestamp
=
1325489621987L
;
...
...
cat-core/src/test/resources/com/dianping/cat/message/spi/core/MessageTree.txt
浏览文件 @
3402d929
PT1
Cat localhost-cat 192.168.1.1 main 1 main Cat-c0a80746-384747-36441
Cat-0a010680-384736-2062 Cat-0a010680-384736-2061 null
PT1
null localhost-cat 192.168.1.1 null null null null
Cat-0a010680-384736-2062 Cat-0a010680-384736-2061 null
t2012-01-02 15:33:41.987 transaction transaction
L2012-01-02 15:33:41.987 logTrace <trace> 0
L2012-01-02 15:33:41.987 logTrace <trace> 0 data
M2012-01-02 15:33:41.987 logMetric 0 test=test
M2012-01-02 15:33:41.987 logMetricForCount C 1
M2012-01-02 15:33:41.987 logMetricForCount C 4
M2012-01-02 15:33:41.987 logMetricForDuration T 100
M2012-01-02 15:33:41.987 logMetricForSum S 100.00
M2012-01-02 15:33:41.987 logMetricForSum S,C 100.00,100
E2012-01-02 15:33:41.987 RemoteLink Call 0 Cat-0a010680-384736-2061
E2012-01-02 15:33:41.987 EventType EventName 0
H2012-01-02 15:33:41.987 logHeartbeat logHeartbeat 0
T2012-01-02 15:33:41.995 transaction transaction unset 8000us
\ No newline at end of file
E2012-01-02 15:33:41.987 logEvent <event> 0 data
E2012-01-02 15:33:41.987 RemoteLink <event> 0 data
M2012-01-02 15:33:41.987 logEvent <event> 0 data
H2012-01-02 15:33:41.987 logHeartbeat <event> 0 data
T2012-01-02 15:33:49.987 transaction transaction 0 8000000us
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录