Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
阿信在这里
SkyWalking
提交
6e2ccfab
S
SkyWalking
项目概览
阿信在这里
/
SkyWalking
与 Fork 源项目一致
Fork自
山不在高_有仙则灵 / SkyWalking
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
SkyWalking
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6e2ccfab
编写于
2月 28, 2017
作者:
wu-sheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add a test case about System.out/err.
上级
a5f2aa1f
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
90 addition
and
9 deletion
+90
-9
pom.xml
pom.xml
+1
-0
skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/logging/EasyLogger.java
...ain/java/com/a/eye/skywalking/api/logging/EasyLogger.java
+1
-2
skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/logging/SyncFileWriter.java
...java/com/a/eye/skywalking/api/logging/SyncFileWriter.java
+3
-4
skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/logging/ThrowableFormatter.java
.../com/a/eye/skywalking/api/logging/ThrowableFormatter.java
+3
-3
skywalking-sniffer/skywalking-api/src/test/java/com/a/eye/skywalking/api/logging/STDOutWriterTest.java
...va/com/a/eye/skywalking/api/logging/STDOutWriterTest.java
+52
-0
skywalking-sniffer/skywalking-api/src/test/java/com/a/eye/skywalking/api/logging/ThrowableFormatterTest.java
.../a/eye/skywalking/api/logging/ThrowableFormatterTest.java
+18
-0
skywalking-sniffer/skywalking-api/src/test/java/com/a/eye/skywalking/api/plugin/bytebuddy/AllObjectDefaultMethodsMatchTest.java
...pi/plugin/bytebuddy/AllObjectDefaultMethodsMatchTest.java
+12
-0
未找到文件。
pom.xml
浏览文件 @
6e2ccfab
...
...
@@ -155,6 +155,7 @@
<instrumentation>
<excludes>
<exclude>
com/a/eye/skywalking/trace/proto/*.class
</exclude>
<exclude>
com/a/eye/skywalking/sniffer/mock/**/*.class
</exclude>
</excludes>
</instrumentation>
</configuration>
...
...
skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/logging/EasyLogger.java
浏览文件 @
6e2ccfab
package
com.a.eye.skywalking.api.logging
;
import
com.a.eye.skywalking.api.util.LoggingUtil
;
import
java.net.URLEncoder
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
...
...
@@ -32,7 +31,7 @@ public class EasyLogger implements ILog {
}
if
(
e
!=
null
)
{
WriterFactory
.
getLogWriter
().
writeError
(
LoggingUtil
.
fetchThrowableStack
(
e
));
WriterFactory
.
getLogWriter
().
writeError
(
ThrowableFormatter
.
format
(
e
));
}
}
...
...
skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/logging/SyncFileWriter.java
浏览文件 @
6e2ccfab
...
...
@@ -3,7 +3,6 @@ package com.a.eye.skywalking.api.logging;
import
com.a.eye.skywalking.api.conf.Config
;
import
com.a.eye.skywalking.api.util.LoggingUtil
;
import
java.io.File
;
import
java.io.FileNotFoundException
;
import
java.io.FileOutputStream
;
...
...
@@ -97,15 +96,15 @@ public class SyncFileWriter implements IWriter {
try
{
File
file
=
new
File
(
Config
.
Logging
.
LOG_DIR_NAME
,
Config
.
Logging
.
SYSTEM_ERROR_LOG_FILE_NAME
);
fileOutputStream
=
new
FileOutputStream
(
file
,
true
);
fileOutputStream
.
write
((
"Failed to init sync File Writer.\n"
+
LoggingUtil
.
fetchThrowableStack
(
e
)).
getBytes
());
fileOutputStream
.
write
((
"Failed to init sync File Writer.\n"
+
ThrowableFormatter
.
format
(
e
)).
getBytes
());
}
catch
(
Exception
e1
)
{
System
.
err
.
print
(
LoggingUtil
.
fetchThrowableStack
(
e1
));
System
.
err
.
print
(
ThrowableFormatter
.
format
(
e1
));
}
finally
{
if
(
fileOutputStream
!=
null
)
{
try
{
fileOutputStream
.
close
();
}
catch
(
IOException
e1
)
{
System
.
err
.
print
(
LoggingUtil
.
fetchThrowableStack
(
e1
));
System
.
err
.
print
(
ThrowableFormatter
.
format
(
e1
));
}
}
}
...
...
skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/
util/LoggingUtil
.java
→
skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/
logging/ThrowableFormatter
.java
浏览文件 @
6e2ccfab
package
com.a.eye.skywalking.api.
util
;
package
com.a.eye.skywalking.api.
logging
;
import
java.io.ByteArrayOutputStream
;
import
java.io.IOException
;
...
...
@@ -6,8 +6,8 @@ import java.io.IOException;
/**
* Created by xin on 16-6-24.
*/
public
class
LoggingUtil
{
public
static
String
f
etchThrowableStack
(
Throwable
e
)
{
public
class
ThrowableFormatter
{
public
static
String
f
ormat
(
Throwable
e
)
{
ByteArrayOutputStream
buf
=
new
ByteArrayOutputStream
();
e
.
printStackTrace
(
new
java
.
io
.
PrintWriter
(
buf
,
true
));
String
expMessage
=
buf
.
toString
();
...
...
skywalking-sniffer/skywalking-api/src/test/java/com/a/eye/skywalking/api/logging/STDOutWriterTest.java
0 → 100644
浏览文件 @
6e2ccfab
package
com.a.eye.skywalking.api.logging
;
import
java.io.PrintStream
;
import
org.junit.AfterClass
;
import
org.junit.BeforeClass
;
import
org.junit.Test
;
import
org.mockito.Mockito
;
import
static
org
.
mockito
.
Matchers
.
anyString
;
import
static
org
.
mockito
.
Mockito
.
times
;
/**
* Created by wusheng on 2017/2/28.
*/
public
class
STDOutWriterTest
{
private
static
PrintStream
outRef
;
private
static
PrintStream
errRef
;
@BeforeClass
public
static
void
initAndHoldOut
(){
outRef
=
System
.
out
;
errRef
=
System
.
err
;
}
@Test
public
void
testWrite
(){
PrintStream
mockStream
=
Mockito
.
mock
(
PrintStream
.
class
);
System
.
setOut
(
mockStream
);
STDOutWriter
writer
=
new
STDOutWriter
();
writer
.
write
(
"hello"
);
Mockito
.
verify
(
mockStream
,
times
(
1
)).
println
(
anyString
());
}
@Test
public
void
testWriteError
(){
PrintStream
mockStream
=
Mockito
.
mock
(
PrintStream
.
class
);
System
.
setErr
(
mockStream
);
STDOutWriter
writer
=
new
STDOutWriter
();
writer
.
writeError
(
"hello"
);
Mockito
.
verify
(
mockStream
,
times
(
1
)).
println
(
anyString
());
}
@AfterClass
public
static
void
reset
(){
System
.
setOut
(
outRef
);
System
.
setErr
(
errRef
);
}
}
skywalking-sniffer/skywalking-api/src/test/java/com/a/eye/skywalking/api/logging/ThrowableFormatterTest.java
0 → 100644
浏览文件 @
6e2ccfab
package
com.a.eye.skywalking.api.logging
;
import
org.junit.Assert
;
import
org.junit.Test
;
/**
* Created by wusheng on 2017/2/28.
*/
public
class
ThrowableFormatterTest
{
@Test
public
void
testFormat
(){
NullPointerException
exception
=
new
NullPointerException
();
String
formatLines
=
ThrowableFormatter
.
format
(
exception
);
String
[]
lines
=
formatLines
.
split
(
"\n"
);
Assert
.
assertEquals
(
"java.lang.NullPointerException"
,
lines
[
0
]);
Assert
.
assertEquals
(
"\tat com.a.eye.skywalking.api.logging.ThrowableFormatterTest.testFormat(ThrowableFormatterTest.java:12)"
,
lines
[
1
]);
}
}
skywalking-sniffer/skywalking-api/src/test/java/com/a/eye/skywalking/api/plugin/bytebuddy/AllObjectDefaultMethodsMatchTest.java
0 → 100644
浏览文件 @
6e2ccfab
package
com.a.eye.skywalking.api.plugin.bytebuddy
;
import
org.junit.Test
;
/**
* Created by wusheng on 2017/2/28.
*/
public
class
AllObjectDefaultMethodsMatchTest
{
@Test
public
void
testMatches
(){
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录