Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
wrr-cat
apollo
提交
fd1b084b
apollo
项目概览
wrr-cat
/
apollo
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
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,发现更多精彩内容 >>
提交
fd1b084b
编写于
4月 13, 2016
作者:
Y
Yiming Liu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add ReleaseController Integration Test
上级
44375b3b
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
131 addition
and
5 deletion
+131
-5
apollo-adminservice/src/test/java/com/ctrip/apollo/adminservice/controller/ItemSetControllerTest.java
...apollo/adminservice/controller/ItemSetControllerTest.java
+0
-2
apollo-adminservice/src/test/java/com/ctrip/apollo/adminservice/controller/ReleaseControllerTest.java
...apollo/adminservice/controller/ReleaseControllerTest.java
+81
-0
apollo-adminservice/src/test/resources/controller/test-release-cleanup.sql
...ce/src/test/resources/controller/test-release-cleanup.sql
+6
-0
apollo-adminservice/src/test/resources/controller/test-release.sql
...minservice/src/test/resources/controller/test-release.sql
+11
-0
apollo-biz/src/main/java/com/ctrip/apollo/biz/entity/Item.java
...o-biz/src/main/java/com/ctrip/apollo/biz/entity/Item.java
+3
-3
apollo-configservice/src/test/java/com/ctrip/apollo/ConfigServiceTestConfiguration.java
...java/com/ctrip/apollo/ConfigServiceTestConfiguration.java
+15
-0
apollo-configservice/src/test/java/com/ctrip/apollo/configservice/controller/AbstractControllerTest.java
...ollo/configservice/controller/AbstractControllerTest.java
+15
-0
未找到文件。
apollo-adminservice/src/test/java/com/ctrip/apollo/adminservice/controller/ItemSetControllerTest.java
浏览文件 @
fd1b084b
...
...
@@ -18,8 +18,6 @@ import com.ctrip.apollo.core.dto.ItemChangeSets;
import
com.ctrip.apollo.core.dto.ItemDTO
;
import
com.ctrip.apollo.core.dto.NamespaceDTO
;
public
class
ItemSetControllerTest
extends
AbstractControllerTest
{
@Autowired
...
...
apollo-adminservice/src/test/java/com/ctrip/apollo/adminservice/controller/ReleaseControllerTest.java
0 → 100644
浏览文件 @
fd1b084b
package
com.ctrip.apollo.adminservice.controller
;
import
java.util.HashMap
;
import
java.util.Map
;
import
org.junit.Assert
;
import
org.junit.Test
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpEntity
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.test.context.jdbc.Sql
;
import
org.springframework.test.context.jdbc.Sql.ExecutionPhase
;
import
org.springframework.util.LinkedMultiValueMap
;
import
org.springframework.util.MultiValueMap
;
import
com.ctrip.apollo.biz.repository.ReleaseRepository
;
import
com.ctrip.apollo.core.dto.AppDTO
;
import
com.ctrip.apollo.core.dto.ClusterDTO
;
import
com.ctrip.apollo.core.dto.ItemDTO
;
import
com.ctrip.apollo.core.dto.NamespaceDTO
;
import
com.ctrip.apollo.core.dto.ReleaseDTO
;
import
com.google.gson.Gson
;
public
class
ReleaseControllerTest
extends
AbstractControllerTest
{
@Autowired
ReleaseRepository
releaseRepository
;
@Test
@Sql
(
scripts
=
"/controller/test-release.sql"
,
executionPhase
=
ExecutionPhase
.
BEFORE_TEST_METHOD
)
@Sql
(
scripts
=
"/controller/test-release-cleanup.sql"
,
executionPhase
=
ExecutionPhase
.
AFTER_TEST_METHOD
)
public
void
testReleaseBuild
()
{
String
appId
=
"someAppId"
;
AppDTO
app
=
restTemplate
.
getForObject
(
"http://localhost:"
+
port
+
"/apps/"
+
appId
,
AppDTO
.
class
);
ClusterDTO
cluster
=
restTemplate
.
getForObject
(
"http://localhost:"
+
port
+
"/apps/"
+
app
.
getAppId
()
+
"/clusters/default"
,
ClusterDTO
.
class
);
NamespaceDTO
namespace
=
restTemplate
.
getForObject
(
"http://localhost:"
+
port
+
"/apps/"
+
app
.
getAppId
()
+
"/clusters/"
+
cluster
.
getName
()
+
"/namespaces/application"
,
NamespaceDTO
.
class
);
Assert
.
assertEquals
(
"someAppId"
,
app
.
getAppId
());
Assert
.
assertEquals
(
"default"
,
cluster
.
getName
());
Assert
.
assertEquals
(
"application"
,
namespace
.
getNamespaceName
());
ItemDTO
[]
items
=
restTemplate
.
getForObject
(
"http://localhost:"
+
port
+
"/apps/"
+
app
.
getAppId
()
+
"/clusters/"
+
cluster
.
getName
()
+
"/namespaces/"
+
namespace
.
getNamespaceName
()
+
"/items"
,
ItemDTO
[].
class
);
Assert
.
assertEquals
(
3
,
items
.
length
);
MultiValueMap
<
String
,
String
>
parameters
=
new
LinkedMultiValueMap
<
String
,
String
>();
parameters
.
add
(
"name"
,
"someReleaseName"
);
parameters
.
add
(
"comment"
,
"someComment"
);
HttpEntity
<
MultiValueMap
<
String
,
String
>>
entity
=
new
HttpEntity
<
MultiValueMap
<
String
,
String
>>(
parameters
,
null
);
ResponseEntity
<
ReleaseDTO
>
response
=
restTemplate
.
postForEntity
(
"http://localhost:"
+
port
+
"/apps/"
+
app
.
getAppId
()
+
"/clusters/"
+
cluster
.
getName
()
+
"/namespaces/"
+
namespace
.
getNamespaceName
()
+
"/releases"
,
entity
,
ReleaseDTO
.
class
);
Assert
.
assertEquals
(
HttpStatus
.
OK
,
response
.
getStatusCode
());
ReleaseDTO
release
=
response
.
getBody
();
Assert
.
assertEquals
(
"someReleaseName"
,
release
.
getName
());
Assert
.
assertEquals
(
"someComment"
,
release
.
getComment
());
Assert
.
assertEquals
(
"someAppId"
,
release
.
getAppId
());
Assert
.
assertEquals
(
"default"
,
release
.
getClusterName
());
Assert
.
assertEquals
(
"application"
,
release
.
getNamespaceName
());
Map
<
String
,
String
>
configurations
=
new
HashMap
<
String
,
String
>();
configurations
.
put
(
"k1"
,
"v1"
);
configurations
.
put
(
"k2"
,
"v2"
);
configurations
.
put
(
"k3"
,
"v3"
);
Gson
gson
=
new
Gson
();
Assert
.
assertEquals
(
gson
.
toJson
(
configurations
),
release
.
getConfigurations
());
}
}
apollo-adminservice/src/test/resources/controller/test-release-cleanup.sql
0 → 100644
浏览文件 @
fd1b084b
DELETE
FROM
Item
;
DELETE
FROM
Namespace
;
DELETE
FROM
AppNamespace
;
DELETE
FROM
Cluster
;
DELETE
FROM
App
;
apollo-adminservice/src/test/resources/controller/test-release.sql
0 → 100644
浏览文件 @
fd1b084b
INSERT
INTO
App
(
AppId
,
Name
,
OwnerName
,
OwnerEmail
)
VALUES
(
'someAppId'
,
'someAppName'
,
'someOwnerName'
,
'someOwnerName@ctrip.com'
);
INSERT
INTO
Cluster
(
AppId
,
Name
)
VALUES
(
'someAppId'
,
'default'
);
INSERT
INTO
AppNamespace
(
AppId
,
Name
)
VALUES
(
'someAppId'
,
'application'
);
INSERT
INTO
Namespace
(
Id
,
AppId
,
ClusterName
,
NamespaceName
)
VALUES
(
100
,
'someAppId'
,
'default'
,
'application'
);
INSERT
INTO
Item
(
NamespaceId
,
`Key`
,
Value
,
Comment
)
VALUES
(
100
,
'k1'
,
'v1'
,
'comment1'
);
INSERT
INTO
Item
(
NamespaceId
,
`Key`
,
Value
,
Comment
)
VALUES
(
100
,
'k2'
,
'v2'
,
'comment1'
);
INSERT
INTO
Item
(
NamespaceId
,
`Key`
,
Value
,
Comment
)
VALUES
(
100
,
'k3'
,
'v3'
,
'comment1'
);
\ No newline at end of file
apollo-biz/src/main/java/com/ctrip/apollo/biz/entity/Item.java
浏览文件 @
fd1b084b
...
...
@@ -24,7 +24,7 @@ public class Item extends BaseEntity {
private
String
comment
;
@Column
private
int
lineNum
;
private
Integer
lineNum
;
public
String
getComment
()
{
return
comment
;
...
...
@@ -58,11 +58,11 @@ public class Item extends BaseEntity {
this
.
value
=
value
;
}
public
int
getLineNum
()
{
public
Integer
getLineNum
()
{
return
lineNum
;
}
public
void
setLineNum
(
int
lineNum
)
{
public
void
setLineNum
(
Integer
lineNum
)
{
this
.
lineNum
=
lineNum
;
}
}
apollo-configservice/src/test/java/com/ctrip/apollo/ConfigServiceTestConfiguration.java
0 → 100644
浏览文件 @
fd1b084b
package
com.ctrip.apollo
;
import
org.springframework.boot.autoconfigure.EnableAutoConfiguration
;
import
org.springframework.context.annotation.ComponentScan
;
import
org.springframework.context.annotation.ComponentScan.Filter
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.FilterType
;
@Configuration
@ComponentScan
(
excludeFilters
=
{
@Filter
(
type
=
FilterType
.
ASSIGNABLE_TYPE
,
value
=
{
SampleConfigServiceApplication
.
class
,
ConfigServiceApplication
.
class
})})
@EnableAutoConfiguration
public
class
ConfigServiceTestConfiguration
{
}
apollo-configservice/src/test/java/com/ctrip/apollo/configservice/
AbstractConfigService
Test.java
→
apollo-configservice/src/test/java/com/ctrip/apollo/configservice/
controller/AbstractController
Test.java
浏览文件 @
fd1b084b
package
com.ctrip.apollo.configservice
;
import
com.ctrip.apollo.ConfigServiceApplication
;
package
com.ctrip.apollo.configservice.controller
;
import
org.junit.runner.RunWith
;
import
org.springframework.boot.test.SpringApplicationConfiguration
;
import
org.springframework.boot.test.WebIntegrationTest
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
com.ctrip.apollo.ConfigServiceTestConfiguration
;
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@SpringApplicationConfiguration
(
classes
=
ConfigServiceApplication
.
class
)
public
abstract
class
AbstractConfigServiceTest
{
@SpringApplicationConfiguration
(
classes
=
ConfigServiceTestConfiguration
.
class
)
@WebIntegrationTest
(
randomPort
=
true
)
public
abstract
class
AbstractControllerTest
{
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录