Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
SkyWalking
提交
ebdfe399
S
SkyWalking
项目概览
apache
/
SkyWalking
上一次同步 大约 1 年
通知
302
Star
21345
Fork
6091
代码
文件
提交
分支
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,体验更适合开发者的 AI 搜索 >>
提交
ebdfe399
编写于
4月 11, 2017
作者:
P
pengys5
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix index testcase bug
上级
1668d8a3
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
54 addition
and
10 deletion
+54
-10
skywalking-collector/skywalking-collector-worker/src/test/java/com/a/eye/skywalking/collector/worker/storage/AbstractIndexTestCase.java
...lking/collector/worker/storage/AbstractIndexTestCase.java
+1
-1
skywalking-collector/skywalking-collector-worker/src/test/java/com/a/eye/skywalking/collector/worker/storage/IndexCreatorTestCase.java
...alking/collector/worker/storage/IndexCreatorTestCase.java
+53
-9
未找到文件。
skywalking-collector/skywalking-collector-worker/src/test/java/com/a/eye/skywalking/collector/worker/storage/AbstractIndexTestCase.java
浏览文件 @
ebdfe399
...
...
@@ -22,7 +22,7 @@ public class AbstractIndexTestCase {
@Test
public
void
testCreateSettingBuilder
()
throws
IOException
{
IndexTest
indexTest
=
new
IndexTest
();
Assert
.
assertEquals
(
"{\"index.number_of_shards\":
null,\"index.number_of_replicas\":null
}"
,
indexTest
.
createSettingBuilder
().
string
());
Assert
.
assertEquals
(
"{\"index.number_of_shards\":
\"\",\"index.number_of_replicas\":\"\"
}"
,
indexTest
.
createSettingBuilder
().
string
());
}
class
IndexTest
extends
AbstractIndex
{
...
...
skywalking-collector/skywalking-collector-worker/src/test/java/com/a/eye/skywalking/collector/worker/storage/IndexCreatorTestCase.java
浏览文件 @
ebdfe399
package
com.a.eye.skywalking.collector.worker.storage
;
import
com.a.eye.skywalking.collector.worker.config.EsConfig
;
import
org.elasticsearch.common.xcontent.XContentBuilder
;
import
org.elasticsearch.common.xcontent.XContentFactory
;
import
org.junit.Assert
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.mockito.Mockito
;
...
...
@@ -25,6 +27,21 @@ import static org.powermock.api.mockito.PowerMockito.*;
@PowerMockIgnore
({
"javax.management.*"
})
public
class
IndexCreatorTestCase
{
private
IndexCreator
indexCreator
;
private
TestIndex
testIndex
;
@Before
public
void
init
()
throws
Exception
{
testIndex
=
mock
(
TestIndex
.
class
);
indexCreator
=
mock
(
IndexCreator
.
class
);
doCallRealMethod
().
when
(
indexCreator
).
create
();
Set
<
AbstractIndex
>
indexSet
=
new
HashSet
<>();
indexSet
.
add
(
testIndex
);
when
(
indexCreator
,
"loadIndex"
).
thenReturn
(
indexSet
);
}
@Test
public
void
testLoadIndex
()
throws
Exception
{
IndexCreator
indexCreator
=
spy
(
IndexCreator
.
INSTANCE
);
...
...
@@ -47,20 +64,47 @@ public class IndexCreatorTestCase {
}
@Test
public
void
testCreate
()
throws
Exception
{
TestIndex
testIndex
=
mock
(
TestIndex
.
class
);
IndexCreator
indexCreator
=
mock
(
IndexCreator
.
class
);
doCallRealMethod
().
when
(
indexCreator
).
create
();
public
void
testCreateOptionOff
()
throws
Exception
{
EsConfig
.
Es
.
Index
.
create
=
EsConfig
.
Create_Off
;
indexCreator
.
create
();
Mockito
.
verify
(
testIndex
,
Mockito
.
never
()).
createIndex
();
Mockito
.
verify
(
testIndex
,
Mockito
.
never
()).
deleteIndex
();
}
Set
<
AbstractIndex
>
indexSet
=
new
HashSet
<>();
indexSet
.
add
(
testIndex
);
@Test
public
void
testCreateOptionOverWriteIndexIsExists
()
throws
Exception
{
EsConfig
.
Es
.
Index
.
create
=
EsConfig
.
Create_Overwrite
;
when
(
testIndex
.
isExists
()).
thenReturn
(
true
);
indexCreator
.
create
();
Mockito
.
verify
(
testIndex
).
createIndex
();
Mockito
.
verify
(
testIndex
).
deleteIndex
();
}
when
(
indexCreator
,
"loadIndex"
).
thenReturn
(
indexSet
);
@Test
public
void
testCreateOptionOverWriteIndexNotExists
()
throws
Exception
{
EsConfig
.
Es
.
Index
.
create
=
EsConfig
.
Create_Overwrite
;
when
(
testIndex
.
isExists
()).
thenReturn
(
false
);
indexCreator
.
create
();
Mockito
.
verify
(
testIndex
).
createIndex
();
Mockito
.
verify
(
testIndex
,
Mockito
.
never
()).
deleteIndex
();
}
@Test
public
void
testCreateOptionIgnoreIndexNotExists
()
throws
Exception
{
EsConfig
.
Es
.
Index
.
create
=
EsConfig
.
Create_Ignore
;
when
(
testIndex
.
isExists
()).
thenReturn
(
false
);
indexCreator
.
create
();
Mockito
.
verify
(
testIndex
).
createIndex
();
Mockito
.
verify
(
testIndex
).
deleteIndex
();
Mockito
.
verify
(
testIndex
,
Mockito
.
never
()).
deleteIndex
();
}
@Test
public
void
testCreateOptionIgnoreIndexExists
()
throws
Exception
{
EsConfig
.
Es
.
Index
.
create
=
EsConfig
.
Create_Ignore
;
when
(
testIndex
.
isExists
()).
thenReturn
(
true
);
indexCreator
.
create
();
Mockito
.
verify
(
testIndex
,
Mockito
.
never
()).
createIndex
();
Mockito
.
verify
(
testIndex
,
Mockito
.
never
()).
deleteIndex
();
}
class
TestIndex
extends
AbstractIndex
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录