Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
梦中观雨
cat
提交
2c952ef9
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,发现更多精彩内容 >>
提交
2c952ef9
编写于
1月 28, 2012
作者:
F
Frankie Wu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix test cases
上级
460a1bb3
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
40 addition
and
23 deletion
+40
-23
cat-consumer/src/main/java/com/dianping/cat/consumer/failure/FailureReportAnalyzer.java
.../dianping/cat/consumer/failure/FailureReportAnalyzer.java
+1
-0
cat-consumer/src/test/java/com/dianping/cat/consumer/failure/FailureAnalyzerStoreTest.java
...anping/cat/consumer/failure/FailureAnalyzerStoreTest.java
+17
-0
cat-consumer/src/test/resources/com/dianping/cat/consumer/failure/failure.json
.../resources/com/dianping/cat/consumer/failure/failure.json
+15
-15
cat-core/src/main/java/com/dianping/cat/message/internal/DefaultMessageManager.java
.../dianping/cat/message/internal/DefaultMessageManager.java
+2
-7
cat-core/src/main/java/com/dianping/cat/message/spi/internal/DefaultMessagePathBuilder.java
...g/cat/message/spi/internal/DefaultMessagePathBuilder.java
+5
-1
未找到文件。
cat-consumer/src/main/java/com/dianping/cat/consumer/failure/FailureReportAnalyzer.java
浏览文件 @
2c952ef9
...
...
@@ -67,6 +67,7 @@ public class FailureReportAnalyzer extends AbstractMessageAnalyzer<FailureReport
if
(
m_handlers
==
null
)
{
m_handlers
=
new
ArrayList
<
FailureReportAnalyzer
.
Handler
>();
}
m_handlers
.
add
(
handler
);
}
...
...
cat-consumer/src/test/java/com/dianping/cat/consumer/failure/FailureAnalyzerStoreTest.java
浏览文件 @
2c952ef9
package
com.dianping.cat.consumer.failure
;
import
java.io.File
;
import
java.util.regex.Pattern
;
import
junit.framework.Assert
;
...
...
@@ -9,9 +10,11 @@ import org.junit.runner.RunWith;
import
org.junit.runners.JUnit4
;
import
com.dianping.cat.consumer.AnalyzerFactory
;
import
com.dianping.cat.consumer.failure.FailureReportAnalyzer.Handler
;
import
com.dianping.cat.consumer.failure.model.entity.FailureReport
;
import
com.dianping.cat.consumer.failure.model.transform.DefaultJsonBuilder
;
import
com.dianping.cat.message.internal.DefaultTransaction
;
import
com.dianping.cat.message.spi.MessagePathBuilder
;
import
com.dianping.cat.message.spi.MessageTree
;
import
com.dianping.cat.message.spi.internal.DefaultMessageTree
;
import
com.site.helper.Files
;
...
...
@@ -19,6 +22,16 @@ import com.site.lookup.ComponentTestCase;
@RunWith
(
JUnit4
.
class
)
public
class
FailureAnalyzerStoreTest
extends
ComponentTestCase
{
@Test
public
void
testLookup
()
throws
Exception
{
Handler
failure
=
lookup
(
Handler
.
class
,
"failure-handler"
);
Handler
longUrl
=
lookup
(
Handler
.
class
,
"long-url-handler"
);
// make sure all handlers could be looked up successfully
Assert
.
assertNotNull
(
failure
);
Assert
.
assertNotNull
(
longUrl
);
}
@Test
public
void
testJson
()
throws
Exception
{
long
current
=
1327470645035L
;
...
...
@@ -26,6 +39,7 @@ public class FailureAnalyzerStoreTest extends ComponentTestCase {
long
extraTime
=
5
*
60
*
1000
;
long
start
=
current
-
current
%
(
60
*
60
*
1000
);
MessagePathBuilder
pathBuilder
=
lookup
(
MessagePathBuilder
.
class
);
AnalyzerFactory
factory
=
lookup
(
AnalyzerFactory
.
class
);
FailureReportAnalyzer
analyzer
=
(
FailureReportAnalyzer
)
factory
.
create
(
"failure"
,
start
,
duration
,
"domain1"
,
extraTime
);
...
...
@@ -55,6 +69,9 @@ public class FailureAnalyzerStoreTest extends ComponentTestCase {
String
json
=
builder
.
getString
();
String
expected
=
Files
.
forIO
().
readFrom
(
getResourceFile
(
"failure.json"
),
"utf-8"
);
String
baseDir
=
pathBuilder
.
getLogViewBaseDir
().
toString
();
json
=
json
.
replaceAll
(
Pattern
.
quote
(
baseDir
),
"./target/catlog"
);
Assert
.
assertEquals
(
"Check json content!"
,
expected
.
replace
(
"\r"
,
""
),
json
.
replace
(
"\r"
,
""
));
}
...
...
cat-consumer/src/test/resources/com/dianping/cat/consumer/failure/failure.json
浏览文件 @
2c952ef9
...
...
@@ -25,19 +25,19 @@
"entries"
:
[
{
"type"
:
"LongUrl"
,
"path"
:
"file:
/Users/qmwu/project/tracking/cat-consumer/target/catlog/20120125/middleware/MessageId0
"
,
"path"
:
"file:
./target/catlog/20120125/13/middleware/MessageId0.html
"
,
"threadId"
:
"Thread0"
,
"text"
:
"A1B1"
},
{
"type"
:
"LongUrl"
,
"path"
:
"file:
/Users/qmwu/project/tracking/cat-consumer/target/catlog/20120125/middleware/MessageId0
"
,
"path"
:
"file:
./target/catlog/20120125/13/middleware/MessageId0.html
"
,
"threadId"
:
"Thread0"
,
"text"
:
"A1B1"
},
{
"type"
:
"LongUrl"
,
"path"
:
"file:
/Users/qmwu/project/tracking/cat-consumer/target/catlog/20120125/middleware/MessageId0
"
,
"path"
:
"file:
./target/catlog/20120125/13/middleware/MessageId0.html
"
,
"threadId"
:
"Thread0"
,
"text"
:
"A1B1"
}
...
...
@@ -48,19 +48,19 @@
"entries"
:
[
{
"type"
:
"LongUrl"
,
"path"
:
"file:
/Users/qmwu/project/tracking/cat-consumer/target/catlog/20120125/middleware/MessageId1
"
,
"path"
:
"file:
./target/catlog/20120125/13/middleware/MessageId1.html
"
,
"threadId"
:
"Thread1"
,
"text"
:
"A1B1"
},
{
"type"
:
"LongUrl"
,
"path"
:
"file:
/Users/qmwu/project/tracking/cat-consumer/target/catlog/20120125/middleware/MessageId1
"
,
"path"
:
"file:
./target/catlog/20120125/13/middleware/MessageId1.html
"
,
"threadId"
:
"Thread1"
,
"text"
:
"A1B1"
},
{
"type"
:
"LongUrl"
,
"path"
:
"file:
/Users/qmwu/project/tracking/cat-consumer/target/catlog/20120125/middleware/MessageId1
"
,
"path"
:
"file:
./target/catlog/20120125/13/middleware/MessageId1.html
"
,
"threadId"
:
"Thread1"
,
"text"
:
"A1B1"
}
...
...
@@ -71,19 +71,19 @@
"entries"
:
[
{
"type"
:
"LongUrl"
,
"path"
:
"file:
/Users/qmwu/project/tracking/cat-consumer/target/catlog/20120125/middleware/MessageId2
"
,
"path"
:
"file:
./target/catlog/20120125/13/middleware/MessageId2.html
"
,
"threadId"
:
"Thread2"
,
"text"
:
"A1B1"
},
{
"type"
:
"LongUrl"
,
"path"
:
"file:
/Users/qmwu/project/tracking/cat-consumer/target/catlog/20120125/middleware/MessageId2
"
,
"path"
:
"file:
./target/catlog/20120125/13/middleware/MessageId2.html
"
,
"threadId"
:
"Thread2"
,
"text"
:
"A1B1"
},
{
"type"
:
"LongUrl"
,
"path"
:
"file:
/Users/qmwu/project/tracking/cat-consumer/target/catlog/20120125/middleware/MessageId2
"
,
"path"
:
"file:
./target/catlog/20120125/13/middleware/MessageId2.html
"
,
"threadId"
:
"Thread2"
,
"text"
:
"A1B1"
}
...
...
@@ -94,19 +94,19 @@
"entries"
:
[
{
"type"
:
"LongUrl"
,
"path"
:
"file:
/Users/qmwu/project/tracking/cat-consumer/target/catlog/20120125/middleware/MessageId3
"
,
"path"
:
"file:
./target/catlog/20120125/13/middleware/MessageId3.html
"
,
"threadId"
:
"Thread3"
,
"text"
:
"A1B1"
},
{
"type"
:
"LongUrl"
,
"path"
:
"file:
/Users/qmwu/project/tracking/cat-consumer/target/catlog/20120125/middleware/MessageId3
"
,
"path"
:
"file:
./target/catlog/20120125/13/middleware/MessageId3.html
"
,
"threadId"
:
"Thread3"
,
"text"
:
"A1B1"
},
{
"type"
:
"LongUrl"
,
"path"
:
"file:
/Users/qmwu/project/tracking/cat-consumer/target/catlog/20120125/middleware/MessageId3
"
,
"path"
:
"file:
./target/catlog/20120125/13/middleware/MessageId3.html
"
,
"threadId"
:
"Thread3"
,
"text"
:
"A1B1"
}
...
...
@@ -117,19 +117,19 @@
"entries"
:
[
{
"type"
:
"LongUrl"
,
"path"
:
"file:
/Users/qmwu/project/tracking/cat-consumer/target/catlog/20120125/middleware/MessageId4
"
,
"path"
:
"file:
./target/catlog/20120125/13/middleware/MessageId4.html
"
,
"threadId"
:
"Thread4"
,
"text"
:
"A1B1"
},
{
"type"
:
"LongUrl"
,
"path"
:
"file:
/Users/qmwu/project/tracking/cat-consumer/target/catlog/20120125/middleware/MessageId4
"
,
"path"
:
"file:
./target/catlog/20120125/13/middleware/MessageId4.html
"
,
"threadId"
:
"Thread4"
,
"text"
:
"A1B1"
},
{
"type"
:
"LongUrl"
,
"path"
:
"file:
/Users/qmwu/project/tracking/cat-consumer/target/catlog/20120125/middleware/MessageId4
"
,
"path"
:
"file:
./target/catlog/20120125/13/middleware/MessageId4.html
"
,
"threadId"
:
"Thread4"
,
"text"
:
"A1B1"
}
...
...
cat-core/src/main/java/com/dianping/cat/message/internal/DefaultMessageManager.java
浏览文件 @
2c952ef9
...
...
@@ -48,11 +48,6 @@ public class DefaultMessageManager extends ContainerHolder implements MessageMan
}
void
flush
(
MessageTree
tree
)
{
// if (m_manager == null) {
// throw new
// RuntimeException("Cat has not been initialized successfully, please call Cat.initialize() first!");
// }
if
(
m_manager
!=
null
)
{
MessageSender
sender
=
m_manager
.
getSender
();
...
...
@@ -76,8 +71,8 @@ public class DefaultMessageManager extends ContainerHolder implements MessageMan
Context
ctx
=
m_context
.
get
();
if
(
ctx
==
null
)
{
throw
new
RuntimeException
(
"Cat has not been initialized successfully,
please call Cal.setup(...) first for each thread."
);
throw
new
RuntimeException
(
"Cat has not been initialized successfully, "
+
"
please call Cal.setup(...) first for each thread."
);
}
else
{
return
ctx
;
}
...
...
cat-core/src/main/java/com/dianping/cat/message/spi/internal/DefaultMessagePathBuilder.java
浏览文件 @
2c952ef9
...
...
@@ -46,7 +46,11 @@ public class DefaultMessagePathBuilder implements MessagePathBuilder, Initializa
@Override
public
void
initialize
()
throws
InitializationException
{
Config
config
=
m_manager
.
getClientConfig
();
if
(
config
==
null
)
{
config
=
new
Config
();
}
String
baseLogDir
=
config
.
getBaseLogDir
();
String
baseLogUrl
=
config
.
getBaseLogUrl
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录