Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
Shardingsphere
提交
299aab35
Shardingsphere
项目概览
apache
/
Shardingsphere
通知
56
Star
3
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Shardingsphere
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
299aab35
编写于
5月 11, 2020
作者:
M
menghaoranss
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
resolve checkstyle problems
上级
dc045312
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
14 addition
and
35 deletion
+14
-35
sharding-orchestration/sharding-orchestration-center/sharding-orchestration-center-apollo/src/main/java/org/apache/shardingsphere/orchestration/center/instance/ApolloCenterRepository.java
...orchestration/center/instance/ApolloCenterRepository.java
+1
-7
sharding-orchestration/sharding-orchestration-center/sharding-orchestration-center-apollo/src/test/java/org/apache/shardingsphere/orchestration/center/instance/ApolloCenterRepositoryTest.java
...estration/center/instance/ApolloCenterRepositoryTest.java
+0
-9
sharding-orchestration/sharding-orchestration-center/sharding-orchestration-center-apollo/src/test/java/org/apache/shardingsphere/orchestration/center/instance/wrapper/ApolloOpenApiWrapperTest.java
...ion/center/instance/wrapper/ApolloOpenApiWrapperTest.java
+13
-19
未找到文件。
sharding-orchestration/sharding-orchestration-center/sharding-orchestration-center-apollo/src/main/java/org/apache/shardingsphere/orchestration/center/instance/ApolloCenterRepository.java
浏览文件 @
299aab35
...
...
@@ -74,13 +74,7 @@ public final class ApolloCenterRepository implements ConfigCenterRepository {
@Override
public
void
persist
(
final
String
key
,
final
String
value
)
{
try
{
openApiWrapper
.
persist
(
ConfigKeyUtils
.
pathToKey
(
key
),
value
);
// CHECKSTYLE:OFF
}
catch
(
Exception
ex
)
{
// CHECKSTYLE:ON
log
.
error
(
"Apollo persist key '{}' throw exception: {}"
,
key
,
ex
);
}
openApiWrapper
.
persist
(
ConfigKeyUtils
.
pathToKey
(
key
),
value
);
}
@Override
...
...
sharding-orchestration/sharding-orchestration-center/sharding-orchestration-center-apollo/src/test/java/org/apache/shardingsphere/orchestration/center/instance/ApolloCenterRepositoryTest.java
浏览文件 @
299aab35
...
...
@@ -40,10 +40,8 @@ import java.util.concurrent.TimeoutException;
import
static
org
.
hamcrest
.
CoreMatchers
.
is
;
import
static
org
.
junit
.
Assert
.
assertNull
;
import
static
org
.
junit
.
Assert
.
assertThat
;
import
static
org
.
mockito
.
ArgumentMatchers
.
anyString
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
verify
;
import
static
org
.
mockito
.
Mockito
.
doThrow
;
public
final
class
ApolloCenterRepositoryTest
{
...
...
@@ -153,13 +151,6 @@ public final class ApolloCenterRepositoryTest {
verify
(
OPEN_API_WRAPPER
).
persist
(
ConfigKeyUtils
.
pathToKey
(
"/test/children/6"
),
"value6"
);
}
@Test
public
void
assertPersistWhenThrowException
()
{
doThrow
(
Exception
.
class
).
when
(
OPEN_API_WRAPPER
).
persist
(
anyString
(),
anyString
());
REPOSITORY
.
persist
(
"/test/children/7"
,
"value7"
);
verify
(
OPEN_API_WRAPPER
).
persist
(
ConfigKeyUtils
.
pathToKey
(
"/test/children/7"
),
"value7"
);
}
@Test
public
void
assertGetType
()
{
assertThat
(
REPOSITORY
.
getType
(),
is
(
"apollo"
));
...
...
sharding-orchestration/sharding-orchestration-center/sharding-orchestration-center-apollo/src/test/java/org/apache/shardingsphere/orchestration/center/instance/wrapper/ApolloOpenApiWrapperTest.java
浏览文件 @
299aab35
...
...
@@ -41,10 +41,15 @@ import static org.mockito.Mockito.verify;
import
static
org
.
mockito
.
Mockito
.
when
;
import
static
org
.
junit
.
Assert
.
assertNull
;
@RunWith
(
MockitoJUnitRunner
.
class
)
public
final
class
ApolloOpenApiWrapperTest
{
private
static
final
String
NAME_SPACE
=
"orchestration"
;
private
static
final
String
PORTAL_URL
=
"http://127.0.0.1"
;
private
static
final
String
TOKEN
=
"testToken"
;
@Mock
private
ApolloOpenApiClient
client
;
...
...
@@ -53,12 +58,6 @@ public final class ApolloOpenApiWrapperTest {
private
ApolloOpenApiWrapper
apolloOpenApiWrapper
;
private
static
final
String
NAME_SPACE
=
"orchestration"
;
private
static
final
String
PORTAL_URL
=
"http://127.0.0.1"
;
private
static
final
String
TOKEN
=
"testToken"
;
@SneakyThrows
({
NoSuchFieldException
.
class
,
SecurityException
.
class
})
@Before
public
void
setUp
()
{
...
...
@@ -77,32 +76,27 @@ public final class ApolloOpenApiWrapperTest {
@Test
public
void
getValue
()
{
apolloOpenApiWrapper
.
getValue
(
ConfigKeyUtils
.
pathToKey
(
"/test/children/0"
));
verify
(
client
).
getItem
(
ApolloPropertyKey
.
APP_ID
.
getDefaultValue
()
,
ApolloPropertyKey
.
ENV
.
getDefaultValue
(),
ApolloPropertyKey
.
CLUSTER_NAME
.
getDefaultValue
(),
NAME_SPACE
,
ConfigKeyUtils
.
pathToKey
(
"/test/children/0"
));
verify
(
client
).
getItem
(
ApolloPropertyKey
.
APP_ID
.
getDefaultValue
(),
ApolloPropertyKey
.
ENV
.
getDefaultValue
(),
ApolloPropertyKey
.
CLUSTER_NAME
.
getDefaultValue
(),
NAME_SPACE
,
ConfigKeyUtils
.
pathToKey
(
"/test/children/0"
));
}
@Test
public
void
getValueNotNull
()
{
when
(
client
.
getItem
(
ApolloPropertyKey
.
APP_ID
.
getDefaultValue
()
,
ApolloPropertyKey
.
ENV
.
getDefaultValue
(),
ApolloPropertyKey
.
CLUSTER_NAME
.
getDefaultValue
(),
NAME_SPACE
,
ConfigKeyUtils
.
pathToKey
(
"/test/children/0"
))).
thenReturn
(
openItemDTO
);
when
(
client
.
getItem
(
ApolloPropertyKey
.
APP_ID
.
getDefaultValue
(),
ApolloPropertyKey
.
ENV
.
getDefaultValue
(),
ApolloPropertyKey
.
CLUSTER_NAME
.
getDefaultValue
(),
NAME_SPACE
,
ConfigKeyUtils
.
pathToKey
(
"/test/children/0"
))).
thenReturn
(
openItemDTO
);
assertNull
(
apolloOpenApiWrapper
.
getValue
(
ConfigKeyUtils
.
pathToKey
(
"/test/children/0"
)));
}
@Test
public
void
persist
()
{
apolloOpenApiWrapper
.
persist
(
ConfigKeyUtils
.
pathToKey
(
"/test/children/0"
),
"value0"
);
verify
(
client
).
createOrUpdateItem
(
anyString
()
,
anyString
(),
anyString
(),
anyString
(),
any
(
OpenItemDTO
.
class
));
verify
(
client
).
publishNamespace
(
anyString
()
,
anyString
(),
anyString
(),
anyString
(),
any
(
NamespaceReleaseDTO
.
class
));
verify
(
client
).
createOrUpdateItem
(
anyString
(),
anyString
(),
anyString
(),
anyString
(),
any
(
OpenItemDTO
.
class
));
verify
(
client
).
publishNamespace
(
anyString
(),
anyString
(),
anyString
(),
anyString
(),
any
(
NamespaceReleaseDTO
.
class
));
}
@Test
public
void
remove
()
{
apolloOpenApiWrapper
.
remove
(
ConfigKeyUtils
.
pathToKey
(
"/test/children/0"
));
verify
(
client
).
removeItem
(
anyString
()
,
anyString
(),
anyString
(),
anyString
(),
eq
(
ConfigKeyUtils
.
pathToKey
(
"/test/children/0"
))
,
anyString
());
verify
(
client
).
removeItem
(
anyString
(),
anyString
(),
anyString
(),
anyString
(),
eq
(
ConfigKeyUtils
.
pathToKey
(
"/test/children/0"
)),
anyString
());
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录