Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
apollo
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
openSource
apollo
Commits
046a50a7
Commit
046a50a7
authored
Apr 24, 2016
by
Jason Song
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #136 from yiming187/test_fix
Enlarge sleep time for long poll unit test
parents
52550468
663deacc
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
41 additions
and
81 deletions
+41
-81
ConfigServiceTest.java
.../java/com/ctrip/apollo/biz/service/ConfigServiceTest.java
+0
-6
RemoteConfigRepositoryTest.java
...om/ctrip/apollo/internals/RemoteConfigRepositoryTest.java
+21
-4
pom.xml
apollo-configservice/pom.xml
+0
-5
ConfigControllerTest.java
...apollo/configservice/controller/ConfigControllerTest.java
+18
-22
pom.xml
pom.xml
+2
-44
No files found.
apollo-biz/src/test/java/com/ctrip/apollo/biz/service/ConfigServiceTest.java
View file @
046a50a7
...
...
@@ -2,13 +2,10 @@ package com.ctrip.apollo.biz.service;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertNull
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
static
org
.
mockito
.
Mockito
.
times
;
import
static
org
.
mockito
.
Mockito
.
verify
;
import
static
org
.
mockito
.
Mockito
.
when
;
import
java.util.Map
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
...
...
@@ -18,9 +15,6 @@ import org.springframework.test.util.ReflectionTestUtils;
import
com.ctrip.apollo.biz.entity.Release
;
import
com.ctrip.apollo.biz.repository.ReleaseRepository
;
import
com.ctrip.apollo.core.dto.ApolloConfig
;
import
com.google.common.collect.Maps
;
import
com.google.gson.JsonSyntaxException
;
/**
* @author Jason Song(song_s@ctrip.com)
...
...
apollo-client/src/test/java/com/ctrip/apollo/internals/RemoteConfigRepositoryTest.java
View file @
046a50a7
...
...
@@ -3,7 +3,7 @@ package com.ctrip.apollo.internals;
import
com.google.common.collect.ImmutableMap
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Maps
;
import
com.google.common.util.concurrent.SettableFuture
;
import
com.ctrip.apollo.core.dto.ApolloConfig
;
import
com.ctrip.apollo.core.dto.ApolloConfigNotification
;
import
com.ctrip.apollo.core.dto.ServiceDTO
;
...
...
@@ -18,7 +18,10 @@ import org.junit.Test;
import
org.junit.runner.RunWith
;
import
org.mockito.ArgumentCaptor
;
import
org.mockito.Mock
;
import
org.mockito.Mockito
;
import
org.mockito.invocation.InvocationOnMock
;
import
org.mockito.runners.MockitoJUnitRunner
;
import
org.mockito.stubbing.Answer
;
import
org.unidal.lookup.ComponentTestCase
;
import
java.util.List
;
...
...
@@ -34,6 +37,8 @@ import static org.mockito.Mockito.mock;
import
static
org
.
mockito
.
Mockito
.
times
;
import
static
org
.
mockito
.
Mockito
.
verify
;
import
static
org
.
mockito
.
Mockito
.
when
;
import
static
org
.
mockito
.
Mockito
.
any
;
import
static
org
.
mockito
.
Mockito
.
doAnswer
;
/**
* Created by Jason on 4/9/16.
...
...
@@ -128,8 +133,19 @@ public class RemoteConfigRepositoryTest extends ComponentTestCase {
when
(
someResponse
.
getStatusCode
()).
thenReturn
(
200
);
when
(
someResponse
.
getBody
()).
thenReturn
(
someApolloConfig
);
final
SettableFuture
<
Boolean
>
longPollFinished
=
SettableFuture
.
create
();
RepositoryChangeListener
someListener
=
mock
(
RepositoryChangeListener
.
class
);
doAnswer
(
new
Answer
<
Void
>(){
@Override
public
Void
answer
(
InvocationOnMock
invocation
)
throws
Throwable
{
longPollFinished
.
set
(
true
);
return
null
;
}
}).
when
(
someListener
).
onRepositoryChange
(
any
(
String
.
class
),
any
(
Properties
.
class
));
RemoteConfigRepository
remoteConfigRepository
=
new
RemoteConfigRepository
(
someNamespace
);
remoteConfigRepository
.
addChangeListener
(
someListener
);
final
ArgumentCaptor
<
Properties
>
captor
=
ArgumentCaptor
.
forClass
(
Properties
.
class
);
...
...
@@ -137,10 +153,11 @@ public class RemoteConfigRepositoryTest extends ComponentTestCase {
Map
<
String
,
String
>
newConfigurations
=
ImmutableMap
.
of
(
"someKey"
,
"anotherValue"
);
ApolloConfig
newApolloConfig
=
assembleApolloConfig
(
newConfigurations
);
when
(
pollResponse
.
getStatusCode
()).
thenReturn
(
HttpServletResponse
.
SC_OK
);
when
(
someResponse
.
getBody
()).
thenReturn
(
newApolloConfig
);
TimeUnit
.
MILLISECONDS
.
sleep
(
60
);
longPollFinished
.
get
(
500
,
TimeUnit
.
MILLISECONDS
);
remoteConfigRepository
.
stopLongPollingRefresh
();
...
...
apollo-configservice/pom.xml
View file @
046a50a7
...
...
@@ -20,11 +20,6 @@
<artifactId>
apollo-biz
</artifactId>
</dependency>
<!-- end of apollo -->
<!-- redis -->
<!-- <dependency> <groupId>org.springframework.data</groupId> <artifactId>spring-data-redis</artifactId>
</dependency> <dependency> <groupId>redis.clients</groupId> <artifactId>jedis</artifactId>
</dependency> -->
<!-- end of redis -->
<!-- eureka -->
<dependency>
<groupId>
org.springframework.cloud
</groupId>
...
...
apollo-configservice/src/test/java/com/ctrip/apollo/configservice/controller/ConfigControllerTest.java
View file @
046a50a7
package
com
.
ctrip
.
apollo
.
configservice
.
controller
;
import
com.google.common.collect.ImmutableMap
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Maps
;
import
com.google.gson.Gson
;
import
com.google.gson.JsonSyntaxException
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertNull
;
import
static
org
.
mockito
.
Matchers
.
anyString
;
import
static
org
.
mockito
.
Matchers
.
eq
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
times
;
import
static
org
.
mockito
.
Mockito
.
verify
;
import
static
org
.
mockito
.
Mockito
.
when
;
import
com.ctrip.apollo.biz.entity.Release
;
import
com.ctrip.apollo.biz.service.ConfigService
;
import
com.ctrip.apollo.core.dto.ApolloConfig
;
import
java.util.Map
;
import
javax.servlet.http.HttpServletResponse
;
import
org.junit.Before
;
import
org.junit.Test
;
...
...
@@ -17,20 +20,13 @@ import org.mockito.Mock;
import
org.mockito.runners.MockitoJUnitRunner
;
import
org.springframework.test.util.ReflectionTestUtils
;
import
java.util.Map
;
import
javax.servlet.http.HttpServletResponse
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertNull
;
import
static
org
.
junit
.
Assert
.
assertThat
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
static
org
.
mockito
.
Mockito
.
anyString
;
import
static
org
.
mockito
.
Mockito
.
eq
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
times
;
import
static
org
.
mockito
.
Mockito
.
verify
;
import
static
org
.
mockito
.
Mockito
.
when
;
import
com.ctrip.apollo.biz.entity.Release
;
import
com.ctrip.apollo.biz.service.ConfigService
;
import
com.ctrip.apollo.core.dto.ApolloConfig
;
import
com.google.common.collect.ImmutableMap
;
import
com.google.common.collect.Lists
;
import
com.google.gson.Gson
;
import
com.google.gson.JsonSyntaxException
;
/**
* @author Jason Song(song_s@ctrip.com)
...
...
pom.xml
View file @
046a50a7
...
...
@@ -343,56 +343,14 @@
<properties>
<package.environment>
local
</package.environment>
</properties>
</profile>
<profile>
<id>
dev
</id>
<properties>
<package.environment>
dev
</package.environment>
</properties>
<activation>
<activeByDefault>
true
</activeByDefault>
</activation>
</profile>
<profile>
<id>
fat
</id>
<properties>
<package.environment>
fat
</package.environment>
</properties>
<dependencies>
<dependency>
<groupId>
com.ctrip.platform
</groupId>
<artifactId>
ctrip-dal-client
</artifactId>
</dependency>
</dependencies>
</profile>
<profile>
<id>
uat
</id>
<properties>
<package.environment>
uat
</package.environment>
</properties>
<dependencies>
<dependency>
<groupId>
com.ctrip.platform
</groupId>
<artifactId>
ctrip-dal-client
</artifactId>
</dependency>
</dependencies>
</profile>
<profile>
<id>
prod
</id>
<properties>
<package.environment>
prod
</package.environment>
</properties>
<dependencies>
<dependency>
<groupId>
com.ctrip.platform
</groupId>
<artifactId>
ctrip-dal-client
</artifactId>
</dependency>
</dependencies>
</profile>
<profile>
<id>
tools
</id>
<id>
ctrip
</id>
<properties>
<package.environment>
tools
</package.environment>
<package.environment>
ctrip
</package.environment>
</properties>
<dependencies>
<dependency>
...
...
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