Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
javalover123888
SkyWalking
提交
a03e6cb2
S
SkyWalking
项目概览
javalover123888
/
SkyWalking
与 Fork 源项目一致
Fork自
山不在高_有仙则灵 / SkyWalking
通知
2
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,发现更多精彩内容 >>
提交
a03e6cb2
编写于
11月 01, 2017
作者:
wu-sheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add test cases for core module.
上级
4e524de1
变更
14
隐藏空白更改
内联
并排
Showing
14 changed file
with
429 addition
and
0 deletion
+429
-0
apm-collector/apm-collector-core/src/test/java/org/skywalking/apm/collector/core/data/AbstractHashMessageTest.java
...king/apm/collector/core/data/AbstractHashMessageTest.java
+40
-0
apm-collector/apm-collector-core/src/test/java/org/skywalking/apm/collector/core/define/DefinitionLoaderTest.java
...lking/apm/collector/core/define/DefinitionLoaderTest.java
+40
-0
apm-collector/apm-collector-core/src/test/java/org/skywalking/apm/collector/core/define/ServiceImpl.java
...org/skywalking/apm/collector/core/define/ServiceImpl.java
+25
-0
apm-collector/apm-collector-core/src/test/java/org/skywalking/apm/collector/core/define/ServiceInterface.java
...kywalking/apm/collector/core/define/ServiceInterface.java
+25
-0
apm-collector/apm-collector-core/src/test/java/org/skywalking/apm/collector/core/define/TestDefineFile.java
.../skywalking/apm/collector/core/define/TestDefineFile.java
+28
-0
apm-collector/apm-collector-core/src/test/java/org/skywalking/apm/collector/core/util/BytesUtilsTest.java
...rg/skywalking/apm/collector/core/util/BytesUtilsTest.java
+32
-0
apm-collector/apm-collector-core/src/test/java/org/skywalking/apm/collector/core/util/CollectionUtilsTest.java
...ywalking/apm/collector/core/util/CollectionUtilsTest.java
+51
-0
apm-collector/apm-collector-core/src/test/java/org/skywalking/apm/collector/core/util/ColumnNameUtilsTest.java
...ywalking/apm/collector/core/util/ColumnNameUtilsTest.java
+33
-0
apm-collector/apm-collector-core/src/test/java/org/skywalking/apm/collector/core/util/ObjectUtilsTest.java
...g/skywalking/apm/collector/core/util/ObjectUtilsTest.java
+33
-0
apm-collector/apm-collector-core/src/test/java/org/skywalking/apm/collector/core/util/ResourceUtilsTest.java
...skywalking/apm/collector/core/util/ResourceUtilsTest.java
+42
-0
apm-collector/apm-collector-core/src/test/java/org/skywalking/apm/collector/core/util/StringUtilsTest.java
...g/skywalking/apm/collector/core/util/StringUtilsTest.java
+35
-0
apm-collector/apm-collector-core/src/test/java/org/skywalking/apm/collector/core/util/TimeBucketUtilsTest.java
...ywalking/apm/collector/core/util/TimeBucketUtilsTest.java
+43
-0
apm-collector/apm-collector-core/src/test/resources/META-INF/defines/test_define.define
...re/src/test/resources/META-INF/defines/test_define.define
+1
-0
apm-collector/apm-collector-core/src/test/resources/TestResourceFile.txt
...pm-collector-core/src/test/resources/TestResourceFile.txt
+1
-0
未找到文件。
apm-collector/apm-collector-core/src/test/java/org/skywalking/apm/collector/core/data/AbstractHashMessageTest.java
0 → 100644
浏览文件 @
a03e6cb2
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.core.data
;
import
org.junit.Assert
;
import
org.junit.Test
;
import
org.skywalking.apm.collector.core.data.AbstractHashMessage
;
/**
* @author wu-sheng
*/
public
class
AbstractHashMessageTest
{
public
class
NewMessage
extends
AbstractHashMessage
{
public
NewMessage
()
{
super
(
"key"
);
}
}
@Test
public
void
testHash
()
{
NewMessage
message
=
new
NewMessage
();
Assert
.
assertEquals
(
"key"
.
hashCode
(),
message
.
getHashCode
());
}
}
apm-collector/apm-collector-core/src/test/java/org/skywalking/apm/collector/core/define/DefinitionLoaderTest.java
0 → 100644
浏览文件 @
a03e6cb2
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.core.define
;
import
java.util.Iterator
;
import
org.junit.Assert
;
import
org.junit.Test
;
/**
* @author wu-sheng
*/
public
class
DefinitionLoaderTest
{
@Test
public
void
testLoad
()
{
TestDefineFile
define
=
new
TestDefineFile
();
DefinitionLoader
<
ServiceInterface
>
definitionLoader
=
new
DefinitionLoader
<>(
ServiceInterface
.
class
,
define
);
Iterator
<
ServiceInterface
>
iterator
=
definitionLoader
.
iterator
();
if
(
iterator
.
hasNext
())
{
ServiceInterface
service
=
iterator
.
next
();
Assert
.
assertTrue
(
service
instanceof
ServiceInterface
);
Assert
.
assertTrue
(
service
instanceof
ServiceImpl
);
}
}
}
apm-collector/apm-collector-core/src/test/java/org/skywalking/apm/collector/core/define/ServiceImpl.java
0 → 100644
浏览文件 @
a03e6cb2
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.core.define
;
/**
* @author wu-sheng
*/
public
class
ServiceImpl
implements
ServiceInterface
{
}
apm-collector/apm-collector-core/src/test/java/org/skywalking/apm/collector/core/define/ServiceInterface.java
0 → 100644
浏览文件 @
a03e6cb2
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.core.define
;
/**
* @author wu-sheng
*/
public
interface
ServiceInterface
{
}
apm-collector/apm-collector-core/src/test/java/org/skywalking/apm/collector/core/define/TestDefineFile.java
0 → 100644
浏览文件 @
a03e6cb2
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.core.define
;
/**
* @author wu-sheng
*/
public
class
TestDefineFile
extends
DefinitionFile
{
@Override
protected
String
fileName
()
{
return
"test_define.define"
;
}
}
apm-collector/apm-collector-core/src/test/java/org/skywalking/apm/collector/core/util/BytesUtilsTest.java
0 → 100644
浏览文件 @
a03e6cb2
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.core.util
;
import
org.junit.Assert
;
import
org.junit.Test
;
/**
* @author wu-sheng
*/
public
class
BytesUtilsTest
{
@Test
public
void
testLong2Bytes
()
{
Assert
.
assertEquals
(
655390L
,
BytesUtils
.
bytes2Long
(
BytesUtils
.
long2Bytes
(
655390L
)));
}
}
apm-collector/apm-collector-core/src/test/java/org/skywalking/apm/collector/core/util/CollectionUtilsTest.java
0 → 100644
浏览文件 @
a03e6cb2
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.core.util
;
import
java.util.HashMap
;
import
java.util.LinkedList
;
import
java.util.List
;
import
java.util.Map
;
import
org.junit.Assert
;
import
org.junit.Test
;
/**
* @author wu-sheng
*/
public
class
CollectionUtilsTest
{
@Test
public
void
testList
()
{
List
<
String
>
list
=
new
LinkedList
<>();
Assert
.
assertTrue
(
CollectionUtils
.
isEmpty
(
list
));
Assert
.
assertFalse
(
CollectionUtils
.
isNotEmpty
(
list
));
}
@Test
public
void
testMap
()
{
Map
<
String
,
String
>
map
=
new
HashMap
<>();
Assert
.
assertTrue
(
CollectionUtils
.
isEmpty
(
map
));
Assert
.
assertFalse
(
CollectionUtils
.
isNotEmpty
(
map
));
}
@Test
public
void
testArray
()
{
String
[]
array
=
new
String
[]
{
"abc"
};
Assert
.
assertTrue
(
CollectionUtils
.
isNotEmpty
(
array
));
}
}
apm-collector/apm-collector-core/src/test/java/org/skywalking/apm/collector/core/util/ColumnNameUtilsTest.java
0 → 100644
浏览文件 @
a03e6cb2
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.core.util
;
import
org.junit.Assert
;
import
org.junit.Test
;
/**
* @author wu-sheng
*/
public
class
ColumnNameUtilsTest
{
@Test
public
void
testRename
()
{
Assert
.
assertEquals
(
"newAttributeNameFromColumnName"
,
ColumnNameUtils
.
INSTANCE
.
rename
(
"new_attribute_name_from_column_name"
));
}
}
apm-collector/apm-collector-core/src/test/java/org/skywalking/apm/collector/core/util/ObjectUtilsTest.java
0 → 100644
浏览文件 @
a03e6cb2
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.core.util
;
import
org.junit.Assert
;
import
org.junit.Test
;
/**
* @author wu-sheng
*/
public
class
ObjectUtilsTest
{
@Test
public
void
testNullObject
()
{
Object
o
=
new
Object
();
Assert
.
assertTrue
(
ObjectUtils
.
isNotEmpty
(
o
));
}
}
apm-collector/apm-collector-core/src/test/java/org/skywalking/apm/collector/core/util/ResourceUtilsTest.java
0 → 100644
浏览文件 @
a03e6cb2
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.core.util
;
import
java.io.BufferedReader
;
import
java.io.IOException
;
import
java.io.Reader
;
import
org.junit.Assert
;
import
org.junit.Test
;
/**
* @author wu-sheng
*/
public
class
ResourceUtilsTest
{
@Test
public
void
testGetResource
()
throws
IOException
{
Reader
read
=
ResourceUtils
.
read
(
"TestResourceFile.txt"
);
try
{
BufferedReader
reader
=
new
BufferedReader
(
read
);
String
line1
=
reader
.
readLine
();
Assert
.
assertEquals
(
"skywalking"
,
line1
);
}
finally
{
read
.
close
();
}
}
}
apm-collector/apm-collector-core/src/test/java/org/skywalking/apm/collector/core/util/StringUtilsTest.java
0 → 100644
浏览文件 @
a03e6cb2
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.core.util
;
import
org.junit.Assert
;
import
org.junit.Test
;
/**
* @author wu-sheng
*/
public
class
StringUtilsTest
{
@Test
public
void
testEmptyString
()
{
Assert
.
assertTrue
(
StringUtils
.
isEmpty
(
null
));
Assert
.
assertTrue
(
StringUtils
.
isEmpty
(
""
));
Assert
.
assertTrue
(
StringUtils
.
isNotEmpty
(
"abc"
));
}
}
apm-collector/apm-collector-core/src/test/java/org/skywalking/apm/collector/core/util/TimeBucketUtilsTest.java
0 → 100644
浏览文件 @
a03e6cb2
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.core.util
;
import
org.junit.Assert
;
import
org.junit.Test
;
/**
* @author wu-sheng
*/
public
class
TimeBucketUtilsTest
{
@Test
public
void
testGetInfoFromATimestamp
()
{
long
timeMillis
=
1509521745220L
;
Assert
.
assertArrayEquals
(
new
long
[]
{
20171101153545L
,
20171101153544L
,
20171101153543L
,
20171101153542L
,
20171101153541L
},
TimeBucketUtils
.
INSTANCE
.
getFiveSecondTimeBuckets
(
TimeBucketUtils
.
INSTANCE
.
getSecondTimeBucket
(
timeMillis
)));
Assert
.
assertEquals
(
20171101153545L
,
TimeBucketUtils
.
INSTANCE
.
getSecondTimeBucket
(
timeMillis
));
Assert
.
assertEquals
(
201711011535L
,
TimeBucketUtils
.
INSTANCE
.
getMinuteTimeBucket
(
timeMillis
));
Assert
.
assertEquals
(
201711011500L
,
TimeBucketUtils
.
INSTANCE
.
getHourTimeBucket
(
timeMillis
));
Assert
.
assertEquals
(
201711010000L
,
TimeBucketUtils
.
INSTANCE
.
getDayTimeBucket
(
timeMillis
));
}
}
apm-collector/apm-collector-core/src/test/resources/META-INF/defines/test_define.define
0 → 100644
浏览文件 @
a03e6cb2
org.skywalking.apm.collector.core.define.ServiceImpl
\ No newline at end of file
apm-collector/apm-collector-core/src/test/resources/TestResourceFile.txt
0 → 100644
浏览文件 @
a03e6cb2
skywalking
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录