Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
apollo
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
Administrator
apollo
Commits
55a0e1b8
Commit
55a0e1b8
authored
Oct 03, 2018
by
nobodyiam
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
upgrade spring boot to 2.0.5 and spring cloud to Finchley.SR1
parent
425de29e
Changes
88
Hide whitespace changes
Inline
Side-by-side
Showing
88 changed files
with
277 additions
and
348 deletions
+277
-348
apollo-adminservice/pom.xml
apollo-adminservice/pom.xml
+3
-5
apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/AdminServiceHealthIndicator.java
...work/apollo/adminservice/AdminServiceHealthIndicator.java
+1
-1
apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/InstanceConfigController.java
...llo/adminservice/controller/InstanceConfigController.java
+1
-1
apollo-adminservice/src/main/resources/adminservice.properties
...o-adminservice/src/main/resources/adminservice.properties
+1
-0
apollo-adminservice/src/main/resources/bootstrap.yml
apollo-adminservice/src/main/resources/bootstrap.yml
+2
-8
apollo-adminservice/src/main/scripts/startup.sh
apollo-adminservice/src/main/scripts/startup.sh
+1
-1
apollo-adminservice/src/test/java/com/ctrip/framework/apollo/adminservice/controller/AbstractControllerTest.java
...pollo/adminservice/controller/AbstractControllerTest.java
+6
-7
apollo-adminservice/src/test/java/com/ctrip/framework/apollo/adminservice/controller/AppControllerTest.java
...ork/apollo/adminservice/controller/AppControllerTest.java
+3
-3
apollo-adminservice/src/test/java/com/ctrip/framework/apollo/adminservice/controller/ControllerExceptionTest.java
...ollo/adminservice/controller/ControllerExceptionTest.java
+2
-2
apollo-adminservice/src/test/java/com/ctrip/framework/apollo/adminservice/controller/InstanceConfigControllerTest.java
...adminservice/controller/InstanceConfigControllerTest.java
+4
-4
apollo-adminservice/src/test/java/com/ctrip/framework/apollo/adminservice/controller/ItemSetControllerTest.java
...apollo/adminservice/controller/ItemSetControllerTest.java
+6
-6
apollo-adminservice/src/test/resources/application.properties
...lo-adminservice/src/test/resources/application.properties
+1
-1
apollo-adminservice/src/test/resources/bootstrap.yml
apollo-adminservice/src/test/resources/bootstrap.yml
+3
-7
apollo-assembly/src/main/java/com/ctrip/framework/apollo/assembly/ApolloApplication.java
...om/ctrip/framework/apollo/assembly/ApolloApplication.java
+2
-1
apollo-assembly/src/test/java/com/ctrip/framework/apollo/assembly/LocalApolloApplication.java
...rip/framework/apollo/assembly/LocalApolloApplication.java
+2
-1
apollo-assembly/src/test/resources/application.properties
apollo-assembly/src/test/resources/application.properties
+1
-1
apollo-biz/pom.xml
apollo-biz/pom.xml
+1
-1
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Instance.java
.../java/com/ctrip/framework/apollo/biz/entity/Instance.java
+2
-1
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/InstanceConfig.java
...com/ctrip/framework/apollo/biz/entity/InstanceConfig.java
+2
-1
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/ReleaseMessage.java
...com/ctrip/framework/apollo/biz/entity/ReleaseMessage.java
+2
-1
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/message/DatabaseMessageSender.java
...p/framework/apollo/biz/message/DatabaseMessageSender.java
+2
-2
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/AppService.java
...va/com/ctrip/framework/apollo/biz/service/AppService.java
+1
-1
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ClusterService.java
...om/ctrip/framework/apollo/biz/service/ClusterService.java
+2
-2
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/InstanceService.java
...m/ctrip/framework/apollo/biz/service/InstanceService.java
+2
-2
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ItemService.java
...a/com/ctrip/framework/apollo/biz/service/ItemService.java
+3
-3
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/NamespaceService.java
.../ctrip/framework/apollo/biz/service/NamespaceService.java
+1
-1
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ReleaseService.java
...om/ctrip/framework/apollo/biz/service/ReleaseService.java
+3
-3
apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/AbstractIntegrationTest.java
...m/ctrip/framework/apollo/biz/AbstractIntegrationTest.java
+3
-4
apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/config/BizConfigTest.java
.../com/ctrip/framework/apollo/biz/config/BizConfigTest.java
+1
-1
apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/repository/AppRepositoryTest.java
...ip/framework/apollo/biz/repository/AppRepositoryTest.java
+1
-1
apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/InstanceServiceTest.java
...rip/framework/apollo/biz/service/InstanceServiceTest.java
+4
-4
apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/NamespaceBranchServiceTest.java
...mework/apollo/biz/service/NamespaceBranchServiceTest.java
+1
-1
apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/NamespaceServiceIntegrationTest.java
...k/apollo/biz/service/NamespaceServiceIntegrationTest.java
+5
-5
apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/NamespaceServiceTest.java
...ip/framework/apollo/biz/service/NamespaceServiceTest.java
+2
-2
apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/ReleaseCreationTest.java
...rip/framework/apollo/biz/service/ReleaseCreationTest.java
+1
-1
apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/ReleaseServiceTest.java
...trip/framework/apollo/biz/service/ReleaseServiceTest.java
+6
-5
apollo-biz/src/test/resources/application.properties
apollo-biz/src/test/resources/application.properties
+1
-1
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/PropertiesConfigFileTest.java
.../framework/apollo/internals/PropertiesConfigFileTest.java
+0
-1
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollServiceTest.java
...ork/apollo/internals/RemoteConfigLongPollServiceTest.java
+0
-3
apollo-client/src/test/java/com/ctrip/framework/apollo/spring/BootstrapConfigTest.java
...om/ctrip/framework/apollo/spring/BootstrapConfigTest.java
+7
-7
apollo-common/pom.xml
apollo-common/pom.xml
+0
-11
apollo-common/src/main/java/com/ctrip/framework/apollo/common/controller/CharacterEncodingFilterConfiguration.java
...mmon/controller/CharacterEncodingFilterConfiguration.java
+1
-1
apollo-common/src/main/java/com/ctrip/framework/apollo/common/controller/HttpMessageConverterConfiguration.java
.../common/controller/HttpMessageConverterConfiguration.java
+1
-1
apollo-common/src/main/java/com/ctrip/framework/apollo/common/controller/WebMvcConfig.java
...trip/framework/apollo/common/controller/WebMvcConfig.java
+8
-8
apollo-common/src/main/java/com/ctrip/framework/apollo/common/customize/TomcatContainerCustomizer.java
...rk/apollo/common/customize/TomcatContainerCustomizer.java
+0
-50
apollo-common/src/main/java/com/ctrip/framework/apollo/common/entity/BaseEntity.java
.../com/ctrip/framework/apollo/common/entity/BaseEntity.java
+2
-1
apollo-common/src/main/resources/application.properties
apollo-common/src/main/resources/application.properties
+6
-7
apollo-common/src/main/resources/banner.txt
apollo-common/src/main/resources/banner.txt
+8
-0
apollo-configservice/pom.xml
apollo-configservice/pom.xml
+3
-5
apollo-configservice/src/main/java/com/ctrip/framework/apollo/configservice/ConfigServiceHealthIndicator.java
...rk/apollo/configservice/ConfigServiceHealthIndicator.java
+1
-1
apollo-configservice/src/main/java/com/ctrip/framework/apollo/configservice/ServletInitializer.java
...ip/framework/apollo/configservice/ServletInitializer.java
+1
-1
apollo-configservice/src/main/java/com/ctrip/framework/apollo/configservice/service/AppNamespaceServiceWithCache.java
...o/configservice/service/AppNamespaceServiceWithCache.java
+1
-1
apollo-configservice/src/main/resources/bootstrap.yml
apollo-configservice/src/main/resources/bootstrap.yml
+2
-6
apollo-configservice/src/main/resources/configservice.properties
...configservice/src/main/resources/configservice.properties
+2
-1
apollo-configservice/src/main/scripts/startup.sh
apollo-configservice/src/main/scripts/startup.sh
+1
-1
apollo-configservice/src/test/java/com/ctrip/framework/apollo/configservice/integration/AbstractBaseIntegrationTest.java
...onfigservice/integration/AbstractBaseIntegrationTest.java
+6
-7
apollo-configservice/src/test/java/com/ctrip/framework/apollo/configservice/integration/ConfigControllerIntegrationTest.java
...gservice/integration/ConfigControllerIntegrationTest.java
+20
-20
apollo-configservice/src/test/java/com/ctrip/framework/apollo/configservice/integration/ConfigFileControllerIntegrationTest.java
...vice/integration/ConfigFileControllerIntegrationTest.java
+15
-15
apollo-configservice/src/test/java/com/ctrip/framework/apollo/configservice/integration/NotificationControllerIntegrationTest.java
...ce/integration/NotificationControllerIntegrationTest.java
+9
-9
apollo-configservice/src/test/java/com/ctrip/framework/apollo/configservice/integration/NotificationControllerV2IntegrationTest.java
.../integration/NotificationControllerV2IntegrationTest.java
+17
-17
apollo-configservice/src/test/java/com/ctrip/framework/apollo/configservice/service/AppNamespaceServiceWithCacheTest.java
...nfigservice/service/AppNamespaceServiceWithCacheTest.java
+3
-3
apollo-configservice/src/test/java/com/ctrip/framework/apollo/configservice/wrapper/CaseInsensitiveMapWrapperTest.java
.../configservice/wrapper/CaseInsensitiveMapWrapperTest.java
+1
-1
apollo-configservice/src/test/resources/application.properties
...o-configservice/src/test/resources/application.properties
+1
-1
apollo-configservice/src/test/resources/bootstrap.yml
apollo-configservice/src/test/resources/bootstrap.yml
+2
-7
apollo-mockserver/src/test/java/com/ctrip/framework/apollo/mockserver/ApolloMockServerSpringIntegrationTest.java
...llo/mockserver/ApolloMockServerSpringIntegrationTest.java
+2
-2
apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/entity/ConsumerAudit.java
.../ctrip/framework/apollo/openapi/entity/ConsumerAudit.java
+2
-1
apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/service/ConsumerService.java
...rip/framework/apollo/openapi/service/ConsumerService.java
+2
-2
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/AdminServiceAddressLocator.java
...k/apollo/portal/component/AdminServiceAddressLocator.java
+1
-1
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/RestTemplateFactory.java
...ramework/apollo/portal/component/RestTemplateFactory.java
+1
-1
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/RetryableRestTemplate.java
...mework/apollo/portal/component/RetryableRestTemplate.java
+2
-2
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/UserPO.java
...a/com/ctrip/framework/apollo/portal/entity/po/UserPO.java
+2
-1
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/FavoriteService.java
...trip/framework/apollo/portal/service/FavoriteService.java
+2
-2
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/configuration/AuthConfiguration.java
...rk/apollo/portal/spi/configuration/AuthConfiguration.java
+4
-5
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/configuration/AuthFilterConfiguration.java
...llo/portal/spi/configuration/AuthFilterConfiguration.java
+1
-1
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/ctrip/WebContextConfiguration.java
...work/apollo/portal/spi/ctrip/WebContextConfiguration.java
+2
-2
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/defaultimpl/DefaultRolePermissionService.java
.../portal/spi/defaultimpl/DefaultRolePermissionService.java
+4
-4
apollo-portal/src/main/resources/application.yml
apollo-portal/src/main/resources/application.yml
+3
-6
apollo-portal/src/main/scripts/startup.sh
apollo-portal/src/main/scripts/startup.sh
+1
-1
apollo-portal/src/test/java/com/ctrip/framework/apollo/openapi/filter/ConsumerAuthenticationFilterTest.java
...ollo/openapi/filter/ConsumerAuthenticationFilterTest.java
+1
-1
apollo-portal/src/test/java/com/ctrip/framework/apollo/openapi/service/ConsumerServiceTest.java
...framework/apollo/openapi/service/ConsumerServiceTest.java
+4
-3
apollo-portal/src/test/java/com/ctrip/framework/apollo/openapi/util/ConsumerAuditUtilTest.java
.../framework/apollo/openapi/util/ConsumerAuditUtilTest.java
+1
-1
apollo-portal/src/test/java/com/ctrip/framework/apollo/openapi/util/ConsumerAuthUtilTest.java
...p/framework/apollo/openapi/util/ConsumerAuthUtilTest.java
+1
-1
apollo-portal/src/test/java/com/ctrip/framework/apollo/portal/AbstractIntegrationTest.java
...trip/framework/apollo/portal/AbstractIntegrationTest.java
+5
-6
apollo-portal/src/test/java/com/ctrip/framework/apollo/portal/service/FavoriteServiceTest.java
.../framework/apollo/portal/service/FavoriteServiceTest.java
+8
-8
apollo-portal/src/test/java/com/ctrip/framework/apollo/portal/spi/defaultImpl/RolePermissionServiceTest.java
...llo/portal/spi/defaultImpl/RolePermissionServiceTest.java
+3
-3
apollo-portal/src/test/resources/application.properties
apollo-portal/src/test/resources/application.properties
+1
-1
apollo-portal/src/test/resources/application.yml
apollo-portal/src/test/resources/application.yml
+0
-7
pom.xml
pom.xml
+21
-8
No files found.
apollo-adminservice/pom.xml
View file @
55a0e1b8
...
...
@@ -22,17 +22,15 @@
<!-- end of apollo -->
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-eureka-server
</artifactId>
<artifactId>
spring-cloud-starter-
netflix-
eureka-server
</artifactId>
<scope>
test
</scope>
<exclusions>
<exclusion>
<artifactId>
spring-cloud-starter-archaius
</artifactId>
<artifactId>
spring-cloud-starter-netflix-archaius
</artifactId>
<groupId>
org.springframework.cloud
</groupId>
</exclusion>
<exclusion>
<artifactId>
spring-cloud-starter-ribbon
</artifactId>
<artifactId>
spring-cloud-starter-
netflix-
ribbon
</artifactId>
<groupId>
org.springframework.cloud
</groupId>
</exclusion>
<exclusion>
...
...
apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/AdminServiceHealthIndicator.java
View file @
55a0e1b8
...
...
@@ -24,7 +24,7 @@ public class AdminServiceHealthIndicator implements HealthIndicator {
}
private
int
check
()
{
PageRequest
pageable
=
new
PageRequest
(
0
,
1
);
PageRequest
pageable
=
PageRequest
.
of
(
0
,
1
);
appService
.
findAll
(
pageable
);
return
0
;
}
...
...
apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/InstanceConfigController.java
View file @
55a0e1b8
...
...
@@ -183,7 +183,7 @@ public class InstanceConfigController {
@RequestParam
(
"clusterName"
)
String
clusterName
,
@RequestParam
(
"namespaceName"
)
String
namespaceName
)
{
Page
<
Instance
>
instances
=
instanceService
.
findInstancesByNamespace
(
appId
,
clusterName
,
namespaceName
,
new
PageRequest
(
0
,
1
));
namespaceName
,
PageRequest
.
of
(
0
,
1
));
return
instances
.
getTotalElements
();
}
}
apollo-adminservice/src/main/resources/adminservice.properties
View file @
55a0e1b8
...
...
@@ -3,3 +3,4 @@ spring.application.name= apollo-adminservice
ctrip.appid
=
100003172
server.port
=
8090
logging.file
=
/opt/logs/100003172/apollo-adminservice.log
spring.jmx.default-domain
=
apollo-adminservice
apollo-adminservice/src/main/resources/bootstrap.yml
View file @
55a0e1b8
...
...
@@ -2,6 +2,8 @@ eureka:
instance
:
hostname
:
${hostname:localhost}
preferIpAddress
:
true
status-page-url-path
:
/info
health-check-url-path
:
/health
client
:
serviceUrl
:
defaultZone
:
http://${eureka.instance.hostname}:8080/eureka/
...
...
@@ -9,15 +11,7 @@ eureka:
enabled
:
true
eurekaServiceUrlPollIntervalSeconds
:
60
endpoints
:
health
:
sensitive
:
false
management
:
security
:
enabled
:
false
health
:
status
:
order
:
DOWN, OUT_OF_SERVICE, UNKNOWN, UP
apollo-adminservice/src/main/scripts/startup.sh
View file @
55a0e1b8
...
...
@@ -99,7 +99,7 @@ declare -i max_counter=48 # 48*5=240s
declare
-i
total_time
=
0
printf
"Waiting for server startup"
until
[[
((
counter
-ge
max_counter
))
||
"
$(
curl
-X
GET
--silent
--connect-timeout
1
--max-time
2
--head
$SERVER_URL
|
grep
"
Coyote
"
)
"
!=
""
]]
;
until
[[
((
counter
-ge
max_counter
))
||
"
$(
curl
-X
GET
--silent
--connect-timeout
1
--max-time
2
--head
$SERVER_URL
|
grep
"
HTTP
"
)
"
!=
""
]]
;
do
printf
"."
counter+
=
1
...
...
apollo-adminservice/src/test/java/com/ctrip/framework/apollo/adminservice/controller/AbstractControllerTest.java
View file @
55a0e1b8
...
...
@@ -5,10 +5,10 @@ import com.ctrip.framework.apollo.AdminServiceTestConfiguration;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.autoconfigure.
web
.HttpMessageConverters
;
import
org.springframework.boot.test.
SpringApplicationConfiguration
;
import
org.springframework.boot.test.
TestRestTemplate
;
import
org.springframework.boot.test.
WebIntegrationTest
;
import
org.springframework.boot.autoconfigure.
http
.HttpMessageConverters
;
import
org.springframework.boot.test.
context.SpringBootTest
;
import
org.springframework.boot.test.
context.SpringBootTest.WebEnvironment
;
import
org.springframework.boot.test.
web.client.TestRestTemplate
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
org.springframework.web.client.DefaultResponseErrorHandler
;
import
org.springframework.web.client.RestTemplate
;
...
...
@@ -16,14 +16,13 @@ import org.springframework.web.client.RestTemplate;
import
javax.annotation.PostConstruct
;
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@SpringApplicationConfiguration
(
classes
=
AdminServiceTestConfiguration
.
class
)
@WebIntegrationTest
(
randomPort
=
true
)
@SpringBootTest
(
classes
=
AdminServiceTestConfiguration
.
class
,
webEnvironment
=
WebEnvironment
.
RANDOM_PORT
)
public
abstract
class
AbstractControllerTest
{
@Autowired
private
HttpMessageConverters
httpMessageConverters
;
RestTemplate
restTemplate
=
new
Tes
tRestTemplate
();
protected
RestTemplate
restTemplate
=
(
new
TestRestTemplate
()).
ge
tRestTemplate
();
@PostConstruct
private
void
postConstruct
()
{
...
...
apollo-adminservice/src/test/java/com/ctrip/framework/apollo/adminservice/controller/AppControllerTest.java
View file @
55a0e1b8
...
...
@@ -53,7 +53,7 @@ public class AppControllerTest extends AbstractControllerTest {
Assert
.
assertEquals
(
dto
.
getAppId
(),
result
.
getAppId
());
Assert
.
assertTrue
(
result
.
getId
()
>
0
);
App
savedApp
=
appRepository
.
find
One
(
result
.
getId
()
);
App
savedApp
=
appRepository
.
find
ById
(
result
.
getId
()).
orElse
(
null
);
Assert
.
assertEquals
(
dto
.
getAppId
(),
savedApp
.
getAppId
());
Assert
.
assertNotNull
(
savedApp
.
getDataChangeCreatedTime
());
}
...
...
@@ -69,7 +69,7 @@ public class AppControllerTest extends AbstractControllerTest {
Assert
.
assertEquals
(
dto
.
getAppId
(),
first
.
getAppId
());
Assert
.
assertTrue
(
first
.
getId
()
>
0
);
App
savedApp
=
appRepository
.
find
One
(
first
.
getId
()
);
App
savedApp
=
appRepository
.
find
ById
(
first
.
getId
()).
orElse
(
null
);
Assert
.
assertEquals
(
dto
.
getAppId
(),
savedApp
.
getAppId
());
Assert
.
assertNotNull
(
savedApp
.
getDataChangeCreatedTime
());
...
...
@@ -108,7 +108,7 @@ public class AppControllerTest extends AbstractControllerTest {
restTemplate
.
delete
(
"http://localhost:{port}/apps/{appId}?operator={operator}"
,
port
,
app
.
getAppId
(),
"test"
);
App
deletedApp
=
appRepository
.
find
One
(
app
.
getId
()
);
App
deletedApp
=
appRepository
.
find
ById
(
app
.
getId
()).
orElse
(
null
);
Assert
.
assertNull
(
deletedApp
);
}
...
...
apollo-adminservice/src/test/java/com/ctrip/framework/apollo/adminservice/controller/ControllerExceptionTest.java
View file @
55a0e1b8
...
...
@@ -56,7 +56,7 @@ public class ControllerExceptionTest {
@Test
public
void
testFindEmpty
()
{
when
(
appService
.
findAll
(
any
(
Pageable
.
class
))).
thenReturn
(
new
ArrayList
<
App
>());
Pageable
pageable
=
new
PageRequest
(
0
,
10
);
Pageable
pageable
=
PageRequest
.
of
(
0
,
10
);
List
<
AppDTO
>
appDTOs
=
appController
.
find
(
null
,
pageable
);
Assert
.
assertNotNull
(
appDTOs
);
Assert
.
assertEquals
(
0
,
appDTOs
.
size
());
...
...
@@ -68,7 +68,7 @@ public class ControllerExceptionTest {
@Test
public
void
testFindByName
()
{
Pageable
pageable
=
new
PageRequest
(
0
,
10
);
Pageable
pageable
=
PageRequest
.
of
(
0
,
10
);
List
<
AppDTO
>
appDTOs
=
appController
.
find
(
"unexist"
,
pageable
);
Assert
.
assertNotNull
(
appDTOs
);
Assert
.
assertEquals
(
0
,
appDTOs
.
size
());
...
...
apollo-adminservice/src/test/java/com/ctrip/framework/apollo/adminservice/controller/InstanceConfigControllerTest.java
View file @
55a0e1b8
...
...
@@ -20,6 +20,7 @@ import org.mockito.Mock;
import
org.mockito.runners.MockitoJUnitRunner
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.PageImpl
;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.test.util.ReflectionTestUtils
;
...
...
@@ -47,7 +48,6 @@ public class InstanceConfigControllerTest {
@Mock
private
InstanceService
instanceService
;
@Mock
private
Pageable
pageable
;
@Before
...
...
@@ -55,6 +55,8 @@ public class InstanceConfigControllerTest {
instanceConfigController
=
new
InstanceConfigController
();
ReflectionTestUtils
.
setField
(
instanceConfigController
,
"releaseService"
,
releaseService
);
ReflectionTestUtils
.
setField
(
instanceConfigController
,
"instanceService"
,
instanceService
);
pageable
=
PageRequest
.
of
(
0
,
2
);
}
@Test
...
...
@@ -230,7 +232,6 @@ public class InstanceConfigControllerTest {
String
someIp
=
"someIp"
;
long
someInstanceId
=
1
;
long
anotherInstanceId
=
2
;
Pageable
pageable
=
mock
(
Pageable
.
class
);
Instance
someInstance
=
assembleInstance
(
someInstanceId
,
someAppId
,
someClusterName
,
someNamespaceName
,
someIp
);
...
...
@@ -270,7 +271,6 @@ public class InstanceConfigControllerTest {
String
someIp
=
"someIp"
;
long
someInstanceId
=
1
;
long
anotherInstanceId
=
2
;
Pageable
pageable
=
mock
(
Pageable
.
class
);
Instance
someInstance
=
assembleInstance
(
someInstanceId
,
someAppId
,
someClusterName
,
someNamespaceName
,
someIp
);
...
...
@@ -352,4 +352,4 @@ public class InstanceConfigControllerTest {
instanceConfig
.
setReleaseDeliveryTime
(
releaseDeliveryTime
);
return
instanceConfig
;
}
}
\ No newline at end of file
}
apollo-adminservice/src/test/java/com/ctrip/framework/apollo/adminservice/controller/ItemSetControllerTest.java
View file @
55a0e1b8
...
...
@@ -11,7 +11,7 @@ import com.ctrip.framework.apollo.common.dto.NamespaceDTO;
import
org.junit.Assert
;
import
org.junit.Test
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.TestRestTemplate
;
import
org.springframework.boot.test.
web.client.
TestRestTemplate
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.test.context.jdbc.Sql
;
...
...
@@ -47,7 +47,7 @@ public class ItemSetControllerTest extends AbstractControllerTest {
ItemChangeSets
itemSet
=
new
ItemChangeSets
();
itemSet
.
setDataChangeLastModifiedBy
(
"created"
);
RestTemplate
createdTemplate
=
new
Tes
tRestTemplate
();
RestTemplate
createdTemplate
=
(
new
TestRestTemplate
()).
ge
tRestTemplate
();
createdTemplate
.
setMessageConverters
(
restTemplate
.
getMessageConverters
());
int
createdSize
=
3
;
...
...
@@ -96,7 +96,7 @@ public class ItemSetControllerTest extends AbstractControllerTest {
ItemChangeSets
createChangeSet
=
new
ItemChangeSets
();
createChangeSet
.
setDataChangeLastModifiedBy
(
"created"
);
RestTemplate
createdRestTemplate
=
new
Tes
tRestTemplate
();
RestTemplate
createdRestTemplate
=
(
new
TestRestTemplate
()).
ge
tRestTemplate
();
createdRestTemplate
.
setMessageConverters
(
restTemplate
.
getMessageConverters
());
int
createdSize
=
3
;
...
...
@@ -123,7 +123,7 @@ public class ItemSetControllerTest extends AbstractControllerTest {
ItemChangeSets
updateChangeSet
=
new
ItemChangeSets
();
updateChangeSet
.
setDataChangeLastModifiedBy
(
"updated"
);
RestTemplate
updatedRestTemplate
=
new
Tes
tRestTemplate
();
RestTemplate
updatedRestTemplate
=
(
new
TestRestTemplate
()).
ge
tRestTemplate
();
updatedRestTemplate
.
setMessageConverters
(
restTemplate
.
getMessageConverters
());
int
updatedSize
=
2
;
...
...
@@ -170,7 +170,7 @@ public class ItemSetControllerTest extends AbstractControllerTest {
ItemChangeSets
createChangeSet
=
new
ItemChangeSets
();
createChangeSet
.
setDataChangeLastModifiedBy
(
"created"
);
RestTemplate
createdTemplate
=
new
Tes
tRestTemplate
();
RestTemplate
createdTemplate
=
(
new
TestRestTemplate
()).
ge
tRestTemplate
();
createdTemplate
.
setMessageConverters
(
restTemplate
.
getMessageConverters
());
int
createdSize
=
3
;
...
...
@@ -196,7 +196,7 @@ public class ItemSetControllerTest extends AbstractControllerTest {
ItemChangeSets
deleteChangeSet
=
new
ItemChangeSets
();
deleteChangeSet
.
setDataChangeLastModifiedBy
(
"deleted"
);
RestTemplate
deletedTemplate
=
new
Tes
tRestTemplate
();
RestTemplate
deletedTemplate
=
(
new
TestRestTemplate
()).
ge
tRestTemplate
();
deletedTemplate
.
setMessageConverters
(
restTemplate
.
getMessageConverters
());
int
deletedSize
=
1
;
...
...
apollo-adminservice/src/test/resources/application.properties
View file @
55a0e1b8
spring.datasource.url
=
jdbc:h2:mem:~/apolloconfigdb;mode=mysql;DB_CLOSE_ON_EXIT=FALSE;DB_CLOSE_DELAY=-1
spring.jpa.hibernate.naming
_strategy
=
org.hibernate.cfg.EJB3NamingStrategy
spring.jpa.hibernate.naming
.physical-strategy
=
org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
spring.jpa.properties.hibernate.show_sql
=
false
spring.h2.console.enabled
=
true
spring.h2.console.settings.web-allow-others
=
true
...
...
apollo-adminservice/src/test/resources/bootstrap.yml
View file @
55a0e1b8
eureka
:
instance
:
hostname
:
${hostname:localhost}
preferIpAddress
:
true
status-page-url-path
:
/info
health-check-url-path
:
/health
client
:
serviceUrl
:
defaultZone
:
http://${eureka.instance.hostname}:8090/eureka/
healthcheck
:
enabled
:
true
endpoints
:
health
:
sensitive
:
false
management
:
security
:
enabled
:
false
health
:
status
:
order
:
DOWN, OUT_OF_SERVICE, UNKNOWN, UP
apollo-assembly/src/main/java/com/ctrip/framework/apollo/assembly/ApolloApplication.java
View file @
55a0e1b8
...
...
@@ -6,6 +6,7 @@ import com.ctrip.framework.apollo.portal.PortalApplication;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.boot.WebApplicationType
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
;
import
org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration
;
...
...
@@ -24,7 +25,7 @@ public class ApolloApplication {
* Common
*/
ConfigurableApplicationContext
commonContext
=
new
SpringApplicationBuilder
(
ApolloApplication
.
class
).
web
(
false
).
run
(
args
);
new
SpringApplicationBuilder
(
ApolloApplication
.
class
).
web
(
WebApplicationType
.
NONE
).
run
(
args
);
logger
.
info
(
commonContext
.
getId
()
+
" isActive: "
+
commonContext
.
isActive
());
/**
...
...
apollo-assembly/src/test/java/com/ctrip/framework/apollo/assembly/LocalApolloApplication.java
View file @
55a0e1b8
...
...
@@ -6,6 +6,7 @@ import com.ctrip.framework.apollo.portal.PortalApplication;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.boot.WebApplicationType
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
;
import
org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration
;
...
...
@@ -24,7 +25,7 @@ public class LocalApolloApplication {
* Common
*/
ConfigurableApplicationContext
commonContext
=
new
SpringApplicationBuilder
(
ApolloApplication
.
class
).
web
(
false
).
run
(
args
);
new
SpringApplicationBuilder
(
ApolloApplication
.
class
).
web
(
WebApplicationType
.
NONE
).
run
(
args
);
logger
.
info
(
commonContext
.
getId
()
+
" isActive: "
+
commonContext
.
isActive
());
/**
...
...
apollo-assembly/src/test/resources/application.properties
View file @
55a0e1b8
spring.datasource.url
=
jdbc:h2:mem:~/apolloconfigdb;mode=mysql;DB_CLOSE_ON_EXIT=FALSE
spring.jpa.hibernate.naming
_strategy
=
org.hibernate.cfg.EJB3NamingStrategy
spring.jpa.hibernate.naming
.physical-strategy
=
org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
spring.jpa.properties.hibernate.show_sql
=
false
spring.h2.console.enabled
=
true
spring.h2.console.settings.web-allow-others
=
true
...
...
apollo-biz/pom.xml
View file @
55a0e1b8
...
...
@@ -21,7 +21,7 @@
<!-- eureka -->
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-
eureka
</artifactId>
<artifactId>
spring-cloud-starter-
netflix-eureka-client
</artifactId>
</dependency>
<!-- end of eureka -->
<dependency>
...
...
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Instance.java
View file @
55a0e1b8
...
...
@@ -7,6 +7,7 @@ import java.util.Date;
import
javax.persistence.Column
;
import
javax.persistence.Entity
;
import
javax.persistence.GeneratedValue
;
import
javax.persistence.GenerationType
;
import
javax.persistence.Id
;
import
javax.persistence.PrePersist
;
import
javax.persistence.Table
;
...
...
@@ -18,7 +19,7 @@ import javax.persistence.Table;
@Table
(
name
=
"Instance"
)
public
class
Instance
{
@Id
@GeneratedValue
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
@Column
(
name
=
"Id"
)
private
long
id
;
...
...
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/InstanceConfig.java
View file @
55a0e1b8
...
...
@@ -7,6 +7,7 @@ import java.util.Date;
import
javax.persistence.Column
;
import
javax.persistence.Entity
;
import
javax.persistence.GeneratedValue
;
import
javax.persistence.GenerationType
;
import
javax.persistence.Id
;
import
javax.persistence.PrePersist
;
import
javax.persistence.PreUpdate
;
...
...
@@ -19,7 +20,7 @@ import javax.persistence.Table;
@Table
(
name
=
"InstanceConfig"
)
public
class
InstanceConfig
{
@Id
@GeneratedValue
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
@Column
(
name
=
"Id"
)
private
long
id
;
...
...
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/ReleaseMessage.java
View file @
55a0e1b8
...
...
@@ -7,6 +7,7 @@ import java.util.Date;
import
javax.persistence.Column
;
import
javax.persistence.Entity
;
import
javax.persistence.GeneratedValue
;
import
javax.persistence.GenerationType
;
import
javax.persistence.Id
;
import
javax.persistence.PrePersist
;
import
javax.persistence.Table
;
...
...
@@ -18,7 +19,7 @@ import javax.persistence.Table;
@Table
(
name
=
"ReleaseMessage"
)
public
class
ReleaseMessage
{
@Id
@GeneratedValue
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
@Column
(
name
=
"Id"
)
private
long
id
;
...
...
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/message/DatabaseMessageSender.java
View file @
55a0e1b8
...
...
@@ -88,7 +88,7 @@ public class DatabaseMessageSender implements MessageSender {
private
void
cleanMessage
(
Long
id
)
{
boolean
hasMore
=
true
;
//double check in case the release message is rolled back
ReleaseMessage
releaseMessage
=
releaseMessageRepository
.
find
One
(
id
);
ReleaseMessage
releaseMessage
=
releaseMessageRepository
.
find
ById
(
id
).
orElse
(
null
);
if
(
releaseMessage
==
null
)
{
return
;
}
...
...
@@ -96,7 +96,7 @@ public class DatabaseMessageSender implements MessageSender {
List
<
ReleaseMessage
>
messages
=
releaseMessageRepository
.
findFirst100ByMessageAndIdLessThanOrderByIdAsc
(
releaseMessage
.
getMessage
(),
releaseMessage
.
getId
());
releaseMessageRepository
.
delete
(
messages
);
releaseMessageRepository
.
delete
All
(
messages
);
hasMore
=
messages
.
size
()
==
100
;
messages
.
forEach
(
toRemove
->
Tracer
.
logEvent
(
...
...
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/AppService.java
View file @
55a0e1b8
...
...
@@ -31,7 +31,7 @@ public class AppService {
@Transactional
public
void
delete
(
long
id
,
String
operator
)
{
App
app
=
appRepository
.
find
One
(
id
);
App
app
=
appRepository
.
find
ById
(
id
).
orElse
(
null
);
if
(
app
==
null
)
{
return
;
}
...
...
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ClusterService.java
View file @
55a0e1b8
...
...
@@ -40,7 +40,7 @@ public class ClusterService {
}
public
Cluster
findOne
(
long
clusterId
)
{
return
clusterRepository
.
find
One
(
clusterId
);
return
clusterRepository
.
find
ById
(
clusterId
).
orElse
(
null
);
}
public
List
<
Cluster
>
findParentClusters
(
String
appId
)
{
...
...
@@ -85,7 +85,7 @@ public class ClusterService {
@Transactional
public
void
delete
(
long
id
,
String
operator
)
{
Cluster
cluster
=
clusterRepository
.
find
One
(
id
);
Cluster
cluster
=
clusterRepository
.
find
ById
(
id
).
orElse
(
null
);
if
(
cluster
==
null
)
{
throw
new
BadRequestException
(
"cluster not exist"
);
}
...
...
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/InstanceService.java
View file @
55a0e1b8
...
...
@@ -41,7 +41,7 @@ public class InstanceService {
}
public
List
<
Instance
>
findInstancesByIds
(
Set
<
Long
>
instanceIds
)
{
Iterable
<
Instance
>
instances
=
instanceRepository
.
findAll
(
instanceIds
);
Iterable
<
Instance
>
instances
=
instanceRepository
.
findAll
ById
(
instanceIds
);
if
(
instances
==
null
)
{
return
Collections
.
emptyList
();
}
...
...
@@ -159,7 +159,7 @@ public class InstanceService {
@Transactional
public
InstanceConfig
updateInstanceConfig
(
InstanceConfig
instanceConfig
)
{
InstanceConfig
existedInstanceConfig
=
instanceConfigRepository
.
find
One
(
instanceConfig
.
getId
()
);
InstanceConfig
existedInstanceConfig
=
instanceConfigRepository
.
find
ById
(
instanceConfig
.
getId
()).
orElse
(
null
);
Preconditions
.
checkArgument
(
existedInstanceConfig
!=
null
,
String
.
format
(
"Instance config %d doesn't exist"
,
instanceConfig
.
getId
()));
...
...
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ItemService.java
View file @
55a0e1b8
...
...
@@ -38,7 +38,7 @@ public class ItemService {
@Transactional
public
Item
delete
(
long
id
,
String
operator
)
{
Item
item
=
itemRepository
.
find
One
(
id
);
Item
item
=
itemRepository
.
find
ById
(
id
).
orElse
(
null
);
if
(
item
==
null
)
{
throw
new
IllegalArgumentException
(
"item not exist. ID:"
+
id
);
}
...
...
@@ -81,7 +81,7 @@ public class ItemService {
}
public
Item
findOne
(
long
itemId
)
{
Item
item
=
itemRepository
.
find
One
(
itemId
);
Item
item
=
itemRepository
.
find
ById
(
itemId
).
orElse
(
null
);
return
item
;
}
...
...
@@ -147,7 +147,7 @@ public class ItemService {
@Transactional
public
Item
update
(
Item
item
)
{
checkItemValueLength
(
item
.
getNamespaceId
(),
item
.
getValue
());
Item
managedItem
=
itemRepository
.
find
One
(
item
.
getId
()
);
Item
managedItem
=
itemRepository
.
find
ById
(
item
.
getId
()).
orElse
(
null
);
BeanUtils
.
copyEntityProperties
(
item
,
managedItem
);
managedItem
=
itemRepository
.
save
(
managedItem
);
...
...
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/NamespaceService.java
View file @
55a0e1b8
...
...
@@ -67,7 +67,7 @@ public class NamespaceService {
public
Namespace
findOne
(
Long
namespaceId
)
{
return
namespaceRepository
.
find
One
(
namespaceId
);
return
namespaceRepository
.
find
ById
(
namespaceId
).
orElse
(
null
);
}
public
Namespace
findOne
(
String
appId
,
String
clusterName
,
String
namespaceName
)
{
...
...
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ReleaseService.java
View file @
55a0e1b8
...
...
@@ -64,7 +64,7 @@ public class ReleaseService {
private
ItemSetService
itemSetService
;
public
Release
findOne
(
long
releaseId
)
{
return
releaseRepository
.
find
One
(
releaseId
);
return
releaseRepository
.
find
ById
(
releaseId
).
orElse
(
null
);
}
...
...
@@ -73,7 +73,7 @@ public class ReleaseService {
}
public
List
<
Release
>
findByReleaseIds
(
Set
<
Long
>
releaseIds
)
{
Iterable
<
Release
>
releases
=
releaseRepository
.
findAll
(
releaseIds
);
Iterable
<
Release
>
releases
=
releaseRepository
.
findAll
ById
(
releaseIds
);
if
(
releases
==
null
)
{
return
Collections
.
emptyList
();
}
...
...
@@ -397,7 +397,7 @@ public class ReleaseService {
String
clusterName
=
release
.
getClusterName
();
String
namespaceName
=
release
.
getNamespaceName
();
PageRequest
page
=
new
PageRequest
(
0
,
2
);
PageRequest
page
=
PageRequest
.
of
(
0
,
2
);
List
<
Release
>
twoLatestActiveReleases
=
findActiveReleases
(
appId
,
clusterName
,
namespaceName
,
page
);
if
(
twoLatestActiveReleases
==
null
||
twoLatestActiveReleases
.
size
()
<
2
)
{
throw
new
BadRequestException
(
String
.
format
(
...
...
apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/AbstractIntegrationTest.java
View file @
55a0e1b8
package
com
.
ctrip
.
framework
.
apollo
.
biz
;
import
org.junit.runner.RunWith
;
import
org.springframework.boot.test.
SpringApplicationConfiguration
;
import
org.springframework.boot.test.
WebIntegrationTes
t
;
import
org.springframework.boot.test.
context.SpringBootTest
;
import
org.springframework.boot.test.
context.SpringBootTest.WebEnvironmen
t
;
import
org.springframework.test.annotation.Rollback
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
org.springframework.transaction.annotation.Transactional
;
...
...
@@ -10,8 +10,7 @@ import org.springframework.transaction.annotation.Transactional;
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@Rollback
@Transactional
@WebIntegrationTest
(
randomPort
=
true
)
@SpringApplicationConfiguration
(
classes
=
BizTestConfiguration
.
class
)
@SpringBootTest
(
classes
=
BizTestConfiguration
.
class
,
webEnvironment
=
WebEnvironment
.
RANDOM_PORT
)
public
abstract
class
AbstractIntegrationTest
{
}
apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/config/BizConfigTest.java
View file @
55a0e1b8
...
...
@@ -77,4 +77,4 @@ public class BizConfigTest {
assertEquals
(
someValidValue
,
bizConfig
.
checkInt
(
someValidValue
,
Integer
.
MIN_VALUE
,
Integer
.
MAX_VALUE
,
someDefaultValue
));
}
}
\ No newline at end of file
}
apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/repository/AppRepositoryTest.java
View file @
55a0e1b8
...
...
@@ -51,7 +51,7 @@ public class AppRepositoryTest extends AbstractIntegrationTest{
Assert
.
assertEquals
(
1
,
appRepository
.
count
());
appRepository
.
delete
(
app
.
getId
());
appRepository
.
delete
ById
(
app
.
getId
());
Assert
.
assertEquals
(
0
,
appRepository
.
count
());
}
...
...
apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/InstanceServiceTest.java
View file @
55a0e1b8
...
...
@@ -119,7 +119,7 @@ public class InstanceServiceTest extends AbstractIntegrationTest {
String
someConfigClusterName
=
"someConfigClusterName"
;
String
someConfigNamespaceName
=
"someConfigNamespaceName"
;
Date
someValidDate
=
new
Date
();
Pageable
pageable
=
new
PageRequest
(
0
,
10
);
Pageable
pageable
=
PageRequest
.
of
(
0
,
10
);
String
someReleaseKey
=
"someReleaseKey"
;
Calendar
calendar
=
Calendar
.
getInstance
();
...
...
@@ -165,7 +165,7 @@ public class InstanceServiceTest extends AbstractIntegrationTest {
someConfigNamespaceName
,
someReleaseKey
,
someValidDate
);
Page
<
Instance
>
result
=
instanceService
.
findInstancesByNamespace
(
someConfigAppId
,
someConfigClusterName
,
someConfigNamespaceName
,
new
PageRequest
(
0
,
10
));
someConfigClusterName
,
someConfigNamespaceName
,
PageRequest
.
of
(
0
,
10
));
assertEquals
(
Lists
.
newArrayList
(
someInstance
,
anotherInstance
),
result
.
getContent
());
}
...
...
@@ -197,9 +197,9 @@ public class InstanceServiceTest extends AbstractIntegrationTest {
someConfigNamespaceName
,
someReleaseKey
,
someValidDate
);
Page
<
Instance
>
result
=
instanceService
.
findInstancesByNamespaceAndInstanceAppId
(
someAppId
,
someConfigAppId
,
someConfigClusterName
,
someConfigNamespaceName
,
new
PageRequest
(
0
,
10
));
someConfigAppId
,
someConfigClusterName
,
someConfigNamespaceName
,
PageRequest
.
of
(
0
,
10
));
Page
<
Instance
>
anotherResult
=
instanceService
.
findInstancesByNamespaceAndInstanceAppId
(
anotherAppId
,
someConfigAppId
,
someConfigClusterName
,
someConfigNamespaceName
,
new
PageRequest
(
0
,
10
));
someConfigAppId
,
someConfigClusterName
,
someConfigNamespaceName
,
PageRequest
.
of
(
0
,
10
));
assertEquals
(
Lists
.
newArrayList
(
someInstance
),
result
.
getContent
());
assertEquals
(
Lists
.
newArrayList
(
anotherInstance
),
anotherResult
.
getContent
());
...
...
apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/NamespaceBranchServiceTest.java
View file @
55a0e1b8
...
...
@@ -28,7 +28,7 @@ public class NamespaceBranchServiceTest extends AbstractIntegrationTest {
private
String
testNamespace
=
"application"
;
private
String
testBranchName
=
"child-cluster"
;
private
String
operator
=
"apollo"
;
private
Pageable
pageable
=
new
PageRequest
(
0
,
10
);
private
Pageable
pageable
=
PageRequest
.
of
(
0
,
10
);
@Test
@Sql
(
scripts
=
"/sql/namespace-branch-test.sql"
,
executionPhase
=
Sql
.
ExecutionPhase
.
BEFORE_TEST_METHOD
)
...
...
apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/NamespaceServiceIntegrationTest.java
View file @
55a0e1b8
...
...
@@ -64,19 +64,19 @@ public class NamespaceServiceIntegrationTest extends AbstractIntegrationTest {
namespaceService
.
deleteNamespace
(
namespace
,
testUser
);
List
<
Item
>
items
=
itemService
.
findItemsWithoutOrdered
(
testApp
,
testCluster
,
testPrivateNamespace
);
List
<
Commit
>
commits
=
commitService
.
find
(
testApp
,
testCluster
,
testPrivateNamespace
,
new
PageRequest
(
0
,
10
));
List
<
Commit
>
commits
=
commitService
.
find
(
testApp
,
testCluster
,
testPrivateNamespace
,
PageRequest
.
of
(
0
,
10
));
AppNamespace
appNamespace
=
appNamespaceService
.
findOne
(
testApp
,
testPrivateNamespace
);
List
<
Cluster
>
childClusters
=
clusterService
.
findChildClusters
(
testApp
,
testCluster
);
InstanceConfig
instanceConfig
=
instanceConfigRepository
.
find
One
(
1L
);
InstanceConfig
instanceConfig
=
instanceConfigRepository
.
find
ById
(
1L
).
orElse
(
null
);
List
<
Release
>
parentNamespaceReleases
=
releaseService
.
findActiveReleases
(
testApp
,
testCluster
,
testPrivateNamespace
,
new
PageRequest
(
0
,
10
));
PageRequest
.
of
(
0
,
10
));
List
<
Release
>
childNamespaceReleases
=
releaseService
.
findActiveReleases
(
testApp
,
testChildCluster
,
testPrivateNamespace
,
new
PageRequest
(
0
,
10
));
PageRequest
.
of
(
0
,
10
));
Page
<
ReleaseHistory
>
releaseHistories
=
releaseHistoryService
.
findReleaseHistoriesByNamespace
(
testApp
,
testCluster
,
testPrivateNamespace
,
new
PageRequest
(
0
,
10
));
.
findReleaseHistoriesByNamespace
(
testApp
,
testCluster
,
testPrivateNamespace
,
PageRequest
.
of
(
0
,
10
));
assertEquals
(
0
,
items
.
size
());
assertEquals
(
0
,
commits
.
size
());
...
...
apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/NamespaceServiceTest.java
View file @
55a0e1b8
...
...
@@ -38,7 +38,7 @@ public class NamespaceServiceTest extends AbstractUnitTest {
@Test
(
expected
=
BadRequestException
.
class
)
public
void
testFindPublicAppNamespaceWithWrongNamespace
()
{
Pageable
page
=
new
PageRequest
(
0
,
10
);
Pageable
page
=
PageRequest
.
of
(
0
,
10
);
when
(
appNamespaceService
.
findPublicNamespaceByName
(
testPublicAppNamespace
)).
thenReturn
(
null
);
...
...
@@ -59,7 +59,7 @@ public class NamespaceServiceTest extends AbstractUnitTest {
MockBeanFactory
.
mockNamespace
(
"app2"
,
ConfigConsts
.
CLUSTER_NAME_DEFAULT
,
testPublicAppNamespace
);
Pageable
page
=
new
PageRequest
(
0
,
10
);
Pageable
page
=
PageRequest
.
of
(
0
,
10
);
when
(
namespaceRepository
.
findByNamespaceName
(
testPublicAppNamespace
,
page
))
.
thenReturn
(
Arrays
.
asList
(
firstParentNamespace
,
secondParentNamespace
));
...
...
apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/ReleaseCreationTest.java
View file @
55a0e1b8
...
...
@@ -36,7 +36,7 @@ public class ReleaseCreationTest extends AbstractIntegrationTest {
private
String
testApp
=
"test"
;
private
String
testNamespace
=
"application"
;
private
String
operator
=
"apollo"
;
private
Pageable
pageable
=
new
PageRequest
(
0
,
10
);
private
Pageable
pageable
=
PageRequest
.
of
(
0
,
10
);
@Test
@Sql
(
scripts
=
"/sql/release-creation-test.sql"
,
executionPhase
=
Sql
.
ExecutionPhase
.
BEFORE_TEST_METHOD
)
...
...
apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/ReleaseServiceTest.java
View file @
55a0e1b8
...
...
@@ -9,6 +9,7 @@ import com.ctrip.framework.apollo.biz.entity.Release;
import
com.ctrip.framework.apollo.biz.repository.ReleaseRepository
;
import
com.ctrip.framework.apollo.common.exception.BadRequestException
;
import
java.util.Optional
;
import
org.junit.Assert
;
import
org.junit.Before
;
import
org.junit.Test
;
...
...
@@ -65,13 +66,13 @@ public class ReleaseServiceTest extends AbstractUnitTest {
secondRelease
.
setNamespaceName
(
namespaceName
);
secondRelease
.
setAbandoned
(
false
);
pageRequest
=
new
PageRequest
(
0
,
2
);
pageRequest
=
PageRequest
.
of
(
0
,
2
);
}
@Test
(
expected
=
BadRequestException
.
class
)
public
void
testNamespaceNotExist
()
{
when
(
releaseRepository
.
find
One
(
releaseId
)).
thenReturn
(
firstRelease
);
when
(
releaseRepository
.
find
ById
(
releaseId
)).
thenReturn
(
Optional
.
of
(
firstRelease
)
);
releaseService
.
rollback
(
releaseId
,
user
);
}
...
...
@@ -79,7 +80,7 @@ public class ReleaseServiceTest extends AbstractUnitTest {
@Test
(
expected
=
BadRequestException
.
class
)
public
void
testHasNoRelease
()
{
when
(
releaseRepository
.
find
One
(
releaseId
)).
thenReturn
(
firstRelease
);
when
(
releaseRepository
.
find
ById
(
releaseId
)).
thenReturn
(
Optional
.
of
(
firstRelease
)
);
when
(
releaseRepository
.
findByAppIdAndClusterNameAndNamespaceNameAndIsAbandonedFalseOrderByIdDesc
(
appId
,
clusterName
,
namespaceName
,
...
...
@@ -92,7 +93,7 @@ public class ReleaseServiceTest extends AbstractUnitTest {
@Test
public
void
testRollback
()
{
when
(
releaseRepository
.
find
One
(
releaseId
)).
thenReturn
(
firstRelease
);
when
(
releaseRepository
.
find
ById
(
releaseId
)).
thenReturn
(
Optional
.
of
(
firstRelease
)
);
when
(
releaseRepository
.
findByAppIdAndClusterNameAndNamespaceNameAndIsAbandonedFalseOrderByIdDesc
(
appId
,
clusterName
,
namespaceName
,
...
...
@@ -166,7 +167,7 @@ public class ReleaseServiceTest extends AbstractUnitTest {
List
<
Release
>
someReleases
=
Lists
.
newArrayList
(
someRelease
,
anotherRelease
);
Set
<
Long
>
someReleaseIds
=
Sets
.
newHashSet
(
someReleaseId
,
anotherReleaseId
);
when
(
releaseRepository
.
findAll
(
someReleaseIds
)).
thenReturn
(
someReleases
);
when
(
releaseRepository
.
findAll
ById
(
someReleaseIds
)).
thenReturn
(
someReleases
);
List
<
Release
>
result
=
releaseService
.
findByReleaseIds
(
someReleaseIds
);
...
...
apollo-biz/src/test/resources/application.properties
View file @
55a0e1b8
spring.datasource.url
=
jdbc:h2:mem:~/apolloconfigdb;mode=mysql;DB_CLOSE_ON_EXIT=FALSE
spring.jpa.hibernate.naming
_strategy
=
org.hibernate.cfg.EJB3NamingStrategy
spring.jpa.hibernate.naming
.physical-strategy
=
org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
spring.jpa.properties.hibernate.show_sql
=
false
spring.h2.console.enabled
=
true
spring.h2.console.settings.web-allow-others
=
true
...
...
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/PropertiesConfigFileTest.java
View file @
55a0e1b8
...
...
@@ -6,7 +6,6 @@ import static org.junit.Assert.assertNull;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
static
org
.
mockito
.
Mockito
.
when
;
import
com.ctrip.framework.apollo.ConfigFile
;
import
com.ctrip.framework.apollo.ConfigFileChangeListener
;
import
com.ctrip.framework.apollo.enums.PropertyChangeType
;
import
com.ctrip.framework.apollo.model.ConfigFileChangeEvent
;
...
...
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollServiceTest.java
View file @
55a0e1b8
...
...
@@ -3,7 +3,6 @@ package com.ctrip.framework.apollo.internals;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
static
org
.
mockito
.
Matchers
.
any
;
import
static
org
.
mockito
.
Matchers
.
anyLong
;
import
static
org
.
mockito
.
Matchers
.
eq
;
import
static
org
.
mockito
.
Mockito
.
doAnswer
;
import
static
org
.
mockito
.
Mockito
.
mock
;
...
...
@@ -12,11 +11,9 @@ import static org.mockito.Mockito.times;
import
static
org
.
mockito
.
Mockito
.
verify
;
import
static
org
.
mockito
.
Mockito
.
when
;
import
com.ctrip.framework.apollo.Apollo
;
import
java.lang.reflect.Type
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Properties
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.atomic.AtomicInteger
;
...
...
apollo-client/src/test/java/com/ctrip/framework/apollo/spring/BootstrapConfigTest.java
View file @
55a0e1b8
...
...
@@ -20,7 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.autoconfigure.EnableAutoConfiguration
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
;
import
org.springframework.boot.test.
SpringApplicationConfiguration
;
import
org.springframework.boot.test.
context.SpringBootTest
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.test.annotation.DirtiesContext
;
...
...
@@ -36,7 +36,7 @@ public class BootstrapConfigTest {
private
static
final
String
FX_APOLLO_NAMESPACE
=
"FX.apollo"
;
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@Spring
ApplicationConfiguration
(
ConfigurationWithConditionalOnProperty
.
class
)
@Spring
BootTest
(
classes
=
ConfigurationWithConditionalOnProperty
.
class
)
@DirtiesContext
public
static
class
TestWithBootstrapEnabledAndDefaultNamespacesAndConditionalOn
extends
AbstractSpringIntegrationTest
{
...
...
@@ -90,7 +90,7 @@ public class BootstrapConfigTest {
}
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@Spring
ApplicationConfiguration
(
ConfigurationWithConditionalOnProperty
.
class
)
@Spring
BootTest
(
classes
=
ConfigurationWithConditionalOnProperty
.
class
)
@DirtiesContext
public
static
class
TestWithBootstrapEnabledAndNamespacesAndConditionalOn
extends
AbstractSpringIntegrationTest
{
...
...
@@ -132,7 +132,7 @@ public class BootstrapConfigTest {
}
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@Spring
ApplicationConfiguration
(
ConfigurationWithConditionalOnProperty
.
class
)
@Spring
BootTest
(
classes
=
ConfigurationWithConditionalOnProperty
.
class
)
@DirtiesContext
public
static
class
TestWithBootstrapEnabledAndDefaultNamespacesAndConditionalOnFailed
extends
AbstractSpringIntegrationTest
{
...
...
@@ -168,7 +168,7 @@ public class BootstrapConfigTest {
}
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@Spring
ApplicationConfiguration
(
ConfigurationWithoutConditionalOnProperty
.
class
)
@Spring
BootTest
(
classes
=
ConfigurationWithoutConditionalOnProperty
.
class
)
@DirtiesContext
public
static
class
TestWithBootstrapEnabledAndDefaultNamespacesAndConditionalOff
extends
AbstractSpringIntegrationTest
{
...
...
@@ -202,7 +202,7 @@ public class BootstrapConfigTest {
}
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@Spring
ApplicationConfiguration
(
ConfigurationWithConditionalOnProperty
.
class
)
@Spring
BootTest
(
classes
=
ConfigurationWithConditionalOnProperty
.
class
)
@DirtiesContext
public
static
class
TestWithBootstrapDisabledAndDefaultNamespacesAndConditionalOn
extends
AbstractSpringIntegrationTest
{
...
...
@@ -234,7 +234,7 @@ public class BootstrapConfigTest {
}
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@Spring
ApplicationConfiguration
(
ConfigurationWithoutConditionalOnProperty
.
class
)
@Spring
BootTest
(
classes
=
ConfigurationWithoutConditionalOnProperty
.
class
)
@DirtiesContext
public
static
class
TestWithBootstrapDisabledAndDefaultNamespacesAndConditionalOff
extends
AbstractSpringIntegrationTest
{
...
...
apollo-common/pom.xml
View file @
55a0e1b8
...
...
@@ -30,17 +30,6 @@
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-security
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-spectator
</artifactId>
<!-- duplicated with spring-security-core -->
<exclusions>
<exclusion>
<groupId>
org.springframework.security
</groupId>
<artifactId>
spring-security-crypto
</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-data-jpa
</artifactId>
...
...
apollo-common/src/main/java/com/ctrip/framework/apollo/common/controller/CharacterEncodingFilterConfiguration.java
View file @
55a0e1b8
package
com
.
ctrip
.
framework
.
apollo
.
common
.
controller
;
import
org.springframework.boot.
context.embedded
.FilterRegistrationBean
;
import
org.springframework.boot.
web.servlet
.FilterRegistrationBean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.web.filter.CharacterEncodingFilter
;
...
...
apollo-common/src/main/java/com/ctrip/framework/apollo/common/controller/HttpMessageConverterConfiguration.java
View file @
55a0e1b8
...
...
@@ -3,7 +3,7 @@ package com.ctrip.framework.apollo.common.controller;
import
com.google.common.collect.Lists
;
import
com.google.gson.GsonBuilder
;
import
org.springframework.boot.autoconfigure.
web
.HttpMessageConverters
;
import
org.springframework.boot.autoconfigure.
http
.HttpMessageConverters
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.http.converter.ByteArrayHttpMessageConverter
;
...
...
apollo-common/src/main/java/com/ctrip/framework/apollo/common/controller/WebMvcConfig.java
View file @
55a0e1b8
package
com
.
ctrip
.
framework
.
apollo
.
common
.
controller
;
import
org.springframework.boot.
context.embedded.ConfigurableEmbeddedServletContainer
;
import
org.springframework.boot.
context.embedded.EmbeddedServletContainerCustomizer
;
import
org.springframework.boot.
context.embedded.MimeMappings
;
import
org.springframework.boot.
web.embedded.tomcat.TomcatServletWebServerFactory
;
import
org.springframework.boot.
web.server.MimeMappings
;
import
org.springframework.boot.
web.server.WebServerFactoryCustomizer
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.data.web.PageableHandlerMethodArgumentResolver
;
import
org.springframework.http.MediaType
;
import
org.springframework.web.method.support.HandlerMethodArgumentResolver
;
import
org.springframework.web.servlet.config.annotation.ContentNegotiationConfigurer
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurer
Adapter
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurer
;
import
java.util.List
;
@Configuration
public
class
WebMvcConfig
extends
WebMvcConfigurerAdapter
implements
EmbeddedServletContainerCustomizer
{
public
class
WebMvcConfig
implements
WebMvcConfigurer
,
WebServerFactoryCustomizer
<
TomcatServletWebServerFactory
>
{
@Override
public
void
addArgumentResolvers
(
List
<
HandlerMethodArgumentResolver
>
argumentResolvers
)
{
PageableHandlerMethodArgumentResolver
pageResolver
=
new
PageableHandlerMethodArgumentResolver
();
pageResolver
.
setFallbackPageable
(
new
PageRequest
(
0
,
10
));
pageResolver
.
setFallbackPageable
(
PageRequest
.
of
(
0
,
10
));
argumentResolvers
.
add
(
pageResolver
);
}
...
...
@@ -32,9 +32,9 @@ public class WebMvcConfig extends WebMvcConfigurerAdapter implements EmbeddedSer
}
@Override
public
void
customize
(
ConfigurableEmbeddedServletContainer
container
)
{
public
void
customize
(
TomcatServletWebServerFactory
factory
)
{
MimeMappings
mappings
=
new
MimeMappings
(
MimeMappings
.
DEFAULT
);
mappings
.
add
(
"html"
,
"text/html;charset=utf-8"
);
container
.
setMimeMappings
(
mappings
);
factory
.
setMimeMappings
(
mappings
);
}
}
apollo-common/src/main/java/com/ctrip/framework/apollo/common/customize/TomcatContainerCustomizer.java
deleted
100644 → 0
View file @
425de29e
package
com
.
ctrip
.
framework
.
apollo
.
common
.
customize
;
import
org.apache.catalina.connector.Connector
;
import
org.apache.coyote.ProtocolHandler
;
import
org.apache.coyote.http11.Http11NioProtocol
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer
;
import
org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer
;
import
org.springframework.boot.context.embedded.tomcat.TomcatConnectorCustomizer
;
import
org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory
;
import
org.springframework.core.env.Environment
;
import
org.springframework.stereotype.Component
;
/**
* @author Jason Song(song_s@ctrip.com)
*/
@Component
public
class
TomcatContainerCustomizer
implements
EmbeddedServletContainerCustomizer
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
TomcatContainerCustomizer
.
class
);
private
static
final
String
TOMCAT_ACCEPTOR_COUNT
=
"server.tomcat.accept-count"
;
@Autowired
private
Environment
environment
;
@Override
public
void
customize
(
ConfigurableEmbeddedServletContainer
container
)
{
if
(!(
container
instanceof
TomcatEmbeddedServletContainerFactory
))
{
return
;
}
if
(!
environment
.
containsProperty
(
TOMCAT_ACCEPTOR_COUNT
))
{
return
;
}
TomcatEmbeddedServletContainerFactory
tomcat
=
(
TomcatEmbeddedServletContainerFactory
)
container
;
tomcat
.
addConnectorCustomizers
(
new
TomcatConnectorCustomizer
()
{
@Override
public
void
customize
(
Connector
connector
)
{
ProtocolHandler
handler
=
connector
.
getProtocolHandler
();
if
(
handler
instanceof
Http11NioProtocol
)
{
Http11NioProtocol
http
=
(
Http11NioProtocol
)
handler
;
int
acceptCount
=
Integer
.
parseInt
(
environment
.
getProperty
(
TOMCAT_ACCEPTOR_COUNT
));
http
.
setBacklog
(
acceptCount
);
logger
.
info
(
"Setting tomcat accept count to {}"
,
acceptCount
);
}
}
});
}
}
apollo-common/src/main/java/com/ctrip/framework/apollo/common/entity/BaseEntity.java
View file @
55a0e1b8
...
...
@@ -7,6 +7,7 @@ import java.util.Date;
import
javax.persistence.Column
;
import
javax.persistence.GeneratedValue
;
import
javax.persistence.GenerationType
;
import
javax.persistence.Id
;
import
javax.persistence.Inheritance
;
import
javax.persistence.InheritanceType
;
...
...
@@ -20,7 +21,7 @@ import javax.persistence.PreUpdate;
public
abstract
class
BaseEntity
{
@Id
@GeneratedValue
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
@Column
(
name
=
"Id"
)
private
long
id
;
...
...
apollo-common/src/main/resources/application.properties
View file @
55a0e1b8
spring.http.converters.preferred-json-mapper
=
gson
# DataSource
spring.datasource.testWhileIdle
=
true
spring.datasource.testOnBorrow
=
true
spring.datasource.validationQuery
=
SELECT 1
spring.datasource.validationInterval
=
5000
spring.datasource.initSQL
=
set names utf8mb4
spring.datasource.hikari.connectionInitSql
=
set names utf8mb4
# Naming strategy
spring.jpa.hibernate.naming
_strategy
=
org.hibernate.cfg.EJB3NamingStrategy
spring.jpa.hibernate.naming
.physical-strategy
=
org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
spring.jpa.hibernate.globally_quoted_identifiers
=
true
spring.jpa.properties.hibernate.globally_quoted_identifiers
=
true
# Tomcat configuration
server.tomcat.accept-count
=
5000
# Increase tomcat header size for longer GET query parameter, should be n * 1024
server.tomcat.maxHttpHeaderSize
=
10240
server.max-http-header-size
=
10240
# Spring Boot 2.0
management.endpoints.web.base-path
=
/
apollo-common/src/main/resources/banner.txt
0 → 100644
View file @
55a0e1b8
_ _ _
/ \ _ __ ___ | | | ___
/ _ \ | '_ \ / _ \| | |/ _ \
/ ___ \| |_) | (_) | | | (_) |
/_/ \_\ .__/ \___/|_|_|\___/
|_|
:: Spring Boot :: ${spring-boot.formatted-version}
apollo-configservice/pom.xml
View file @
55a0e1b8
...
...
@@ -23,16 +23,14 @@
<!-- eureka -->
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-eureka-server
</artifactId>
<artifactId>
spring-cloud-starter-
netflix-
eureka-server
</artifactId>
<exclusions>
<exclusion>
<artifactId>
spring-cloud-starter-archaius
</artifactId>
<artifactId>
spring-cloud-starter-netflix-archaius
</artifactId>
<groupId>
org.springframework.cloud
</groupId>
</exclusion>
<exclusion>
<artifactId>
spring-cloud-starter-ribbon
</artifactId>
<artifactId>
spring-cloud-starter-
netflix-
ribbon
</artifactId>
<groupId>
org.springframework.cloud
</groupId>
</exclusion>
<exclusion>
...
...
apollo-configservice/src/main/java/com/ctrip/framework/apollo/configservice/ConfigServiceHealthIndicator.java
View file @
55a0e1b8
...
...
@@ -24,7 +24,7 @@ public class ConfigServiceHealthIndicator implements HealthIndicator {
}
private
int
check
()
{
PageRequest
pageable
=
new
PageRequest
(
0
,
1
);
PageRequest
pageable
=
PageRequest
.
of
(
0
,
1
);
appService
.
findAll
(
pageable
);
return
0
;
}
...
...
apollo-configservice/src/main/java/com/ctrip/framework/apollo/configservice/ServletInitializer.java
View file @
55a0e1b8
package
com
.
ctrip
.
framework
.
apollo
.
configservice
;
import
org.springframework.boot.builder.SpringApplicationBuilder
;
import
org.springframework.boot.
context.web
.SpringBootServletInitializer
;
import
org.springframework.boot.
web.servlet.support
.SpringBootServletInitializer
;
/**
* Entry point for traditional web app
...
...
apollo-configservice/src/main/java/com/ctrip/framework/apollo/configservice/service/AppNamespaceServiceWithCache.java
View file @
55a0e1b8
...
...
@@ -186,7 +186,7 @@ public class AppNamespaceServiceWithCache implements InitializingBean {
}
List
<
List
<
Long
>>
partitionIds
=
Lists
.
partition
(
ids
,
500
);
for
(
List
<
Long
>
toRebuild
:
partitionIds
)
{
Iterable
<
AppNamespace
>
appNamespaces
=
appNamespaceRepository
.
findAll
(
toRebuild
);
Iterable
<
AppNamespace
>
appNamespaces
=
appNamespaceRepository
.
findAll
ById
(
toRebuild
);
if
(
appNamespaces
==
null
)
{
continue
;
...
...
apollo-configservice/src/main/resources/bootstrap.yml
View file @
55a0e1b8
...
...
@@ -2,6 +2,8 @@ eureka:
instance
:
hostname
:
${hostname:localhost}
preferIpAddress
:
true
status-page-url-path
:
/info
health-check-url-path
:
/health
server
:
peerEurekaNodesUpdateIntervalMs
:
60000
enableSelfPreservation
:
false
...
...
@@ -12,13 +14,7 @@ eureka:
enabled
:
true
eurekaServiceUrlPollIntervalSeconds
:
60
endpoints
:
health
:
sensitive
:
false
management
:
security
:
enabled
:
false
health
:
status
:
order
:
DOWN, OUT_OF_SERVICE, UNKNOWN, UP
apollo-configservice/src/main/resources/configservice.properties
View file @
55a0e1b8
...
...
@@ -2,4 +2,5 @@
spring.application.name
=
apollo-configservice
ctrip.appid
=
100003171
server.port
=
8080
logging.file
=
/opt/logs/100003171/apollo-configservice.log
\ No newline at end of file
logging.file
=
/opt/logs/100003171/apollo-configservice.log
spring.jmx.default-domain
=
apollo-configservice
apollo-configservice/src/main/scripts/startup.sh
View file @
55a0e1b8
...
...
@@ -99,7 +99,7 @@ declare -i max_counter=48 # 48*5=240s
declare
-i
total_time
=
0
printf
"Waiting for server startup"
until
[[
((
counter
-ge
max_counter
))
||
"
$(
curl
-X
GET
--silent
--connect-timeout
1
--max-time
2
--head
$SERVER_URL
|
grep
"
Coyote
"
)
"
!=
""
]]
;
until
[[
((
counter
-ge
max_counter
))
||
"
$(
curl
-X
GET
--silent
--connect-timeout
1
--max-time
2
--head
$SERVER_URL
|
grep
"
HTTP
"
)
"
!=
""
]]
;
do
printf
"."
counter+
=
1
...
...
apollo-configservice/src/test/java/com/ctrip/framework/apollo/configservice/integration/AbstractBaseIntegrationTest.java
View file @
55a0e1b8
...
...
@@ -14,9 +14,9 @@ import com.ctrip.framework.apollo.biz.utils.ReleaseKeyGenerator;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.test.
SpringApplicationConfiguration
;
import
org.springframework.boot.test.
TestRestTemplate
;
import
org.springframework.boot.test.
WebIntegrationTest
;
import
org.springframework.boot.test.
context.SpringBootTest
;
import
org.springframework.boot.test.
context.SpringBootTest.WebEnvironment
;
import
org.springframework.boot.test.
web.client.TestRestTemplate
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Import
;
...
...
@@ -36,8 +36,7 @@ import javax.annotation.PostConstruct;
* @author Jason Song(song_s@ctrip.com)
*/
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@SpringApplicationConfiguration
(
classes
=
AbstractBaseIntegrationTest
.
TestConfiguration
.
class
)
@WebIntegrationTest
(
randomPort
=
true
)
@SpringBootTest
(
classes
=
AbstractBaseIntegrationTest
.
TestConfiguration
.
class
,
webEnvironment
=
WebEnvironment
.
RANDOM_PORT
)
public
abstract
class
AbstractBaseIntegrationTest
{
@Autowired
private
ReleaseMessageRepository
releaseMessageRepository
;
...
...
@@ -46,7 +45,7 @@ public abstract class AbstractBaseIntegrationTest {
private
Gson
gson
=
new
Gson
();
RestTemplate
restTemplate
=
new
Tes
tRestTemplate
();
protected
RestTemplate
restTemplate
=
(
new
TestRestTemplate
()).
ge
tRestTemplate
();
@PostConstruct
private
void
postConstruct
()
{
...
...
@@ -57,7 +56,7 @@ public abstract class AbstractBaseIntegrationTest {
int
port
;
protected
String
getHostUrl
()
{
return
"
http://
localhost:"
+
port
;
return
"localhost:"
+
port
;
}
@Configuration
...
...
apollo-configservice/src/test/java/com/ctrip/framework/apollo/configservice/integration/ConfigControllerIntegrationTest.java
View file @
55a0e1b8
...
...
@@ -59,7 +59,7 @@ public class ConfigControllerIntegrationTest extends AbstractBaseIntegrationTest
@Sql
(
scripts
=
"/integration-test/cleanup.sql"
,
executionPhase
=
Sql
.
ExecutionPhase
.
AFTER_TEST_METHOD
)
public
void
testQueryConfigWithDefaultClusterAndDefaultNamespaceOK
()
throws
Exception
{
ResponseEntity
<
ApolloConfig
>
response
=
restTemplate
.
getForEntity
(
"{baseurl}/configs/{appId}/{clusterName}/{namespace}"
,
ApolloConfig
.
class
,
.
getForEntity
(
"
http://
{baseurl}/configs/{appId}/{clusterName}/{namespace}"
,
ApolloConfig
.
class
,
getHostUrl
(),
someAppId
,
ConfigConsts
.
CLUSTER_NAME_DEFAULT
,
ConfigConsts
.
NAMESPACE_APPLICATION
);
ApolloConfig
result
=
response
.
getBody
();
...
...
@@ -73,7 +73,7 @@ public class ConfigControllerIntegrationTest extends AbstractBaseIntegrationTest
@Sql
(
scripts
=
"/integration-test/cleanup.sql"
,
executionPhase
=
Sql
.
ExecutionPhase
.
AFTER_TEST_METHOD
)
public
void
testQueryConfigWithDefaultClusterAndDefaultNamespaceAndIncorrectCase
()
throws
Exception
{
ResponseEntity
<
ApolloConfig
>
response
=
restTemplate
.
getForEntity
(
"{baseurl}/configs/{appId}/{clusterName}/{namespace}"
,
ApolloConfig
.
class
,
.
getForEntity
(
"
http://
{baseurl}/configs/{appId}/{clusterName}/{namespace}"
,
ApolloConfig
.
class
,
getHostUrl
(),
someAppId
,
ConfigConsts
.
CLUSTER_NAME_DEFAULT
,
ConfigConsts
.
NAMESPACE_APPLICATION
.
toUpperCase
());
ApolloConfig
result
=
response
.
getBody
();
...
...
@@ -97,7 +97,7 @@ public class ConfigControllerIntegrationTest extends AbstractBaseIntegrationTest
stop
.
set
(
true
);
ResponseEntity
<
ApolloConfig
>
response
=
restTemplate
.
getForEntity
(
"{baseurl}/configs/{appId}/{clusterName}/{namespace}?ip={clientIp}"
,
ApolloConfig
.
class
,
.
getForEntity
(
"
http://
{baseurl}/configs/{appId}/{clusterName}/{namespace}?ip={clientIp}"
,
ApolloConfig
.
class
,
getHostUrl
(),
someAppId
,
ConfigConsts
.
CLUSTER_NAME_DEFAULT
,
ConfigConsts
.
NAMESPACE_APPLICATION
,
someClientIp
);
ApolloConfig
result
=
response
.
getBody
();
...
...
@@ -120,7 +120,7 @@ public class ConfigControllerIntegrationTest extends AbstractBaseIntegrationTest
stop
.
set
(
true
);
ResponseEntity
<
ApolloConfig
>
response
=
restTemplate
.
getForEntity
(
"{baseurl}/configs/{appId}/{clusterName}/{namespace}?ip={clientIp}"
,
ApolloConfig
.
class
,
.
getForEntity
(
"
http://
{baseurl}/configs/{appId}/{clusterName}/{namespace}?ip={clientIp}"
,
ApolloConfig
.
class
,
getHostUrl
(),
someAppId
,
ConfigConsts
.
CLUSTER_NAME_DEFAULT
,
ConfigConsts
.
NAMESPACE_APPLICATION
.
toUpperCase
(),
someClientIp
);
ApolloConfig
result
=
response
.
getBody
();
...
...
@@ -135,7 +135,7 @@ public class ConfigControllerIntegrationTest extends AbstractBaseIntegrationTest
@Sql
(
scripts
=
"/integration-test/cleanup.sql"
,
executionPhase
=
Sql
.
ExecutionPhase
.
AFTER_TEST_METHOD
)
public
void
testQueryConfigFileWithDefaultClusterAndDefaultNamespaceOK
()
throws
Exception
{
ResponseEntity
<
ApolloConfig
>
response
=
restTemplate
.
getForEntity
(
"{baseurl}/configs/{appId}/{clusterName}/{namespace}"
,
ApolloConfig
.
class
,
.
getForEntity
(
"
http://
{baseurl}/configs/{appId}/{clusterName}/{namespace}"
,
ApolloConfig
.
class
,
getHostUrl
(),
someAppId
,
ConfigConsts
.
CLUSTER_NAME_DEFAULT
,
ConfigConsts
.
NAMESPACE_APPLICATION
+
".properties"
);
ApolloConfig
result
=
response
.
getBody
();
...
...
@@ -149,7 +149,7 @@ public class ConfigControllerIntegrationTest extends AbstractBaseIntegrationTest
@Sql
(
scripts
=
"/integration-test/cleanup.sql"
,
executionPhase
=
Sql
.
ExecutionPhase
.
AFTER_TEST_METHOD
)
public
void
testQueryConfigWithNamespaceOK
()
throws
Exception
{
ResponseEntity
<
ApolloConfig
>
response
=
restTemplate
.
getForEntity
(
"{baseurl}/configs/{appId}/{clusterName}/{namespace}"
,
ApolloConfig
.
class
,
.
getForEntity
(
"
http://
{baseurl}/configs/{appId}/{clusterName}/{namespace}"
,
ApolloConfig
.
class
,
getHostUrl
(),
someAppId
,
someCluster
,
someNamespace
);
ApolloConfig
result
=
response
.
getBody
();
...
...
@@ -163,7 +163,7 @@ public class ConfigControllerIntegrationTest extends AbstractBaseIntegrationTest
@Sql
(
scripts
=
"/integration-test/cleanup.sql"
,
executionPhase
=
Sql
.
ExecutionPhase
.
AFTER_TEST_METHOD
)
public
void
testQueryConfigFileWithNamespaceOK
()
throws
Exception
{
ResponseEntity
<
ApolloConfig
>
response
=
restTemplate
.
getForEntity
(
"{baseurl}/configs/{appId}/{clusterName}/{namespace}"
,
ApolloConfig
.
class
,
.
getForEntity
(
"
http://
{baseurl}/configs/{appId}/{clusterName}/{namespace}"
,
ApolloConfig
.
class
,
getHostUrl
(),
someAppId
,
ConfigConsts
.
CLUSTER_NAME_DEFAULT
,
someNamespace
+
".xml"
);
ApolloConfig
result
=
response
.
getBody
();
...
...
@@ -180,7 +180,7 @@ public class ConfigControllerIntegrationTest extends AbstractBaseIntegrationTest
HttpStatusCodeException
httpException
=
null
;
try
{
ResponseEntity
<
ApolloConfig
>
response
=
restTemplate
.
getForEntity
(
"{baseurl}/configs/{appId}/{clusterName}/{namespace}"
,
ApolloConfig
.
class
,
.
getForEntity
(
"
http://
{baseurl}/configs/{appId}/{clusterName}/{namespace}"
,
ApolloConfig
.
class
,
getHostUrl
(),
someAppId
,
someCluster
,
someNamespaceNotExists
);
}
catch
(
HttpStatusCodeException
ex
)
{
httpException
=
ex
;
...
...
@@ -195,7 +195,7 @@ public class ConfigControllerIntegrationTest extends AbstractBaseIntegrationTest
public
void
testQueryConfigNotModified
()
throws
Exception
{
String
releaseKey
=
"TEST-RELEASE-KEY2"
;
ResponseEntity
<
ApolloConfig
>
response
=
restTemplate
.
getForEntity
(
"{baseurl}/configs/{appId}/{clusterName}/{namespace}?releaseKey={releaseKey}"
,
.
getForEntity
(
"
http://
{baseurl}/configs/{appId}/{clusterName}/{namespace}?releaseKey={releaseKey}"
,
ApolloConfig
.
class
,
getHostUrl
(),
someAppId
,
someCluster
,
someNamespace
,
releaseKey
);
...
...
@@ -216,7 +216,7 @@ public class ConfigControllerIntegrationTest extends AbstractBaseIntegrationTest
stop
.
set
(
true
);
ResponseEntity
<
ApolloConfig
>
response
=
restTemplate
.
getForEntity
(
"{baseurl}/configs/{appId}/{clusterName}/{namespace}?ip={clientIp}"
,
ApolloConfig
.
class
,
.
getForEntity
(
"
http://
{baseurl}/configs/{appId}/{clusterName}/{namespace}?ip={clientIp}"
,
ApolloConfig
.
class
,
getHostUrl
(),
someAppId
,
someCluster
,
somePublicNamespace
,
someClientIp
);
ApolloConfig
result
=
response
.
getBody
();
...
...
@@ -231,7 +231,7 @@ public class ConfigControllerIntegrationTest extends AbstractBaseIntegrationTest
@Sql
(
scripts
=
"/integration-test/cleanup.sql"
,
executionPhase
=
Sql
.
ExecutionPhase
.
AFTER_TEST_METHOD
)
public
void
testQueryPublicConfigWithDataCenterFoundAndNoOverride
()
throws
Exception
{
ResponseEntity
<
ApolloConfig
>
response
=
restTemplate
.
getForEntity
(
"{baseurl}/configs/{appId}/{clusterName}/{namespace}?dataCenter={dateCenter}"
,
.
getForEntity
(
"
http://
{baseurl}/configs/{appId}/{clusterName}/{namespace}?dataCenter={dateCenter}"
,
ApolloConfig
.
class
,
getHostUrl
(),
someAppId
,
someCluster
,
somePublicNamespace
,
someDC
);
ApolloConfig
result
=
response
.
getBody
();
...
...
@@ -250,7 +250,7 @@ public class ConfigControllerIntegrationTest extends AbstractBaseIntegrationTest
@Sql
(
scripts
=
"/integration-test/cleanup.sql"
,
executionPhase
=
Sql
.
ExecutionPhase
.
AFTER_TEST_METHOD
)
public
void
testQueryPublicConfigWithDataCenterFoundAndOverride
()
throws
Exception
{
ResponseEntity
<
ApolloConfig
>
response
=
restTemplate
.
getForEntity
(
"{baseurl}/configs/{appId}/{clusterName}/{namespace}?dataCenter={dateCenter}"
,
.
getForEntity
(
"
http://
{baseurl}/configs/{appId}/{clusterName}/{namespace}?dataCenter={dateCenter}"
,
ApolloConfig
.
class
,
getHostUrl
(),
someAppId
,
someDefaultCluster
,
somePublicNamespace
,
someDC
);
ApolloConfig
result
=
response
.
getBody
();
...
...
@@ -271,7 +271,7 @@ public class ConfigControllerIntegrationTest extends AbstractBaseIntegrationTest
@Sql
(
scripts
=
"/integration-test/cleanup.sql"
,
executionPhase
=
Sql
.
ExecutionPhase
.
AFTER_TEST_METHOD
)
public
void
testQueryPublicConfigWithIncorrectCaseAndDataCenterFoundAndOverride
()
throws
Exception
{
ResponseEntity
<
ApolloConfig
>
response
=
restTemplate
.
getForEntity
(
"{baseurl}/configs/{appId}/{clusterName}/{namespace}?dataCenter={dateCenter}"
,
.
getForEntity
(
"
http://
{baseurl}/configs/{appId}/{clusterName}/{namespace}?dataCenter={dateCenter}"
,
ApolloConfig
.
class
,
getHostUrl
(),
someAppId
,
someDefaultCluster
,
somePublicNamespace
.
toUpperCase
(),
someDC
);
ApolloConfig
result
=
response
.
getBody
();
...
...
@@ -289,7 +289,7 @@ public class ConfigControllerIntegrationTest extends AbstractBaseIntegrationTest
public
void
testQueryPublicConfigWithDataCenterNotFoundAndNoOverride
()
throws
Exception
{
String
someDCNotFound
=
"someDCNotFound"
;
ResponseEntity
<
ApolloConfig
>
response
=
restTemplate
.
getForEntity
(
"{baseurl}/configs/{appId}/{clusterName}/{namespace}?dataCenter={dateCenter}"
,
.
getForEntity
(
"
http://
{baseurl}/configs/{appId}/{clusterName}/{namespace}?dataCenter={dateCenter}"
,
ApolloConfig
.
class
,
getHostUrl
(),
someAppId
,
someCluster
,
somePublicNamespace
,
someDCNotFound
);
ApolloConfig
result
=
response
.
getBody
();
...
...
@@ -309,7 +309,7 @@ public class ConfigControllerIntegrationTest extends AbstractBaseIntegrationTest
public
void
testQueryPublicConfigWithDataCenterNotFoundAndOverride
()
throws
Exception
{
String
someDCNotFound
=
"someDCNotFound"
;
ResponseEntity
<
ApolloConfig
>
response
=
restTemplate
.
getForEntity
(
"{baseurl}/configs/{appId}/{clusterName}/{namespace}?dataCenter={dateCenter}"
,
.
getForEntity
(
"
http://
{baseurl}/configs/{appId}/{clusterName}/{namespace}?dataCenter={dateCenter}"
,
ApolloConfig
.
class
,
getHostUrl
(),
someAppId
,
someDefaultCluster
,
somePublicNamespace
,
someDCNotFound
);
ApolloConfig
result
=
response
.
getBody
();
...
...
@@ -339,7 +339,7 @@ public class ConfigControllerIntegrationTest extends AbstractBaseIntegrationTest
stop
.
set
(
true
);
ResponseEntity
<
ApolloConfig
>
response
=
restTemplate
.
getForEntity
(
"{baseurl}/configs/{appId}/{clusterName}/{namespace}?ip={clientIp}"
,
ApolloConfig
.
class
,
.
getForEntity
(
"
http://
{baseurl}/configs/{appId}/{clusterName}/{namespace}?ip={clientIp}"
,
ApolloConfig
.
class
,
getHostUrl
(),
someAppId
,
someDefaultCluster
,
somePublicNamespace
,
someClientIp
);
ApolloConfig
result
=
response
.
getBody
();
...
...
@@ -366,7 +366,7 @@ public class ConfigControllerIntegrationTest extends AbstractBaseIntegrationTest
stop
.
set
(
true
);
ResponseEntity
<
ApolloConfig
>
response
=
restTemplate
.
getForEntity
(
"{baseurl}/configs/{appId}/{clusterName}/{namespace}?ip={clientIp}"
,
ApolloConfig
.
class
,
.
getForEntity
(
"
http://
{baseurl}/configs/{appId}/{clusterName}/{namespace}?ip={clientIp}"
,
ApolloConfig
.
class
,
getHostUrl
(),
someAppId
,
someDefaultCluster
,
somePublicNamespace
.
toUpperCase
(),
someClientIp
);
ApolloConfig
result
=
response
.
getBody
();
...
...
@@ -384,7 +384,7 @@ public class ConfigControllerIntegrationTest extends AbstractBaseIntegrationTest
public
void
testQueryPrivateConfigFileWithPublicNamespaceExists
()
throws
Exception
{
String
namespaceName
=
"anotherNamespace"
;
ResponseEntity
<
ApolloConfig
>
response
=
restTemplate
.
getForEntity
(
"{baseurl}/configs/{appId}/{clusterName}/{namespace}"
,
.
getForEntity
(
"
http://
{baseurl}/configs/{appId}/{clusterName}/{namespace}"
,
ApolloConfig
.
class
,
getHostUrl
(),
someAppId
,
ConfigConsts
.
CLUSTER_NAME_DEFAULT
,
namespaceName
);
ApolloConfig
result
=
response
.
getBody
();
...
...
@@ -403,7 +403,7 @@ public class ConfigControllerIntegrationTest extends AbstractBaseIntegrationTest
HttpStatusCodeException
httpException
=
null
;
try
{
ResponseEntity
<
ApolloConfig
>
response
=
restTemplate
.
getForEntity
(
"{baseurl}/configs/{appId}/{clusterName}/{namespace}"
,
ApolloConfig
.
class
,
.
getForEntity
(
"
http://
{baseurl}/configs/{appId}/{clusterName}/{namespace}"
,
ApolloConfig
.
class
,
getHostUrl
(),
ConfigConsts
.
NO_APPID_PLACEHOLDER
,
someCluster
,
ConfigConsts
.
NAMESPACE_APPLICATION
);
}
catch
(
HttpStatusCodeException
ex
)
{
httpException
=
ex
;
...
...
@@ -417,7 +417,7 @@ public class ConfigControllerIntegrationTest extends AbstractBaseIntegrationTest
@Sql
(
scripts
=
"/integration-test/cleanup.sql"
,
executionPhase
=
Sql
.
ExecutionPhase
.
AFTER_TEST_METHOD
)
public
void
testQueryPublicConfigForNoAppIdPlaceHolder
()
throws
Exception
{
ResponseEntity
<
ApolloConfig
>
response
=
restTemplate
.
getForEntity
(
"{baseurl}/configs/{appId}/{clusterName}/{namespace}?dataCenter={dateCenter}"
,
.
getForEntity
(
"
http://
{baseurl}/configs/{appId}/{clusterName}/{namespace}?dataCenter={dateCenter}"
,
ApolloConfig
.
class
,
getHostUrl
(),
ConfigConsts
.
NO_APPID_PLACEHOLDER
,
someCluster
,
somePublicNamespace
,
someDC
);
ApolloConfig
result
=
response
.
getBody
();
...
...
apollo-configservice/src/test/java/com/ctrip/framework/apollo/configservice/integration/ConfigFileControllerIntegrationTest.java
View file @
55a0e1b8
...
...
@@ -72,7 +72,7 @@ public class ConfigFileControllerIntegrationTest extends AbstractBaseIntegration
public
void
testQueryConfigAsProperties
()
throws
Exception
{
ResponseEntity
<
String
>
response
=
restTemplate
.
getForEntity
(
"{baseurl}/configfiles/{appId}/{clusterName}/{namespace}"
,
String
.
class
,
.
getForEntity
(
"
http://
{baseurl}/configfiles/{appId}/{clusterName}/{namespace}"
,
String
.
class
,
getHostUrl
(),
someAppId
,
someCluster
,
someNamespace
);
String
result
=
response
.
getBody
();
...
...
@@ -96,12 +96,12 @@ public class ConfigFileControllerIntegrationTest extends AbstractBaseIntegration
ResponseEntity
<
String
>
response
=
restTemplate
.
getForEntity
(
"{baseurl}/configfiles/{appId}/{clusterName}/{namespace}?ip={clientIp}"
,
String
.
class
,
.
getForEntity
(
"
http://
{baseurl}/configfiles/{appId}/{clusterName}/{namespace}?ip={clientIp}"
,
String
.
class
,
getHostUrl
(),
someAppId
,
someDefaultCluster
,
ConfigConsts
.
NAMESPACE_APPLICATION
,
grayClientIp
);
ResponseEntity
<
String
>
anotherResponse
=
restTemplate
.
getForEntity
(
"{baseurl}/configfiles/{appId}/{clusterName}/{namespace}?ip={clientIp}"
,
String
.
class
,
.
getForEntity
(
"
http://
{baseurl}/configfiles/{appId}/{clusterName}/{namespace}?ip={clientIp}"
,
String
.
class
,
getHostUrl
(),
someAppId
,
someDefaultCluster
,
ConfigConsts
.
NAMESPACE_APPLICATION
,
nonGrayClientIp
);
String
result
=
response
.
getBody
();
...
...
@@ -123,7 +123,7 @@ public class ConfigFileControllerIntegrationTest extends AbstractBaseIntegration
ResponseEntity
<
String
>
response
=
restTemplate
.
getForEntity
(
"{baseurl}/configfiles/{appId}/{clusterName}/{namespace}?dataCenter={dateCenter}"
,
"
http://
{baseurl}/configfiles/{appId}/{clusterName}/{namespace}?dataCenter={dateCenter}"
,
String
.
class
,
getHostUrl
(),
someAppId
,
someDefaultCluster
,
somePublicNamespace
,
someDC
);
...
...
@@ -140,7 +140,7 @@ public class ConfigFileControllerIntegrationTest extends AbstractBaseIntegration
public
void
testQueryConfigAsJson
()
throws
Exception
{
ResponseEntity
<
String
>
response
=
restTemplate
.
getForEntity
(
"{baseurl}/configfiles/json/{appId}/{clusterName}/{namespace}"
,
String
.
class
,
.
getForEntity
(
"
http://
{baseurl}/configfiles/json/{appId}/{clusterName}/{namespace}"
,
String
.
class
,
getHostUrl
(),
someAppId
,
someCluster
,
someNamespace
);
Map
<
String
,
String
>
configs
=
gson
.
fromJson
(
response
.
getBody
(),
mapResponseType
);
...
...
@@ -155,7 +155,7 @@ public class ConfigFileControllerIntegrationTest extends AbstractBaseIntegration
public
void
testQueryConfigAsJsonWithIncorrectCase
()
throws
Exception
{
ResponseEntity
<
String
>
response
=
restTemplate
.
getForEntity
(
"{baseurl}/configfiles/json/{appId}/{clusterName}/{namespace}"
,
String
.
class
,
.
getForEntity
(
"
http://
{baseurl}/configfiles/json/{appId}/{clusterName}/{namespace}"
,
String
.
class
,
getHostUrl
(),
someAppId
,
someCluster
,
someNamespace
.
toUpperCase
());
Map
<
String
,
String
>
configs
=
gson
.
fromJson
(
response
.
getBody
(),
mapResponseType
);
...
...
@@ -172,7 +172,7 @@ public class ConfigFileControllerIntegrationTest extends AbstractBaseIntegration
ResponseEntity
<
String
>
response
=
restTemplate
.
getForEntity
(
"{baseurl}/configfiles/json/{appId}/{clusterName}/{namespace}?dataCenter={dateCenter}"
,
"
http://
{baseurl}/configfiles/json/{appId}/{clusterName}/{namespace}?dataCenter={dateCenter}"
,
String
.
class
,
getHostUrl
(),
someAppId
,
someDefaultCluster
,
somePublicNamespace
,
someDC
);
...
...
@@ -191,7 +191,7 @@ public class ConfigFileControllerIntegrationTest extends AbstractBaseIntegration
ResponseEntity
<
String
>
response
=
restTemplate
.
getForEntity
(
"{baseurl}/configfiles/json/{appId}/{clusterName}/{namespace}?dataCenter={dateCenter}"
,
"
http://
{baseurl}/configfiles/json/{appId}/{clusterName}/{namespace}?dataCenter={dateCenter}"
,
String
.
class
,
getHostUrl
(),
someAppId
,
someDefaultCluster
,
somePublicNamespace
.
toUpperCase
(),
someDC
);
...
...
@@ -219,14 +219,14 @@ public class ConfigFileControllerIntegrationTest extends AbstractBaseIntegration
ResponseEntity
<
String
>
response
=
restTemplate
.
getForEntity
(
"{baseurl}/configfiles/json/{appId}/{clusterName}/{namespace}?ip={clientIp}"
,
"
http://
{baseurl}/configfiles/json/{appId}/{clusterName}/{namespace}?ip={clientIp}"
,
String
.
class
,
getHostUrl
(),
someAppId
,
someDefaultCluster
,
somePublicNamespace
,
grayClientIp
);
ResponseEntity
<
String
>
anotherResponse
=
restTemplate
.
getForEntity
(
"{baseurl}/configfiles/json/{appId}/{clusterName}/{namespace}?ip={clientIp}"
,
"
http://
{baseurl}/configfiles/json/{appId}/{clusterName}/{namespace}?ip={clientIp}"
,
String
.
class
,
getHostUrl
(),
someAppId
,
someDefaultCluster
,
somePublicNamespace
,
nonGrayClientIp
);
...
...
@@ -260,14 +260,14 @@ public class ConfigFileControllerIntegrationTest extends AbstractBaseIntegration
ResponseEntity
<
String
>
response
=
restTemplate
.
getForEntity
(
"{baseurl}/configfiles/json/{appId}/{clusterName}/{namespace}?ip={clientIp}"
,
"
http://
{baseurl}/configfiles/json/{appId}/{clusterName}/{namespace}?ip={clientIp}"
,
String
.
class
,
getHostUrl
(),
someAppId
,
someDefaultCluster
,
somePublicNamespace
.
toUpperCase
(),
grayClientIp
);
ResponseEntity
<
String
>
anotherResponse
=
restTemplate
.
getForEntity
(
"{baseurl}/configfiles/json/{appId}/{clusterName}/{namespace}?ip={clientIp}"
,
"
http://
{baseurl}/configfiles/json/{appId}/{clusterName}/{namespace}?ip={clientIp}"
,
String
.
class
,
getHostUrl
(),
someAppId
,
someDefaultCluster
,
somePublicNamespace
.
toUpperCase
(),
nonGrayClientIp
);
...
...
@@ -290,7 +290,7 @@ public class ConfigFileControllerIntegrationTest extends AbstractBaseIntegration
public
void
testConfigChanged
()
throws
Exception
{
ResponseEntity
<
String
>
response
=
restTemplate
.
getForEntity
(
"{baseurl}/configfiles/{appId}/{clusterName}/{namespace}"
,
String
.
class
,
.
getForEntity
(
"
http://
{baseurl}/configfiles/{appId}/{clusterName}/{namespace}"
,
String
.
class
,
getHostUrl
(),
someAppId
,
someCluster
,
someNamespace
);
String
result
=
response
.
getBody
();
...
...
@@ -312,7 +312,7 @@ public class ConfigFileControllerIntegrationTest extends AbstractBaseIntegration
ResponseEntity
<
String
>
anotherResponse
=
restTemplate
.
getForEntity
(
"{baseurl}/configfiles/{appId}/{clusterName}/{namespace}"
,
String
.
class
,
.
getForEntity
(
"
http://
{baseurl}/configfiles/{appId}/{clusterName}/{namespace}"
,
String
.
class
,
getHostUrl
(),
someAppId
,
someCluster
,
someNamespace
);
assertEquals
(
response
.
getBody
(),
anotherResponse
.
getBody
());
...
...
@@ -325,7 +325,7 @@ public class ConfigFileControllerIntegrationTest extends AbstractBaseIntegration
ResponseEntity
<
String
>
newResponse
=
restTemplate
.
getForEntity
(
"{baseurl}/configfiles/{appId}/{clusterName}/{namespace}"
,
String
.
class
,
.
getForEntity
(
"
http://
{baseurl}/configfiles/{appId}/{clusterName}/{namespace}"
,
String
.
class
,
getHostUrl
(),
someAppId
,
someCluster
,
someNamespace
);
result
=
newResponse
.
getBody
();
...
...
apollo-configservice/src/test/java/com/ctrip/framework/apollo/configservice/integration/NotificationControllerIntegrationTest.java
View file @
55a0e1b8
...
...
@@ -57,7 +57,7 @@ public class NotificationControllerIntegrationTest extends AbstractBaseIntegrati
periodicSendMessage
(
executorService
,
assembleKey
(
someAppId
,
someCluster
,
defaultNamespace
),
stop
);
ResponseEntity
<
ApolloConfigNotification
>
result
=
restTemplate
.
getForEntity
(
"{baseurl}/notifications?appId={appId}&cluster={clusterName}&namespace={namespace}"
,
"
http://
{baseurl}/notifications?appId={appId}&cluster={clusterName}&namespace={namespace}"
,
ApolloConfigNotification
.
class
,
getHostUrl
(),
someAppId
,
someCluster
,
defaultNamespace
);
...
...
@@ -76,7 +76,7 @@ public class NotificationControllerIntegrationTest extends AbstractBaseIntegrati
periodicSendMessage
(
executorService
,
assembleKey
(
someAppId
,
someCluster
,
defaultNamespace
),
stop
);
ResponseEntity
<
ApolloConfigNotification
>
result
=
restTemplate
.
getForEntity
(
"{baseurl}/notifications?appId={appId}&cluster={clusterName}&namespace={namespace}"
,
"
http://
{baseurl}/notifications?appId={appId}&cluster={clusterName}&namespace={namespace}"
,
ApolloConfigNotification
.
class
,
getHostUrl
(),
someAppId
,
someCluster
,
defaultNamespace
+
".properties"
);
...
...
@@ -98,7 +98,7 @@ public class NotificationControllerIntegrationTest extends AbstractBaseIntegrati
ResponseEntity
<
ApolloConfigNotification
>
result
=
restTemplate
.
getForEntity
(
"{baseurl}/notifications?appId={appId}&cluster={clusterName}&namespace={namespace}"
,
"
http://
{baseurl}/notifications?appId={appId}&cluster={clusterName}&namespace={namespace}"
,
ApolloConfigNotification
.
class
,
getHostUrl
(),
someAppId
,
someCluster
,
namespace
);
...
...
@@ -115,7 +115,7 @@ public class NotificationControllerIntegrationTest extends AbstractBaseIntegrati
@Sql
(
scripts
=
"/integration-test/cleanup.sql"
,
executionPhase
=
Sql
.
ExecutionPhase
.
AFTER_TEST_METHOD
)
public
void
testPollNotificationWithDefaultNamespaceWithNotificationIdNull
()
throws
Exception
{
ResponseEntity
<
ApolloConfigNotification
>
result
=
restTemplate
.
getForEntity
(
"{baseurl}/notifications?appId={appId}&cluster={clusterName}&namespace={namespace}"
,
"
http://
{baseurl}/notifications?appId={appId}&cluster={clusterName}&namespace={namespace}"
,
ApolloConfigNotification
.
class
,
getHostUrl
(),
someAppId
,
someCluster
,
defaultNamespace
);
...
...
@@ -132,7 +132,7 @@ public class NotificationControllerIntegrationTest extends AbstractBaseIntegrati
public
void
testPollNotificationWithDefaultNamespaceWithNotificationIdOutDated
()
throws
Exception
{
long
someOutDatedNotificationId
=
1
;
ResponseEntity
<
ApolloConfigNotification
>
result
=
restTemplate
.
getForEntity
(
"{baseurl}/notifications?appId={appId}&cluster={clusterName}&namespace={namespace}¬ificationId={notificationId}"
,
"
http://
{baseurl}/notifications?appId={appId}&cluster={clusterName}&namespace={namespace}¬ificationId={notificationId}"
,
ApolloConfigNotification
.
class
,
getHostUrl
(),
someAppId
,
someCluster
,
defaultNamespace
,
someOutDatedNotificationId
);
...
...
@@ -153,7 +153,7 @@ public class NotificationControllerIntegrationTest extends AbstractBaseIntegrati
ResponseEntity
<
ApolloConfigNotification
>
result
=
restTemplate
.
getForEntity
(
"{baseurl}/notifications?appId={appId}&cluster={clusterName}&namespace={namespace}"
,
"
http://
{baseurl}/notifications?appId={appId}&cluster={clusterName}&namespace={namespace}"
,
ApolloConfigNotification
.
class
,
getHostUrl
(),
someAppId
,
someCluster
,
somePublicNamespace
);
...
...
@@ -177,7 +177,7 @@ public class NotificationControllerIntegrationTest extends AbstractBaseIntegrati
ResponseEntity
<
ApolloConfigNotification
>
result
=
restTemplate
.
getForEntity
(
"{baseurl}/notifications?appId={appId}&cluster={clusterName}&namespace={namespace}&dataCenter={dataCenter}"
,
"
http://
{baseurl}/notifications?appId={appId}&cluster={clusterName}&namespace={namespace}&dataCenter={dataCenter}"
,
ApolloConfigNotification
.
class
,
getHostUrl
(),
someAppId
,
someCluster
,
somePublicNamespace
,
someDC
);
...
...
@@ -201,7 +201,7 @@ public class NotificationControllerIntegrationTest extends AbstractBaseIntegrati
ResponseEntity
<
ApolloConfigNotification
>
result
=
restTemplate
.
getForEntity
(
"{baseurl}/notifications?appId={appId}&cluster={clusterName}&namespace={namespace}&dataCenter={dataCenter}"
,
"
http://
{baseurl}/notifications?appId={appId}&cluster={clusterName}&namespace={namespace}&dataCenter={dataCenter}"
,
ApolloConfigNotification
.
class
,
getHostUrl
(),
someAppId
,
someCluster
,
somePublicNamespace
+
".properties"
,
someDC
);
...
...
@@ -220,7 +220,7 @@ public class NotificationControllerIntegrationTest extends AbstractBaseIntegrati
public
void
testPollNotificationWithPublicNamespaceWithNotificationIdOutDated
()
throws
Exception
{
long
someOutDatedNotificationId
=
1
;
ResponseEntity
<
ApolloConfigNotification
>
result
=
restTemplate
.
getForEntity
(
"{baseurl}/notifications?appId={appId}&cluster={clusterName}&namespace={namespace}¬ificationId={notificationId}"
,
"
http://
{baseurl}/notifications?appId={appId}&cluster={clusterName}&namespace={namespace}¬ificationId={notificationId}"
,
ApolloConfigNotification
.
class
,
getHostUrl
(),
someAppId
,
someCluster
,
somePublicNamespace
,
someOutDatedNotificationId
);
...
...
apollo-configservice/src/test/java/com/ctrip/framework/apollo/configservice/integration/NotificationControllerV2IntegrationTest.java
View file @
55a0e1b8
...
...
@@ -68,7 +68,7 @@ public class NotificationControllerV2IntegrationTest extends AbstractBaseIntegra
periodicSendMessage
(
executorService
,
key
,
stop
);
ResponseEntity
<
List
<
ApolloConfigNotification
>>
result
=
restTemplate
.
exchange
(
"{baseurl}/notifications/v2?appId={appId}&cluster={clusterName}¬ifications={notifications}"
,
"
http://
{baseurl}/notifications/v2?appId={appId}&cluster={clusterName}¬ifications={notifications}"
,
HttpMethod
.
GET
,
null
,
typeReference
,
getHostUrl
(),
someAppId
,
someCluster
,
transformApolloConfigNotificationsToString
(
defaultNamespace
,
ConfigConsts
.
NOTIFICATION_ID_PLACEHOLDER
));
...
...
@@ -96,7 +96,7 @@ public class NotificationControllerV2IntegrationTest extends AbstractBaseIntegra
stop
);
ResponseEntity
<
List
<
ApolloConfigNotification
>>
result
=
restTemplate
.
exchange
(
"{baseurl}/notifications/v2?appId={appId}&cluster={clusterName}¬ifications={notifications}"
,
"
http://
{baseurl}/notifications/v2?appId={appId}&cluster={clusterName}¬ifications={notifications}"
,
HttpMethod
.
GET
,
null
,
typeReference
,
getHostUrl
(),
someAppId
,
someCluster
,
transformApolloConfigNotificationsToString
(
defaultNamespace
+
".properties"
,
...
...
@@ -124,7 +124,7 @@ public class NotificationControllerV2IntegrationTest extends AbstractBaseIntegra
periodicSendMessage
(
executorService
,
key
,
stop
);
ResponseEntity
<
List
<
ApolloConfigNotification
>>
result
=
restTemplate
.
exchange
(
"{baseurl}/notifications/v2?appId={appId}&cluster={clusterName}¬ifications={notifications}"
,
"
http://
{baseurl}/notifications/v2?appId={appId}&cluster={clusterName}¬ifications={notifications}"
,
HttpMethod
.
GET
,
null
,
typeReference
,
getHostUrl
(),
someAppId
,
someCluster
,
transformApolloConfigNotificationsToString
(
defaultNamespace
+
".properties"
,
...
...
@@ -156,7 +156,7 @@ public class NotificationControllerV2IntegrationTest extends AbstractBaseIntegra
String
somePublicNamespaceWithIncorrectCase
=
somePublicNamespace
.
toUpperCase
();
ResponseEntity
<
List
<
ApolloConfigNotification
>>
result
=
restTemplate
.
exchange
(
"{baseurl}/notifications/v2?appId={appId}&cluster={clusterName}¬ifications={notifications}"
,
"
http://
{baseurl}/notifications/v2?appId={appId}&cluster={clusterName}¬ifications={notifications}"
,
HttpMethod
.
GET
,
null
,
typeReference
,
getHostUrl
(),
someAppId
,
someCluster
,
transformApolloConfigNotificationsToString
(
defaultNamespace
+
".properties"
,
...
...
@@ -189,7 +189,7 @@ public class NotificationControllerV2IntegrationTest extends AbstractBaseIntegra
periodicSendMessage
(
executorService
,
key
,
stop
);
ResponseEntity
<
List
<
ApolloConfigNotification
>>
result
=
restTemplate
.
exchange
(
"{baseurl}/notifications/v2?appId={appId}&cluster={clusterName}¬ifications={notifications}"
,
"
http://
{baseurl}/notifications/v2?appId={appId}&cluster={clusterName}¬ifications={notifications}"
,
HttpMethod
.
GET
,
null
,
typeReference
,
getHostUrl
(),
someAppId
,
someCluster
,
transformApolloConfigNotificationsToString
(
namespace
,
ConfigConsts
.
NOTIFICATION_ID_PLACEHOLDER
));
...
...
@@ -216,7 +216,7 @@ public class NotificationControllerV2IntegrationTest extends AbstractBaseIntegra
throws
Exception
{
long
someOutDatedNotificationId
=
1
;
ResponseEntity
<
List
<
ApolloConfigNotification
>>
result
=
restTemplate
.
exchange
(
"{baseurl}/notifications/v2?appId={appId}&cluster={clusterName}¬ifications={notifications}"
,
"
http://
{baseurl}/notifications/v2?appId={appId}&cluster={clusterName}¬ifications={notifications}"
,
HttpMethod
.
GET
,
null
,
typeReference
,
getHostUrl
(),
someAppId
,
someCluster
,
transformApolloConfigNotificationsToString
(
defaultNamespace
,
someOutDatedNotificationId
));
...
...
@@ -247,7 +247,7 @@ public class NotificationControllerV2IntegrationTest extends AbstractBaseIntegra
periodicSendMessage
(
executorService
,
key
,
stop
);
ResponseEntity
<
List
<
ApolloConfigNotification
>>
result
=
restTemplate
.
exchange
(
"{baseurl}/notifications/v2?appId={appId}&cluster={clusterName}¬ifications={notifications}"
,
"
http://
{baseurl}/notifications/v2?appId={appId}&cluster={clusterName}¬ifications={notifications}"
,
HttpMethod
.
GET
,
null
,
typeReference
,
getHostUrl
(),
someAppId
,
someCluster
,
transformApolloConfigNotificationsToString
(
somePublicNamespace
,
ConfigConsts
.
NOTIFICATION_ID_PLACEHOLDER
));
...
...
@@ -278,7 +278,7 @@ public class NotificationControllerV2IntegrationTest extends AbstractBaseIntegra
periodicSendMessage
(
executorService
,
key
,
stop
);
ResponseEntity
<
List
<
ApolloConfigNotification
>>
result
=
restTemplate
.
exchange
(
"{baseurl}/notifications/v2?appId={appId}&cluster={clusterName}¬ifications={notifications}&dataCenter={dataCenter}"
,
"
http://
{baseurl}/notifications/v2?appId={appId}&cluster={clusterName}¬ifications={notifications}&dataCenter={dataCenter}"
,
HttpMethod
.
GET
,
null
,
typeReference
,
getHostUrl
(),
someAppId
,
someCluster
,
transformApolloConfigNotificationsToString
(
somePublicNamespace
,
ConfigConsts
.
NOTIFICATION_ID_PLACEHOLDER
),
...
...
@@ -311,7 +311,7 @@ public class NotificationControllerV2IntegrationTest extends AbstractBaseIntegra
periodicSendMessage
(
executorService
,
key
,
stop
);
ResponseEntity
<
List
<
ApolloConfigNotification
>>
result
=
restTemplate
.
exchange
(
"{baseurl}/notifications/v2?appId={appId}&cluster={clusterName}¬ifications={notifications}&dataCenter={dataCenter}"
,
"
http://
{baseurl}/notifications/v2?appId={appId}&cluster={clusterName}¬ifications={notifications}&dataCenter={dataCenter}"
,
HttpMethod
.
GET
,
null
,
typeReference
,
getHostUrl
(),
someAppId
,
someCluster
,
transformApolloConfigNotificationsToString
(
defaultNamespace
,
ConfigConsts
.
NOTIFICATION_ID_PLACEHOLDER
,
...
...
@@ -344,7 +344,7 @@ public class NotificationControllerV2IntegrationTest extends AbstractBaseIntegra
periodicSendMessage
(
executorService
,
key
,
stop
);
ResponseEntity
<
List
<
ApolloConfigNotification
>>
result
=
restTemplate
.
exchange
(
"{baseurl}/notifications/v2?appId={appId}&cluster={clusterName}¬ifications={notifications}&dataCenter={dataCenter}"
,
"
http://
{baseurl}/notifications/v2?appId={appId}&cluster={clusterName}¬ifications={notifications}&dataCenter={dataCenter}"
,
HttpMethod
.
GET
,
null
,
typeReference
,
getHostUrl
(),
someAppId
,
someCluster
,
transformApolloConfigNotificationsToString
(
somePublicNamespace
+
".properties"
,
...
...
@@ -373,7 +373,7 @@ public class NotificationControllerV2IntegrationTest extends AbstractBaseIntegra
long
someOutDatedNotificationId
=
1
;
ResponseEntity
<
List
<
ApolloConfigNotification
>>
result
=
restTemplate
.
exchange
(
"{baseurl}/notifications/v2?appId={appId}&cluster={clusterName}¬ifications={notifications}"
,
"
http://
{baseurl}/notifications/v2?appId={appId}&cluster={clusterName}¬ifications={notifications}"
,
HttpMethod
.
GET
,
null
,
typeReference
,
getHostUrl
(),
someAppId
,
someCluster
,
transformApolloConfigNotificationsToString
(
somePublicNamespace
,
...
...
@@ -407,7 +407,7 @@ public class NotificationControllerV2IntegrationTest extends AbstractBaseIntegra
//the same namespace with difference character case, and difference notification id
ResponseEntity
<
List
<
ApolloConfigNotification
>>
result
=
restTemplate
.
exchange
(
"{baseurl}/notifications/v2?appId={appId}&cluster={clusterName}¬ifications={notifications}"
,
"
http://
{baseurl}/notifications/v2?appId={appId}&cluster={clusterName}¬ifications={notifications}"
,
HttpMethod
.
GET
,
null
,
typeReference
,
getHostUrl
(),
someAppId
,
someCluster
,
transformApolloConfigNotificationsToString
(
somePublicNamespace
,
newNotificationId
,
...
...
@@ -440,7 +440,7 @@ public class NotificationControllerV2IntegrationTest extends AbstractBaseIntegra
//the same namespace with difference character case, and difference notification id
ResponseEntity
<
List
<
ApolloConfigNotification
>>
result
=
restTemplate
.
exchange
(
"{baseurl}/notifications/v2?appId={appId}&cluster={clusterName}¬ifications={notifications}"
,
"
http://
{baseurl}/notifications/v2?appId={appId}&cluster={clusterName}¬ifications={notifications}"
,
HttpMethod
.
GET
,
null
,
typeReference
,
getHostUrl
(),
someAppId
,
someCluster
,
transformApolloConfigNotificationsToString
(
somePublicNameWithIncorrectCase
,
someOutDatedNotificationId
,
...
...
@@ -473,7 +473,7 @@ public class NotificationControllerV2IntegrationTest extends AbstractBaseIntegra
//the same namespace with difference character case, and difference notification id
ResponseEntity
<
List
<
ApolloConfigNotification
>>
result
=
restTemplate
.
exchange
(
"{baseurl}/notifications/v2?appId={appId}&cluster={clusterName}¬ifications={notifications}"
,
"
http://
{baseurl}/notifications/v2?appId={appId}&cluster={clusterName}¬ifications={notifications}"
,
HttpMethod
.
GET
,
null
,
typeReference
,
getHostUrl
(),
someAppId
,
someCluster
,
transformApolloConfigNotificationsToString
(
somePublicNameWithIncorrectCase
,
newNotificationId
,
...
...
@@ -506,7 +506,7 @@ public class NotificationControllerV2IntegrationTest extends AbstractBaseIntegra
//the same namespace with difference character case, and difference notification id
ResponseEntity
<
List
<
ApolloConfigNotification
>>
result
=
restTemplate
.
exchange
(
"{baseurl}/notifications/v2?appId={appId}&cluster={clusterName}¬ifications={notifications}"
,
"
http://
{baseurl}/notifications/v2?appId={appId}&cluster={clusterName}¬ifications={notifications}"
,
HttpMethod
.
GET
,
null
,
typeReference
,
getHostUrl
(),
someAppId
,
someCluster
,
transformApolloConfigNotificationsToString
(
somePublicNamespace
,
someOutDatedNotificationId
,
...
...
@@ -538,7 +538,7 @@ public class NotificationControllerV2IntegrationTest extends AbstractBaseIntegra
long
newPublicNamespaceNotification
=
20
;
ResponseEntity
<
List
<
ApolloConfigNotification
>>
result
=
restTemplate
.
exchange
(
"{baseurl}/notifications/v2?appId={appId}&cluster={clusterName}¬ifications={notifications}"
,
"
http://
{baseurl}/notifications/v2?appId={appId}&cluster={clusterName}¬ifications={notifications}"
,
HttpMethod
.
GET
,
null
,
typeReference
,
getHostUrl
(),
someAppId
,
someCluster
,
transformApolloConfigNotificationsToString
(
somePublicNamespace
,
...
...
@@ -592,7 +592,7 @@ public class NotificationControllerV2IntegrationTest extends AbstractBaseIntegra
String
somePublicNamespaceWithIncorrectCase
=
somePublicNamespace
.
toUpperCase
();
ResponseEntity
<
List
<
ApolloConfigNotification
>>
result
=
restTemplate
.
exchange
(
"{baseurl}/notifications/v2?appId={appId}&cluster={clusterName}¬ifications={notifications}"
,
"
http://
{baseurl}/notifications/v2?appId={appId}&cluster={clusterName}¬ifications={notifications}"
,
HttpMethod
.
GET
,
null
,
typeReference
,
getHostUrl
(),
someAppId
,
someCluster
,
transformApolloConfigNotificationsToString
(
somePublicNamespaceWithIncorrectCase
,
...
...
apollo-configservice/src/test/java/com/ctrip/framework/apollo/configservice/service/AppNamespaceServiceWithCacheTest.java
View file @
55a0e1b8
...
...
@@ -133,7 +133,7 @@ public class AppNamespaceServiceWithCacheTest {
// Add 1 private namespace and 1 public namespace
when
(
appNamespaceRepository
.
findFirst500ByIdGreaterThanOrderByIdAsc
(
0
)).
thenReturn
(
Lists
.
newArrayList
(
somePrivateAppNamespace
,
somePublicAppNamespace
));
when
(
appNamespaceRepository
.
findAll
(
Lists
.
newArrayList
(
somePrivateNamespaceId
,
when
(
appNamespaceRepository
.
findAll
ById
(
Lists
.
newArrayList
(
somePrivateNamespaceId
,
somePublicNamespaceId
))).
thenReturn
(
Lists
.
newArrayList
(
somePrivateAppNamespace
,
somePublicAppNamespace
));
...
...
@@ -165,7 +165,7 @@ public class AppNamespaceServiceWithCacheTest {
when
(
appNamespaceRepository
.
findFirst500ByIdGreaterThanOrderByIdAsc
(
somePublicNamespaceId
))
.
thenReturn
(
Lists
.
newArrayList
(
anotherPrivateAppNamespace
,
yetAnotherPrivateAppNamespace
,
anotherPublicAppNamespace
));
when
(
appNamespaceRepository
.
findAll
(
appNamespaceIds
)).
thenReturn
(
allAppNamespaces
);
when
(
appNamespaceRepository
.
findAll
ById
(
appNamespaceIds
)).
thenReturn
(
allAppNamespaces
);
scanIntervalTimeUnit
.
sleep
(
sleepInterval
);
...
...
@@ -213,7 +213,7 @@ public class AppNamespaceServiceWithCacheTest {
(
somePublicAppNamespace
.
getDataChangeLastModifiedTime
(),
1
));
// Delete 1 private and 1 public
when
(
appNamespaceRepository
.
findAll
(
appNamespaceIds
)).
thenReturn
(
Lists
.
newArrayList
when
(
appNamespaceRepository
.
findAll
ById
(
appNamespaceIds
)).
thenReturn
(
Lists
.
newArrayList
(
somePrivateAppNamespaceNew
,
yetAnotherPrivateAppNamespaceNew
,
somePublicAppNamespaceNew
));
scanIntervalTimeUnit
.
sleep
(
sleepInterval
);
...
...
apollo-configservice/src/test/java/com/ctrip/framework/apollo/configservice/wrapper/CaseInsensitiveMapWrapperTest.java
View file @
55a0e1b8
...
...
@@ -64,4 +64,4 @@ public class CaseInsensitiveMapWrapperTest {
verify
(
someMap
,
times
(
1
)).
remove
(
someKey
.
toLowerCase
());
}
}
\ No newline at end of file
}
apollo-configservice/src/test/resources/application.properties
View file @
55a0e1b8
spring.datasource.url
=
jdbc:h2:mem:~/apolloconfigdb;mode=mysql;DB_CLOSE_ON_EXIT=FALSE;DB_CLOSE_DELAY=-1
spring.jpa.hibernate.naming
_strategy
=
org.hibernate.cfg.EJB3NamingStrategy
spring.jpa.hibernate.naming
.physical-strategy
=
org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
spring.h2.console.enabled
=
true
spring.h2.console.settings.web-allow-others
=
true
spring.jpa.properties.hibernate.show_sql
=
false
...
...
apollo-configservice/src/test/resources/bootstrap.yml
View file @
55a0e1b8
...
...
@@ -2,20 +2,15 @@ eureka:
instance
:
hostname
:
${hostname:localhost}
preferIpAddress
:
true
status-page-url-path
:
/info
health-check-url-path
:
/health
client
:
serviceUrl
:
defaultZone
:
http://${eureka.instance.hostname}:8080/eureka/
healthcheck
:
enabled
:
true
endpoints
:
health
:
sensitive
:
false
management
:
security
:
enabled
:
false
health
:
status
:
order
:
DOWN, OUT_OF_SERVICE, UNKNOWN, UP
apollo-mockserver/src/test/java/com/ctrip/framework/apollo/mockserver/ApolloMockServerSpringIntegrationTest.java
View file @
55a0e1b8
...
...
@@ -16,7 +16,7 @@ import org.junit.Test;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.test.
SpringApplicationConfiguration
;
import
org.springframework.boot.test.
context.SpringBootTest
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.test.annotation.DirtiesContext
;
...
...
@@ -26,7 +26,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
* Create by zhangzheng on 8/16/18 Email:zhangzheng@youzan.com
*/
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@Spring
ApplicationConfiguration
(
classes
=
TestConfiguration
.
class
)
@Spring
BootTest
(
classes
=
TestConfiguration
.
class
)
public
class
ApolloMockServerSpringIntegrationTest
{
private
static
final
String
otherNamespace
=
"otherNamespace"
;
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/entity/ConsumerAudit.java
View file @
55a0e1b8
...
...
@@ -7,6 +7,7 @@ import java.util.Date;
import
javax.persistence.Column
;
import
javax.persistence.Entity
;
import
javax.persistence.GeneratedValue
;
import
javax.persistence.GenerationType
;
import
javax.persistence.Id
;
import
javax.persistence.PrePersist
;
import
javax.persistence.Table
;
...
...
@@ -18,7 +19,7 @@ import javax.persistence.Table;
@Table
(
name
=
"ConsumerAudit"
)
public
class
ConsumerAudit
{
@Id
@GeneratedValue
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
@Column
(
name
=
"Id"
)
private
long
id
;
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/service/ConsumerService.java
View file @
55a0e1b8
...
...
@@ -109,7 +109,7 @@ public class ConsumerService {
}
public
Consumer
getConsumerByConsumerId
(
long
consumerId
)
{
return
consumerRepository
.
find
One
(
consumerId
);
return
consumerRepository
.
find
ById
(
consumerId
).
orElse
(
null
);
}
public
List
<
ConsumerRole
>
assignNamespaceRoleToConsumer
(
String
token
,
String
appId
,
String
namespaceName
)
{
...
...
@@ -177,7 +177,7 @@ public class ConsumerService {
@Transactional
public
void
createConsumerAudits
(
Iterable
<
ConsumerAudit
>
consumerAudits
)
{
consumerAuditRepository
.
save
(
consumerAudits
);
consumerAuditRepository
.
save
All
(
consumerAudits
);
}
@Transactional
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/AdminServiceAddressLocator.java
View file @
55a0e1b8
...
...
@@ -11,7 +11,7 @@ import com.ctrip.framework.apollo.tracer.Tracer;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.autoconfigure.
web
.HttpMessageConverters
;
import
org.springframework.boot.autoconfigure.
http
.HttpMessageConverters
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.web.client.RestTemplate
;
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/RestTemplateFactory.java
View file @
55a0e1b8
...
...
@@ -7,7 +7,7 @@ import org.apache.http.impl.client.HttpClientBuilder;
import
org.springframework.beans.factory.FactoryBean
;
import
org.springframework.beans.factory.InitializingBean
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.autoconfigure.
web
.HttpMessageConverters
;
import
org.springframework.boot.autoconfigure.
http
.HttpMessageConverters
;
import
org.springframework.http.client.HttpComponentsClientHttpRequestFactory
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.client.RestTemplate
;
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/RetryableRestTemplate.java
View file @
55a0e1b8
...
...
@@ -20,7 +20,7 @@ import org.springframework.stereotype.Component;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.web.client.RestClientException
;
import
org.springframework.web.client.RestTemplate
;
import
org.springframework.web.util.DefaultUri
TemplateHandler
;
import
org.springframework.web.util.DefaultUri
BuilderFactory
;
import
org.springframework.web.util.UriTemplateHandler
;
import
java.net.SocketTimeoutException
;
...
...
@@ -36,7 +36,7 @@ public class RetryableRestTemplate {
private
Logger
logger
=
LoggerFactory
.
getLogger
(
RetryableRestTemplate
.
class
);
private
UriTemplateHandler
uriTemplateHandler
=
new
DefaultUri
TemplateHandler
();
private
UriTemplateHandler
uriTemplateHandler
=
new
DefaultUri
BuilderFactory
();
private
RestTemplate
restTemplate
;
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/UserPO.java
View file @
55a0e1b8
...
...
@@ -5,6 +5,7 @@ import com.ctrip.framework.apollo.portal.entity.bo.UserInfo;
import
javax.persistence.Column
;
import
javax.persistence.Entity
;
import
javax.persistence.GeneratedValue
;
import
javax.persistence.GenerationType
;
import
javax.persistence.Id
;
import
javax.persistence.Table
;
...
...
@@ -16,7 +17,7 @@ import javax.persistence.Table;
public
class
UserPO
{
@Id
@GeneratedValue
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
@Column
(
name
=
"Id"
)
private
long
id
;
@Column
(
name
=
"Username"
,
nullable
=
false
)
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/FavoriteService.java
View file @
55a0e1b8
...
...
@@ -77,7 +77,7 @@ public class FavoriteService {
public
void
deleteFavorite
(
long
favoriteId
)
{
Favorite
favorite
=
favoriteRepository
.
find
One
(
favoriteId
);
Favorite
favorite
=
favoriteRepository
.
find
ById
(
favoriteId
).
orElse
(
null
);
checkUserOperatePermission
(
favorite
);
...
...
@@ -85,7 +85,7 @@ public class FavoriteService {
}
public
void
adjustFavoriteToFirst
(
long
favoriteId
)
{
Favorite
favorite
=
favoriteRepository
.
find
One
(
favoriteId
);
Favorite
favorite
=
favoriteRepository
.
find
ById
(
favoriteId
).
orElse
(
null
);
checkUserOperatePermission
(
favorite
);
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/configuration/AuthConfiguration.java
View file @
55a0e1b8
...
...
@@ -22,13 +22,12 @@ import java.util.Collections;
import
java.util.EventListener
;
import
java.util.Map
;
import
javax.servlet.Filter
;
import
org.apache.tomcat.jdbc.poo
l.DataSource
;
import
javax.sq
l.DataSource
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.autoconfigure.AutoConfigureAfter
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
;
import
org.springframework.boot.context.embedded.FilterRegistrationBean
;
import
org.springframework.boot.context.embedded.ServletListenerRegistrationBean
;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.boot.web.servlet.FilterRegistrationBean
;
import
org.springframework.boot.web.servlet.ServletListenerRegistrationBean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Profile
;
...
...
@@ -38,13 +37,13 @@ import org.springframework.ldap.core.ContextSource;
import
org.springframework.ldap.core.LdapOperations
;
import
org.springframework.ldap.core.LdapTemplate
;
import
org.springframework.ldap.core.support.LdapContextSource
;
import
org.springframework.security.authentication.encoding.LdapShaPasswordEncoder
;
import
org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder
;
import
org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity
;
import
org.springframework.security.config.annotation.web.builders.HttpSecurity
;
import
org.springframework.security.config.annotation.web.configuration.EnableWebSecurity
;
import
org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter
;
import
org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder
;
import
org.springframework.security.crypto.password.LdapShaPasswordEncoder
;
import
org.springframework.security.provisioning.JdbcUserDetailsManager
;
import
org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint
;
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/configuration/AuthFilterConfiguration.java
View file @
55a0e1b8
...
...
@@ -4,7 +4,7 @@ import com.ctrip.framework.apollo.openapi.filter.ConsumerAuthenticationFilter;
import
com.ctrip.framework.apollo.openapi.util.ConsumerAuditUtil
;
import
com.ctrip.framework.apollo.openapi.util.ConsumerAuthUtil
;
import
org.springframework.boot.
context.embedded
.FilterRegistrationBean
;
import
org.springframework.boot.
web.servlet
.FilterRegistrationBean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/ctrip/WebContextConfiguration.java
View file @
55a0e1b8
...
...
@@ -7,8 +7,8 @@ import com.ctrip.framework.apollo.portal.component.config.PortalConfig;
import
com.ctrip.framework.apollo.portal.spi.UserInfoHolder
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.
context.embedded
.FilterRegistrationBean
;
import
org.springframework.boot.
context.embedded
.ServletContextInitializer
;
import
org.springframework.boot.
web.servlet
.FilterRegistrationBean
;
import
org.springframework.boot.
web.servlet
.ServletContextInitializer
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Profile
;
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/defaultimpl/DefaultRolePermissionService.java
View file @
55a0e1b8
...
...
@@ -60,7 +60,7 @@ public class DefaultRolePermissionService implements RolePermissionService {
rolePermission
.
setDataChangeLastModifiedBy
(
createdRole
.
getDataChangeLastModifiedBy
());
return
rolePermission
;
});
rolePermissionRepository
.
save
(
rolePermissions
);
rolePermissionRepository
.
save
All
(
rolePermissions
);
}
return
createdRole
;
...
...
@@ -93,7 +93,7 @@ public class DefaultRolePermissionService implements RolePermissionService {
return
userRole
;
});
userRoleRepository
.
save
(
toCreate
);
userRoleRepository
.
save
All
(
toCreate
);
return
toAssignUserIds
;
}
...
...
@@ -114,7 +114,7 @@ public class DefaultRolePermissionService implements RolePermissionService {
userRole
.
setDataChangeLastModifiedBy
(
operatorUserId
);
}
userRoleRepository
.
save
(
existedUserRoles
);
userRoleRepository
.
save
All
(
existedUserRoles
);
}
/**
...
...
@@ -218,7 +218,7 @@ public class DefaultRolePermissionService implements RolePermissionService {
targetId
);
}
Iterable
<
Permission
>
results
=
permissionRepository
.
save
(
permissions
);
Iterable
<
Permission
>
results
=
permissionRepository
.
save
All
(
permissions
);
return
FluentIterable
.
from
(
results
).
toSet
();
}
...
...
apollo-portal/src/main/resources/application.yml
View file @
55a0e1b8
...
...
@@ -4,7 +4,9 @@ spring:
profiles
:
active
:
${apollo_profile}
resources
:
cache-period
:
3600
cache
:
cachecontrol
:
max-age
:
3600
server
:
port
:
8080
...
...
@@ -13,12 +15,7 @@ logging:
path
:
/opt/logs/100003173
file
:
${logging.path}/apollo-portal.log
endpoints
:
health
:
sensitive
:
false
management
:
security
:
enabled
:
false
health
:
status
:
order
:
DOWN, OUT_OF_SERVICE, UNKNOWN, UP
...
...
apollo-portal/src/main/scripts/startup.sh
View file @
55a0e1b8
...
...
@@ -99,7 +99,7 @@ declare -i max_counter=48 # 48*5=240s
declare
-i
total_time
=
0
printf
"Waiting for server startup"
until
[[
((
counter
-ge
max_counter
))
||
"
$(
curl
-X
GET
--silent
--connect-timeout
1
--max-time
2
--head
$SERVER_URL
|
grep
"
Coyote
"
)
"
!=
""
]]
;
until
[[
((
counter
-ge
max_counter
))
||
"
$(
curl
-X
GET
--silent
--connect-timeout
1
--max-time
2
--head
$SERVER_URL
|
grep
"
HTTP
"
)
"
!=
""
]]
;
do
printf
"."
counter+
=
1
...
...
apollo-portal/src/test/java/com/ctrip/framework/apollo/openapi/filter/ConsumerAuthenticationFilterTest.java
View file @
55a0e1b8
...
...
@@ -72,4 +72,4 @@ public class ConsumerAuthenticationFilterTest {
verify
(
consumerAuditUtil
,
never
()).
audit
(
eq
(
request
),
anyLong
());
verify
(
filterChain
,
never
()).
doFilter
(
request
,
response
);
}
}
\ No newline at end of file
}
apollo-portal/src/test/java/com/ctrip/framework/apollo/openapi/service/ConsumerServiceTest.java
View file @
55a0e1b8
...
...
@@ -16,6 +16,7 @@ import com.ctrip.framework.apollo.portal.spi.UserInfoHolder;
import
com.ctrip.framework.apollo.portal.spi.UserService
;
import
com.ctrip.framework.apollo.portal.util.RoleUtils
;
import
java.util.Optional
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.mockito.InjectMocks
;
...
...
@@ -97,10 +98,10 @@ public class ConsumerServiceTest extends AbstractUnitTest {
long
someConsumerId
=
1
;
Consumer
someConsumer
=
mock
(
Consumer
.
class
);
when
(
consumerRepository
.
find
One
(
someConsumerId
)).
thenReturn
(
someConsumer
);
when
(
consumerRepository
.
find
ById
(
someConsumerId
)).
thenReturn
(
Optional
.
of
(
someConsumer
)
);
assertEquals
(
someConsumer
,
consumerService
.
getConsumerByConsumerId
(
someConsumerId
));
verify
(
consumerRepository
,
times
(
1
)).
find
One
(
someConsumerId
);
verify
(
consumerRepository
,
times
(
1
)).
find
ById
(
someConsumerId
);
}
@Test
...
...
@@ -131,7 +132,7 @@ public class ConsumerServiceTest extends AbstractUnitTest {
Date
generationTime
=
new
Date
();
Consumer
consumer
=
mock
(
Consumer
.
class
);
when
(
consumerRepository
.
find
One
(
someConsumerId
)).
thenReturn
(
consumer
);
when
(
consumerRepository
.
find
ById
(
someConsumerId
)).
thenReturn
(
Optional
.
of
(
consumer
)
);
when
(
consumer
.
getAppId
()).
thenReturn
(
someConsumerAppId
);
when
(
consumerService
.
generateToken
(
someConsumerAppId
,
generationTime
,
someTokenSalt
))
.
thenReturn
(
someToken
);
...
...
apollo-portal/src/test/java/com/ctrip/framework/apollo/openapi/util/ConsumerAuditUtilTest.java
View file @
55a0e1b8
...
...
@@ -88,4 +88,4 @@ public class ConsumerAuditUtilTest {
assertEquals
(
someConsumerId
,
audit
.
getConsumerId
());
}
}
\ No newline at end of file
}
apollo-portal/src/test/java/com/ctrip/framework/apollo/openapi/util/ConsumerAuthUtilTest.java
View file @
55a0e1b8
...
...
@@ -76,4 +76,4 @@ public class ConsumerAuthUtilTest {
consumerAuthUtil
.
retrieveConsumerId
(
request
);
}
}
\ No newline at end of file
}
apollo-portal/src/test/java/com/ctrip/framework/apollo/portal/AbstractIntegrationTest.java
View file @
55a0e1b8
...
...
@@ -3,9 +3,9 @@ package com.ctrip.framework.apollo.portal;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.test.
SpringApplicationConfiguration
;
import
org.springframework.boot.test.
TestRestTemplate
;
import
org.springframework.boot.test.
WebIntegrationTest
;
import
org.springframework.boot.test.
context.SpringBootTest
;
import
org.springframework.boot.test.
context.SpringBootTest.WebEnvironment
;
import
org.springframework.boot.test.
web.client.TestRestTemplate
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
org.springframework.web.client.DefaultResponseErrorHandler
;
import
org.springframework.web.client.RestTemplate
;
...
...
@@ -13,11 +13,10 @@ import org.springframework.web.client.RestTemplate;
import
javax.annotation.PostConstruct
;
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@SpringApplicationConfiguration
(
classes
=
PortalApplication
.
class
)
@WebIntegrationTest
(
randomPort
=
true
)
@SpringBootTest
(
classes
=
PortalApplication
.
class
,
webEnvironment
=
WebEnvironment
.
RANDOM_PORT
)
public
abstract
class
AbstractIntegrationTest
{
RestTemplate
restTemplate
=
new
Tes
tRestTemplate
();
protected
RestTemplate
restTemplate
=
(
new
TestRestTemplate
()).
ge
tRestTemplate
();
@PostConstruct
private
void
postConstruct
()
{
...
...
apollo-portal/src/test/java/com/ctrip/framework/apollo/portal/service/FavoriteServiceTest.java
View file @
55a0e1b8
...
...
@@ -35,7 +35,7 @@ public class FavoriteServiceTest extends AbstractIntegrationTest {
Favorite
favorite
=
instanceOfFavorite
(
testUser
,
testApp
);
favoriteService
.
addFavorite
(
favorite
);
List
<
Favorite
>
createdFavorites
=
favoriteService
.
search
(
testUser
,
testApp
,
new
PageRequest
(
0
,
10
));
List
<
Favorite
>
createdFavorites
=
favoriteService
.
search
(
testUser
,
testApp
,
PageRequest
.
of
(
0
,
10
));
Assert
.
assertEquals
(
1
,
createdFavorites
.
size
());
...
...
@@ -57,7 +57,7 @@ public class FavoriteServiceTest extends AbstractIntegrationTest {
@Sql
(
scripts
=
"/sql/favorites/favorites.sql"
,
executionPhase
=
Sql
.
ExecutionPhase
.
BEFORE_TEST_METHOD
)
@Sql
(
scripts
=
"/sql/cleanup.sql"
,
executionPhase
=
Sql
.
ExecutionPhase
.
AFTER_TEST_METHOD
)
public
void
testSearchByUserId
()
{
List
<
Favorite
>
favorites
=
favoriteService
.
search
(
testUser
,
null
,
new
PageRequest
(
0
,
10
));
List
<
Favorite
>
favorites
=
favoriteService
.
search
(
testUser
,
null
,
PageRequest
.
of
(
0
,
10
));
Assert
.
assertEquals
(
4
,
favorites
.
size
());
}
...
...
@@ -65,7 +65,7 @@ public class FavoriteServiceTest extends AbstractIntegrationTest {
@Sql
(
scripts
=
"/sql/favorites/favorites.sql"
,
executionPhase
=
Sql
.
ExecutionPhase
.
BEFORE_TEST_METHOD
)
@Sql
(
scripts
=
"/sql/cleanup.sql"
,
executionPhase
=
Sql
.
ExecutionPhase
.
AFTER_TEST_METHOD
)
public
void
testSearchByAppId
()
{
List
<
Favorite
>
favorites
=
favoriteService
.
search
(
null
,
"test0621-04"
,
new
PageRequest
(
0
,
10
));
List
<
Favorite
>
favorites
=
favoriteService
.
search
(
null
,
"test0621-04"
,
PageRequest
.
of
(
0
,
10
));
Assert
.
assertEquals
(
3
,
favorites
.
size
());
}
...
...
@@ -73,7 +73,7 @@ public class FavoriteServiceTest extends AbstractIntegrationTest {
@Sql
(
scripts
=
"/sql/favorites/favorites.sql"
,
executionPhase
=
Sql
.
ExecutionPhase
.
BEFORE_TEST_METHOD
)
@Sql
(
scripts
=
"/sql/cleanup.sql"
,
executionPhase
=
Sql
.
ExecutionPhase
.
AFTER_TEST_METHOD
)
public
void
testSearchByAppIdAndUserId
()
{
List
<
Favorite
>
favorites
=
favoriteService
.
search
(
testUser
,
"test0621-04"
,
new
PageRequest
(
0
,
10
));
List
<
Favorite
>
favorites
=
favoriteService
.
search
(
testUser
,
"test0621-04"
,
PageRequest
.
of
(
0
,
10
));
Assert
.
assertEquals
(
1
,
favorites
.
size
());
}
...
...
@@ -81,7 +81,7 @@ public class FavoriteServiceTest extends AbstractIntegrationTest {
@Sql
(
scripts
=
"/sql/favorites/favorites.sql"
,
executionPhase
=
Sql
.
ExecutionPhase
.
BEFORE_TEST_METHOD
)
@Sql
(
scripts
=
"/sql/cleanup.sql"
,
executionPhase
=
Sql
.
ExecutionPhase
.
AFTER_TEST_METHOD
)
public
void
testSearchWithErrorParams
()
{
favoriteService
.
search
(
null
,
null
,
new
PageRequest
(
0
,
10
));
favoriteService
.
search
(
null
,
null
,
PageRequest
.
of
(
0
,
10
));
}
@Test
...
...
@@ -90,7 +90,7 @@ public class FavoriteServiceTest extends AbstractIntegrationTest {
public
void
testDeleteFavorite
()
{
long
legalFavoriteId
=
21L
;
favoriteService
.
deleteFavorite
(
legalFavoriteId
);
Assert
.
assertNull
(
favoriteRepository
.
find
One
(
legalFavoriteId
));
Assert
.
assertNull
(
favoriteRepository
.
find
ById
(
legalFavoriteId
).
orElse
(
null
));
}
@Test
(
expected
=
BadRequestException
.
class
)
...
...
@@ -99,7 +99,7 @@ public class FavoriteServiceTest extends AbstractIntegrationTest {
public
void
testDeleteFavoriteFail
()
{
long
anotherPersonFavoriteId
=
23L
;
favoriteService
.
deleteFavorite
(
anotherPersonFavoriteId
);
Assert
.
assertNull
(
favoriteRepository
.
find
One
(
anotherPersonFavoriteId
));
Assert
.
assertNull
(
favoriteRepository
.
find
ById
(
anotherPersonFavoriteId
).
orElse
(
null
));
}
@Test
(
expected
=
BadRequestException
.
class
)
...
...
@@ -117,7 +117,7 @@ public class FavoriteServiceTest extends AbstractIntegrationTest {
long
toAdjustFavoriteId
=
20
;
favoriteService
.
adjustFavoriteToFirst
(
toAdjustFavoriteId
);
List
<
Favorite
>
favorites
=
favoriteService
.
search
(
testUser
,
null
,
new
PageRequest
(
0
,
10
));
List
<
Favorite
>
favorites
=
favoriteService
.
search
(
testUser
,
null
,
PageRequest
.
of
(
0
,
10
));
Favorite
firstFavorite
=
favorites
.
get
(
0
);
Favorite
secondFavorite
=
favorites
.
get
(
1
);
...
...
apollo-portal/src/test/java/com/ctrip/framework/apollo/portal/spi/defaultImpl/RolePermissionServiceTest.java
View file @
55a0e1b8
...
...
@@ -67,7 +67,7 @@ public class RolePermissionServiceTest extends AbstractIntegrationTest {
Permission
created
=
rolePermissionService
.
createPermission
(
somePermission
);
Permission
createdFromDB
=
permissionRepository
.
find
One
(
created
.
getId
()
);
Permission
createdFromDB
=
permissionRepository
.
find
ById
(
created
.
getId
()).
orElse
(
null
);
assertEquals
(
somePermissionType
,
createdFromDB
.
getPermissionType
());
assertEquals
(
someTargetId
,
createdFromDB
.
getTargetId
());
...
...
@@ -103,7 +103,7 @@ public class RolePermissionServiceTest extends AbstractIntegrationTest {
FluentIterable
.
from
(
created
).
transform
(
BaseEntity:
:
getId
)
.
toSet
();
Iterable
<
Permission
>
permissionsFromDB
=
permissionRepository
.
findAll
(
permissionIds
);
Iterable
<
Permission
>
permissionsFromDB
=
permissionRepository
.
findAll
ById
(
permissionIds
);
Set
<
String
>
targetIds
=
Sets
.
newHashSet
();
Set
<
String
>
permissionTypes
=
Sets
.
newHashSet
();
...
...
@@ -145,7 +145,7 @@ public class RolePermissionServiceTest extends AbstractIntegrationTest {
Role
created
=
rolePermissionService
.
createRoleWithPermissions
(
role
,
permissionIds
);
Role
createdFromDB
=
roleRepository
.
find
One
(
created
.
getId
()
);
Role
createdFromDB
=
roleRepository
.
find
ById
(
created
.
getId
()).
orElse
(
null
);
List
<
RolePermission
>
rolePermissions
=
rolePermissionRepository
.
findByRoleIdIn
(
Sets
.
newHashSet
(
createdFromDB
.
getId
()));
...
...
apollo-portal/src/test/resources/application.properties
View file @
55a0e1b8
spring.datasource.url
=
jdbc:h2:mem:~/apolloportaldb;mode=mysql;DB_CLOSE_ON_EXIT=FALSE;DB_CLOSE_DELAY=-1
spring.jpa.hibernate.naming
_strategy
=
org.hibernate.cfg.EJB3NamingStrategy
spring.jpa.hibernate.naming
.physical-strategy
=
org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
spring.jpa.properties.hibernate.show_sql
=
false
spring.h2.console.enabled
=
true
spring.h2.console.settings.web-allow-others
=
true
apollo-portal/src/test/resources/application.yml
View file @
55a0e1b8
...
...
@@ -14,14 +14,7 @@ apollo:
portal
:
envs
:
local
endpoints
:
health
:
sensitive
:
false
management
:
security
:
enabled
:
false
health
:
status
:
order
:
DOWN, OUT_OF_SERVICE, UNKNOWN, UP
pom.xml
View file @
55a0e1b8
...
...
@@ -75,8 +75,9 @@
<properties>
<java.version>
1.8
</java.version>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<spring-boot.version>
1.3.8.RELEASE
</spring-boot.version>
<spring-cloud.version>
1.2.3.RELEASE
</spring-cloud.version>
<platform-bom.version>
Cairo-SR4
</platform-bom.version>
<spring-boot.version>
2.0.5.RELEASE
</spring-boot.version>
<spring-cloud.version>
Finchley.SR1
</spring-cloud.version>
<!-- Plugins Version -->
<maven-compiler-plugin.version>
3.6.0
</maven-compiler-plugin.version>
<maven-surefire-plugin.version>
2.19.1
</maven-surefire-plugin.version>
...
...
@@ -287,18 +288,24 @@
<artifactId>
h2
</artifactId>
<version>
1.4.191
</version>
</dependency>
<!-- stick with mockito 1.x -->
<dependency>
<groupId>
org.mockito
</groupId>
<artifactId>
mockito-core
</artifactId>
<version>
1.10.19
</version>
</dependency>
<!-- declare Spring BOMs in order -->
<dependency>
<groupId>
io.spring.platform
</groupId>
<artifactId>
platform-bom
</artifactId>
<version>
2.0.8.RELEASE
</version>
<version>
${platform-bom.version}
</version>
<type>
pom
</type>
<scope>
import
</scope>
</dependency>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-
netflix
</artifactId>
<version>
1.2.3.RELEASE
</version>
<artifactId>
spring-cloud-
dependencies
</artifactId>
<version>
${spring-cloud.version}
</version>
<type>
pom
</type>
<scope>
import
</scope>
</dependency>
...
...
@@ -323,6 +330,12 @@
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-test
</artifactId>
<scope>
test
</scope>
<exclusions>
<exclusion>
<artifactId>
spring-boot-starter
</artifactId>
<groupId>
org.springframework.boot
</groupId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
...
...
@@ -421,7 +434,7 @@
<plugin>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-maven-plugin
</artifactId>
<version>
1.3.
5
.RELEASE
</version>
<version>
1.3.
8
.RELEASE
</version>
<executions>
<execution>
<goals>
...
...
@@ -655,7 +668,7 @@
<!-- eureka -->
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-
eureka
</artifactId>
<artifactId>
spring-cloud-starter-
netflix-eureka-client
</artifactId>
<version>
${spring-cloud.version}
</version>
<exclusions>
<!-- already in java -->
...
...
@@ -761,7 +774,7 @@
<!-- eureka -->
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-
eureka
</artifactId>
<artifactId>
spring-cloud-starter-
netflix-eureka-client
</artifactId>
<version>
${spring-cloud.version}
</version>
<exclusions>
<!-- already in java -->
...
...
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