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
8b88c6e8
Commit
8b88c6e8
authored
Sep 06, 2017
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish
parent
e244d75b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
8 deletions
+27
-8
EnvironmentEndpoint.java
...gframework/boot/actuate/endpoint/EnvironmentEndpoint.java
+6
-5
EnvironmentEndpointTests.java
...ework/boot/actuate/endpoint/EnvironmentEndpointTests.java
+21
-3
No files found.
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/EnvironmentEndpoint.java
View file @
8b88c6e8
...
@@ -73,17 +73,18 @@ public class EnvironmentEndpoint {
...
@@ -73,17 +73,18 @@ public class EnvironmentEndpoint {
@ReadOperation
@ReadOperation
public
EnvironmentDescriptor
environment
(
String
pattern
)
{
public
EnvironmentDescriptor
environment
(
String
pattern
)
{
if
(
StringUtils
.
hasText
(
pattern
))
{
if
(
StringUtils
.
hasText
(
pattern
))
{
return
environment
(
Pattern
.
compile
(
pattern
).
asPredicate
());
return
getEnvironmentDescriptor
(
Pattern
.
compile
(
pattern
).
asPredicate
());
}
}
return
environment
((
name
)
->
true
);
return
getEnvironmentDescriptor
((
name
)
->
true
);
}
}
@ReadOperation
@ReadOperation
public
Object
getE
nvironmentEntry
(
@Selector
String
toMatch
)
{
public
EnvironmentDescriptor
e
nvironmentEntry
(
@Selector
String
toMatch
)
{
return
environment
((
name
)
->
toMatch
.
equals
(
name
)
);
return
getEnvironmentDescriptor
(
toMatch:
:
equals
);
}
}
private
EnvironmentDescriptor
environment
(
Predicate
<
String
>
propertyNamePredicate
)
{
private
EnvironmentDescriptor
getEnvironmentDescriptor
(
Predicate
<
String
>
propertyNamePredicate
)
{
PropertyResolver
resolver
=
getResolver
();
PropertyResolver
resolver
=
getResolver
();
List
<
PropertySourceDescriptor
>
propertySources
=
new
ArrayList
<>();
List
<
PropertySourceDescriptor
>
propertySources
=
new
ArrayList
<>();
getPropertySourcesAsMap
().
forEach
((
sourceName
,
source
)
->
{
getPropertySourcesAsMap
().
forEach
((
sourceName
,
source
)
->
{
...
...
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/EnvironmentEndpointTests.java
View file @
8b88c6e8
...
@@ -69,9 +69,9 @@ public class EnvironmentEndpointTests {
...
@@ -69,9 +69,9 @@ public class EnvironmentEndpointTests {
StandardEnvironment
environment
=
new
StandardEnvironment
();
StandardEnvironment
environment
=
new
StandardEnvironment
();
CompositePropertySource
source
=
new
CompositePropertySource
(
"composite"
);
CompositePropertySource
source
=
new
CompositePropertySource
(
"composite"
);
source
.
addPropertySource
(
new
MapPropertySource
(
"one"
,
source
.
addPropertySource
(
new
MapPropertySource
(
"one"
,
Collections
.
singletonMap
(
"foo"
,
(
Object
)
"bar"
)));
Collections
.
singletonMap
(
"foo"
,
"bar"
)));
source
.
addPropertySource
(
new
MapPropertySource
(
"two"
,
source
.
addPropertySource
(
new
MapPropertySource
(
"two"
,
Collections
.
singletonMap
(
"foo"
,
(
Object
)
"spam"
)));
Collections
.
singletonMap
(
"foo"
,
"spam"
)));
environment
.
getPropertySources
().
addFirst
(
source
);
environment
.
getPropertySources
().
addFirst
(
source
);
EnvironmentDescriptor
env
=
new
EnvironmentEndpoint
(
environment
)
EnvironmentDescriptor
env
=
new
EnvironmentEndpoint
(
environment
)
.
environment
(
null
);
.
environment
(
null
);
...
@@ -230,6 +230,25 @@ public class EnvironmentEndpointTests {
...
@@ -230,6 +230,25 @@ public class EnvironmentEndpointTests {
assertThat
(
foo
.
get
(
"bar"
)).
isEqualTo
(
"baz"
);
assertThat
(
foo
.
get
(
"bar"
)).
isEqualTo
(
"baz"
);
}
}
@Test
public
void
propertyEntry
()
{
StandardEnvironment
environment
=
new
StandardEnvironment
();
TestPropertyValues
.
of
(
"my.foo=bar"
,
"my.foo2=bar2"
)
.
applyTo
(
environment
);
EnvironmentDescriptor
env
=
new
EnvironmentEndpoint
(
environment
)
.
environmentEntry
(
"my.foo"
);
assertThat
(
env
).
isNotNull
();
assertThat
(
getSource
(
"test"
,
env
).
getProperties
().
get
(
"my.foo"
).
getValue
())
.
isEqualTo
(
"bar"
);
}
@Test
public
void
propertyEntryNoMatchReturnNull
()
{
EnvironmentDescriptor
env
=
new
EnvironmentEndpoint
(
new
StandardEnvironment
())
.
environmentEntry
(
"this.property.does-not-exist"
);
assertThat
(
env
).
isNull
();
}
private
void
clearSystemProperties
(
String
...
properties
)
{
private
void
clearSystemProperties
(
String
...
properties
)
{
for
(
String
property
:
properties
)
{
for
(
String
property
:
properties
)
{
System
.
clearProperty
(
property
);
System
.
clearProperty
(
property
);
...
@@ -254,5 +273,4 @@ public class EnvironmentEndpointTests {
...
@@ -254,5 +273,4 @@ public class EnvironmentEndpointTests {
}
}
}
}
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