Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
apollo
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
openSource
apollo
Commits
fd1b084b
Commit
fd1b084b
authored
Apr 13, 2016
by
Yiming Liu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add ReleaseController Integration Test
parent
44375b3b
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
124 additions
and
10 deletions
+124
-10
ItemSetControllerTest.java
...apollo/adminservice/controller/ItemSetControllerTest.java
+0
-2
ReleaseControllerTest.java
...apollo/adminservice/controller/ReleaseControllerTest.java
+81
-0
test-release-cleanup.sql
...ce/src/test/resources/controller/test-release-cleanup.sql
+6
-0
test-release.sql
...minservice/src/test/resources/controller/test-release.sql
+12
-0
Item.java
...o-biz/src/main/java/com/ctrip/apollo/biz/entity/Item.java
+3
-3
ConfigServiceTestConfiguration.java
...java/com/ctrip/apollo/ConfigServiceTestConfiguration.java
+15
-0
AbstractControllerTest.java
...ollo/configservice/controller/AbstractControllerTest.java
+7
-5
No files found.
apollo-adminservice/src/test/java/com/ctrip/apollo/adminservice/controller/ItemSetControllerTest.java
View file @
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
View file @
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
View file @
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
View file @
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
View file @
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
View file @
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
View file @
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
{
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment