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
77029324
Commit
77029324
authored
Feb 09, 2018
by
jian.tan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Multimap并未严格保持@EnableApolloConfig注解中namespace定义的顺序。
parent
3573f3ef
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
1 deletion
+31
-1
PropertySourcesProcessor.java
...mework/apollo/spring/config/PropertySourcesProcessor.java
+2
-1
JavaConfigPlaceholderTest.java
...ip/framework/apollo/spring/JavaConfigPlaceholderTest.java
+29
-0
No files found.
apollo-client/src/main/java/com/ctrip/framework/apollo/spring/config/PropertySourcesProcessor.java
View file @
77029324
...
...
@@ -2,6 +2,7 @@ package com.ctrip.framework.apollo.spring.config;
import
com.google.common.collect.HashMultimap
;
import
com.google.common.collect.ImmutableSortedSet
;
import
com.google.common.collect.LinkedHashMultimap
;
import
com.google.common.collect.Multimap
;
import
com.ctrip.framework.apollo.Config
;
...
...
@@ -31,7 +32,7 @@ import java.util.Iterator;
* @author Jason Song(song_s@ctrip.com)
*/
public
class
PropertySourcesProcessor
implements
BeanFactoryPostProcessor
,
EnvironmentAware
,
PriorityOrdered
{
private
static
final
Multimap
<
Integer
,
String
>
NAMESPACE_NAMES
=
HashMultimap
.
create
();
private
static
final
Multimap
<
Integer
,
String
>
NAMESPACE_NAMES
=
Linked
HashMultimap
.
create
();
private
ConfigurableEnvironment
environment
;
...
...
apollo-client/src/test/java/com/ctrip/framework/apollo/spring/JavaConfigPlaceholderTest.java
View file @
77029324
...
...
@@ -96,6 +96,26 @@ public class JavaConfigPlaceholderTest extends AbstractSpringIntegrationTest {
check
(
someTimeout
,
someBatch
,
AppConfig3
.
class
);
}
@Test
public
void
testMultiplePropertySourcesCoverWithSameProperties
()
throws
Exception
{
//Multimap does not maintain the strict input order of namespace.
int
someTimeout
=
1000
;
int
anotherTimeout
=
someTimeout
+
1
;
int
someBatch
=
2000
;
Config
fxApollo
=
mock
(
Config
.
class
);
when
(
fxApollo
.
getProperty
(
eq
(
TIMEOUT_PROPERTY
),
anyString
())).
thenReturn
(
String
.
valueOf
(
someTimeout
));
when
(
fxApollo
.
getProperty
(
eq
(
BATCH_PROPERTY
),
anyString
())).
thenReturn
(
String
.
valueOf
(
someBatch
));
mockConfig
(
FX_APOLLO_NAMESPACE
,
fxApollo
);
Config
application
=
mock
(
Config
.
class
);
when
(
application
.
getProperty
(
eq
(
TIMEOUT_PROPERTY
),
anyString
())).
thenReturn
(
String
.
valueOf
(
anotherTimeout
));
mockConfig
(
ConfigConsts
.
NAMESPACE_APPLICATION
,
application
);
check
(
someTimeout
,
someBatch
,
AppConfig6
.
class
);
}
@Test
public
void
testMultiplePropertySourcesWithSamePropertiesWithWeight
()
throws
Exception
{
int
someTimeout
=
1000
;
...
...
@@ -188,6 +208,15 @@ public class JavaConfigPlaceholderTest extends AbstractSpringIntegrationTest {
}
}
@Configuration
@EnableApolloConfig
({
"FX.apollo"
,
"application"
})
static
class
AppConfig6
{
@Bean
TestJavaConfigBean
testJavaConfigBean
()
{
return
new
TestJavaConfigBean
();
}
}
@Component
static
class
TestJavaConfigBean
{
@Value
(
"${timeout:100}"
)
...
...
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