Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
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
DEMO
spring-boot
Commits
dba6a5bf
Commit
dba6a5bf
authored
Jan 12, 2014
by
Dave Syer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for = separator in EnvironmentTestUtils
parent
577c177d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
1 deletion
+20
-1
EnvironmentTestUtils.java
...a/org/springframework/boot/test/EnvironmentTestUtils.java
+20
-1
No files found.
spring-boot/src/test/java/org/springframework/boot/test/EnvironmentTestUtils.java
View file @
dba6a5bf
...
@@ -19,8 +19,10 @@ package org.springframework.boot.test;
...
@@ -19,8 +19,10 @@ package org.springframework.boot.test;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Map
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.ConfigurableApplicationContext
;
import
org.springframework.context.ConfigurableApplicationContext
;
import
org.springframework.core.env.ConfigurableEnvironment
;
import
org.springframework.core.env.ConfigurableEnvironment
;
import
org.springframework.core.env.Environment
;
import
org.springframework.core.env.MapPropertySource
;
import
org.springframework.core.env.MapPropertySource
;
/**
/**
...
@@ -30,15 +32,32 @@ import org.springframework.core.env.MapPropertySource;
...
@@ -30,15 +32,32 @@ import org.springframework.core.env.MapPropertySource;
*/
*/
public
abstract
class
EnvironmentTestUtils
{
public
abstract
class
EnvironmentTestUtils
{
/**
* Add additional (high priority) values to an {@link Environment} owned by an
* {@link ApplicationContext}. Name-value pairs can be specified with colon (":") or
* equals ("=") separators.
*
* @param context the context with an environment to modify
* @param pairs the name:value pairs
*/
public
static
void
addEnvironment
(
ConfigurableApplicationContext
context
,
public
static
void
addEnvironment
(
ConfigurableApplicationContext
context
,
String
...
pairs
)
{
String
...
pairs
)
{
addEnvironment
(
context
.
getEnvironment
(),
pairs
);
addEnvironment
(
context
.
getEnvironment
(),
pairs
);
}
}
public
static
void
addEnvironment
(
ConfigurableEnvironment
environment
,
String
...
pairs
)
{
/**
* Add additional (high priority) values to an {@link Environment}. Name-value pairs
* can be specified with colon (":") or equals ("=") separators.
*
* @param environment the environment to modify
* @param pairs the name:value pairs
*/
public
static
void
addEnvironment
(
ConfigurableEnvironment
environment
,
String
...
pairs
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
for
(
String
pair
:
pairs
)
{
for
(
String
pair
:
pairs
)
{
int
index
=
pair
.
indexOf
(
":"
);
int
index
=
pair
.
indexOf
(
":"
);
index
=
index
<
0
?
index
=
pair
.
indexOf
(
"="
)
:
index
;
String
key
=
pair
.
substring
(
0
,
index
>
0
?
index
:
pair
.
length
());
String
key
=
pair
.
substring
(
0
,
index
>
0
?
index
:
pair
.
length
());
String
value
=
index
>
0
?
pair
.
substring
(
index
+
1
)
:
""
;
String
value
=
index
>
0
?
pair
.
substring
(
index
+
1
)
:
""
;
map
.
put
(
key
.
trim
(),
value
.
trim
());
map
.
put
(
key
.
trim
(),
value
.
trim
());
...
...
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