Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
superrain51
apollo
提交
d91d221a
apollo
项目概览
superrain51
/
apollo
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
apollo
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
d91d221a
编写于
4月 15, 2016
作者:
Y
Yiming Liu
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #94 from lepdou/portal
delete old test
上级
00467579
bef96d6f
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
1 addition
and
236 deletion
+1
-236
apollo-portal/src/main/resources/application.yml
apollo-portal/src/main/resources/application.yml
+1
-1
apollo-portal/src/test/java/com/ctrip/apollo/portal/AllTests.java
...ortal/src/test/java/com/ctrip/apollo/portal/AllTests.java
+0
-3
apollo-portal/src/test/java/com/ctrip/apollo/portal/service/ConfigServiceTest.java
...va/com/ctrip/apollo/portal/service/ConfigServiceTest.java
+0
-232
未找到文件。
apollo-portal/src/main/resources/application.yml
浏览文件 @
d91d221a
...
...
@@ -15,4 +15,4 @@ ctrip:
apollo
:
portal
:
env
:
local
env
:
dev
apollo-portal/src/test/java/com/ctrip/apollo/portal/AllTests.java
浏览文件 @
d91d221a
...
...
@@ -4,11 +4,8 @@ import org.junit.runner.RunWith;
import
org.junit.runners.Suite
;
import
org.junit.runners.Suite.SuiteClasses
;
import
com.ctrip.apollo.portal.service.ConfigServiceTest
;
@RunWith
(
Suite
.
class
)
@SuiteClasses
({
//ConfigServiceTest.class
})
public
class
AllTests
{
...
...
apollo-portal/src/test/java/com/ctrip/apollo/portal/service/ConfigServiceTest.java
已删除
100644 → 0
浏览文件 @
00467579
package
com.ctrip.apollo.portal.service
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
mockito
.
Mockito
.
when
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.mockito.InjectMocks
;
import
org.mockito.Mock
;
import
org.mockito.Mockito
;
import
org.mockito.Spy
;
import
org.mockito.runners.MockitoJUnitRunner
;
import
org.springframework.test.util.ReflectionTestUtils
;
import
org.springframework.web.client.RestTemplate
;
import
com.ctrip.apollo.Apollo.Env
;
import
com.ctrip.apollo.core.ConfigConsts
;
import
com.ctrip.apollo.core.dto.AppConfigVO
;
import
com.ctrip.apollo.core.dto.ClusterDTO
;
import
com.ctrip.apollo.core.dto.ItemDTO
;
import
com.ctrip.apollo.core.dto.ReleaseDTO
;
import
com.ctrip.apollo.core.dto.ServiceDTO
;
import
com.ctrip.apollo.core.exception.ServiceException
;
import
com.ctrip.apollo.portal.api.AdminServiceAPI
;
import
com.ctrip.apollo.portal.constants.PortalConstants
;
import
java.util.Arrays
;
@RunWith
(
MockitoJUnitRunner
.
class
)
public
class
ConfigServiceTest
{
@Mock
private
RestTemplate
restTemplate
;
@InjectMocks
private
ConfigService
configService
;
@Mock
private
ServiceLocator
serviceLocator
;
@Spy
private
AdminServiceAPI
.
ClusterAPI
clusterAPI
;
// @Spy
// private AdminServiceAPI.ConfigAPI configAPI;
@Before
public
void
setUp
()
throws
ServiceException
{
// ReflectionTestUtils.setField(clusterAPI, "restTemplate", restTemplate);
// ReflectionTestUtils.setField(configAPI, "restTemplate", restTemplate);
//
// ReflectionTestUtils.setField(clusterAPI, "serviceLocator", serviceLocator);
// ReflectionTestUtils.setField(configAPI, "serviceLocator", serviceLocator);
//
// String defaultAdminService = "http://localhost:8090";
// ServiceDTO service = new ServiceDTO();
// service.setHomepageUrl(defaultAdminService);
// Mockito.doReturn(service).when(serviceLocator).getAdminService(Env.DEV);
}
// @Test
// public void testLoadReleaseConfig() {
// String appId = "6666";
// long versionId = 100;
// long releaseId = 11111;
//
// VersionDTO someVersion = assembleVersion(appId, "1.0", releaseId);
// ReleaseDTO[] someReleaseSnapShots = assembleReleaseSnapShots();
//
// when(versionAPI.getVersionById(Env.DEV, versionId)).thenReturn(someVersion);
// when(configAPI.getConfigByReleaseId(Env.DEV, releaseId)).thenReturn(someReleaseSnapShots);
//
// AppConfigVO appConfigVO = configService.loadReleaseConfig(Env.DEV, appId, versionId);
//
// assertEquals(appConfigVO.getAppId(), appId);
// assertEquals(appConfigVO.getVersionId(), versionId);
// assertEquals(appConfigVO.getDefaultClusterConfigs().size(), 2);
// assertEquals(appConfigVO.getOverrideAppConfigs().size(), 2);
// assertEquals(appConfigVO.getOverrideClusterConfigs().size(), 2);
// }
//
// @Test
// public void testLoadReleaseConfigOnlyDefaultConfigs() {
// String appId = "6666";
// long versionId = 100;
// long releaseId = 11111;
//
// ReleaseDTO[] someReleaseSnapShots = new ReleaseDTO[1];
// someReleaseSnapShots[0] = assembleReleaseSnapShot(11111, ConfigConsts.DEFAULT_CLUSTER_NAME,
// "{\"6666.foo\":\"demo1\", \"6666.bar\":\"demo2\"}");
//
// when(versionAPI.getVersionById(Env.DEV, versionId)).thenReturn(someVersion);
// when(configAPI.getConfigByReleaseId(Env.DEV, releaseId)).thenReturn(someReleaseSnapShots);
//
// AppConfigVO appConfigVO = configService.loadReleaseConfig(Env.DEV, appId, versionId);
//
// assertEquals(appConfigVO.getAppId(), appId);
// assertEquals(appConfigVO.getVersionId(), versionId);
// assertEquals(appConfigVO.getDefaultClusterConfigs().size(), 2);
// assertEquals(appConfigVO.getOverrideAppConfigs().size(), 0);
// assertEquals(appConfigVO.getOverrideClusterConfigs().size(), 0);
// }
//
// @Test
// public void testLoadReleaseConfigDefaultConfigsAndOverrideApp() {
// String appId = "6666";
// long versionId = 100;
// long releaseId = 11111;
// VersionDTO someVersion = assembleVersion(appId, "1.0", releaseId);
// ReleaseDTO[] someReleaseSnapShots = new ReleaseDTO[1];
// someReleaseSnapShots[0] = assembleReleaseSnapShot(11111, ConfigConsts.DEFAULT_CLUSTER_NAME,
// "{\"6666.foo\":\"demo1\", \"6666.bar\":\"demo2\", \"5555.bar\":\"demo2\", \"22.bar\":\"demo2\"}");
//
// when(versionAPI.getVersionById(Env.DEV, versionId)).thenReturn(someVersion);
// when(configAPI.getConfigByReleaseId(Env.DEV, releaseId)).thenReturn(someReleaseSnapShots);
//
// AppConfigVO appConfigVO = configService.loadReleaseConfig(Env.DEV, appId, versionId);
//
// assertEquals(appConfigVO.getAppId(), appId);
// assertEquals(appConfigVO.getVersionId(), versionId);
// assertEquals(appConfigVO.getDefaultClusterConfigs().size(), 2);
// assertEquals(2, appConfigVO.getOverrideAppConfigs().size());
// assertEquals(appConfigVO.getOverrideClusterConfigs().size(), 0);
// }
//
// @Test
// public void testLoadReleaseConfigDefaultConfigsAndOverrideCluster() {
// String appId = "6666";
// long versionId = 100;
// long releaseId = 11111;
// VersionDTO someVersion = assembleVersion(appId, "1.0", releaseId);
// ReleaseDTO[] someReleaseSnapShots = new ReleaseDTO[2];
// someReleaseSnapShots[0] = assembleReleaseSnapShot(11111, ConfigConsts.DEFAULT_CLUSTER_NAME,
// "{\"6666.foo\":\"demo1\", \"6666.bar\":\"demo2\"}");
// someReleaseSnapShots[1] = assembleReleaseSnapShot(11112, "cluster1",
// "{\"6666.foo\":\"demo1\", \"6666.bar\":\"demo2\"}");
//
// when(versionAPI.getVersionById(Env.DEV, versionId)).thenReturn(someVersion);
// when(configAPI.getConfigByReleaseId(Env.DEV, releaseId)).thenReturn(someReleaseSnapShots);
//
// AppConfigVO appConfigVO = configService.loadReleaseConfig(Env.DEV, appId, versionId);
//
// assertEquals(appConfigVO.getAppId(), appId);
// assertEquals(appConfigVO.getVersionId(), versionId);
// assertEquals(appConfigVO.getDefaultClusterConfigs().size(), 2);
// assertEquals(0, appConfigVO.getOverrideAppConfigs().size());
// assertEquals(1, appConfigVO.getOverrideClusterConfigs().size());
// }
//
// @Test
// public void testLoadLastestConfig() {
// String appId = "6666";
// ClusterDTO[] someClusters = assembleClusters();
// ItemDTO[] someConfigItem = assembleConfigItems();
//
// when(clusterAPI.getClustersByApp(Env.DEV, appId)).thenReturn(someClusters);
// when(configAPI.getLatestConfigItemsByClusters(Env.DEV, Arrays
// .asList(Long.valueOf(100), Long.valueOf(101)))).thenReturn(someConfigItem);
//
// AppConfigVO appConfigVO = configService.loadLatestConfig(Env.DEV, appId);
//
// assertEquals(appConfigVO.getAppId(), "6666");
// assertEquals(appConfigVO.getVersionId(), PortalConstants.LASTEST_VERSION_ID);
// assertEquals(appConfigVO.getDefaultClusterConfigs().size(), 3);
// assertEquals(appConfigVO.getOverrideAppConfigs().size(), 1);
// assertEquals(appConfigVO.getOverrideClusterConfigs().size(), 1);
// }
//
// private VersionDTO assembleVersion(String appId, String versionName, long releaseId) {
// VersionDTO version = new VersionDTO();
// version.setAppId(appId);
// version.setName(versionName);
// version.setReleaseId(releaseId);
// return version;
// }
private
ReleaseDTO
[]
assembleReleaseSnapShots
()
{
ReleaseDTO
[]
releaseSnapShots
=
new
ReleaseDTO
[
3
];
releaseSnapShots
[
0
]
=
assembleReleaseSnapShot
(
11111
,
ConfigConsts
.
CLUSTER_NAME_DEFAULT
,
"{\"6666.foo\":\"demo1\", \"6666.bar\":\"demo2\",\"3333.foo\":\"1008\",\"4444.bar\":\"99901\"}"
);
releaseSnapShots
[
1
]
=
assembleReleaseSnapShot
(
11111
,
"cluster1"
,
"{\"6666.foo\":\"demo1\"}"
);
releaseSnapShots
[
2
]
=
assembleReleaseSnapShot
(
11111
,
"cluster2"
,
"{\"6666.bar\":\"bar2222\"}"
);
return
releaseSnapShots
;
}
private
ReleaseDTO
assembleReleaseSnapShot
(
long
releaseId
,
String
clusterName
,
String
configurations
)
{
ReleaseDTO
releaseSnapShot
=
new
ReleaseDTO
();
// releaseSnapShot.setReleaseId(releaseId);
releaseSnapShot
.
setClusterName
(
clusterName
);
releaseSnapShot
.
setConfigurations
(
configurations
);
return
releaseSnapShot
;
}
private
ClusterDTO
[]
assembleClusters
()
{
ClusterDTO
[]
clusters
=
new
ClusterDTO
[
2
];
clusters
[
0
]
=
assembleCluster
(
100
,
"6666"
,
ConfigConsts
.
CLUSTER_NAME_DEFAULT
);
clusters
[
1
]
=
assembleCluster
(
101
,
"6666"
,
"cluster1"
);
return
clusters
;
}
private
ClusterDTO
assembleCluster
(
long
id
,
String
appId
,
String
name
)
{
ClusterDTO
cluster
=
new
ClusterDTO
();
cluster
.
setAppId
(
appId
);
cluster
.
setId
(
id
);
cluster
.
setName
(
name
);
return
cluster
;
}
private
ItemDTO
[]
assembleConfigItems
()
{
ItemDTO
[]
configItems
=
new
ItemDTO
[
5
];
configItems
[
0
]
=
assembleConfigItem
(
100
,
ConfigConsts
.
CLUSTER_NAME_DEFAULT
,
"6666"
,
"6666.k1"
,
"6666.v1"
);
configItems
[
1
]
=
assembleConfigItem
(
100
,
ConfigConsts
.
CLUSTER_NAME_DEFAULT
,
"6666"
,
"6666.k2"
,
"6666.v2"
);
configItems
[
2
]
=
assembleConfigItem
(
100
,
ConfigConsts
.
CLUSTER_NAME_DEFAULT
,
"6666"
,
"6666.k3"
,
"6666.v3"
);
configItems
[
3
]
=
assembleConfigItem
(
100
,
ConfigConsts
.
CLUSTER_NAME_DEFAULT
,
"5555"
,
"5555.k1"
,
"5555.v1"
);
configItems
[
4
]
=
assembleConfigItem
(
101
,
"cluster1"
,
"6666"
,
"6666.k1"
,
"6666.v1"
);
return
configItems
;
}
private
ItemDTO
assembleConfigItem
(
long
clusterId
,
String
clusterName
,
String
appId
,
String
key
,
String
value
)
{
ItemDTO
configItem
=
new
ItemDTO
();
// configItem.setClusterName(clusterName);
// configItem.setClusterId(clusterId);
// configItem.setAppId(appId);
configItem
.
setKey
(
key
);
configItem
.
setValue
(
value
);
return
configItem
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录