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
8bef0a1e
Commit
8bef0a1e
authored
Jan 16, 2017
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish contribution
Closes gh-7905
parent
b2250f4a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
12 deletions
+26
-12
LdapHealthIndicator.java
...ingframework/boot/actuate/health/LdapHealthIndicator.java
+16
-6
HealthIndicatorAutoConfigurationTests.java
.../autoconfigure/HealthIndicatorAutoConfigurationTests.java
+1
-2
LdapHealthIndicatorTests.java
...amework/boot/actuate/health/LdapHealthIndicatorTests.java
+8
-4
appendix-application-properties.adoc
...cs/src/main/asciidoc/appendix-application-properties.adoc
+1
-0
No files found.
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/LdapHealthIndicator.java
View file @
8bef0a1e
...
...
@@ -27,10 +27,13 @@ import org.springframework.util.Assert;
* {@link HealthIndicator} for configured LDAP server(s).
*
* @author Eddú Meléndez
* @author Stephane Nicoll
* @version 1.5.0
*/
public
class
LdapHealthIndicator
extends
AbstractHealthIndicator
{
private
static
final
ContextExecutor
<
String
>
versionContextExecutor
=
new
VersionContextExecutor
();
private
final
LdapOperations
ldapOperations
;
public
LdapHealthIndicator
(
LdapOperations
ldapOperations
)
{
...
...
@@ -40,13 +43,20 @@ public class LdapHealthIndicator extends AbstractHealthIndicator {
@Override
protected
void
doHealthCheck
(
Health
.
Builder
builder
)
throws
Exception
{
String
version
=
(
String
)
this
.
ldapOperations
.
executeReadOnly
(
new
ContextExecutor
<
Object
>()
{
@Override
public
Object
executeWithContext
(
DirContext
ctx
)
throws
NamingException
{
return
ctx
.
getEnvironment
().
get
(
"java.naming.ldap.version"
);
}
});
String
version
=
this
.
ldapOperations
.
executeReadOnly
(
versionContextExecutor
);
builder
.
up
().
withDetail
(
"version"
,
version
);
}
private
static
class
VersionContextExecutor
implements
ContextExecutor
<
String
>
{
@Override
public
String
executeWithContext
(
DirContext
ctx
)
throws
NamingException
{
Object
version
=
ctx
.
getEnvironment
().
get
(
"java.naming.ldap.version"
);
if
(
version
!=
null
)
{
return
(
String
)
version
;
}
return
null
;
}
}
}
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/HealthIndicatorAutoConfigurationTests.java
View file @
8bef0a1e
...
...
@@ -641,8 +641,7 @@ public class HealthIndicatorAutoConfigurationTests {
@Bean
public
LdapOperations
ldapOperations
()
{
LdapOperations
operations
=
mock
(
LdapOperations
.
class
);
return
operations
;
return
mock
(
LdapOperations
.
class
);
}
}
...
...
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/LdapHealthIndicatorTests.java
View file @
8bef0a1e
...
...
@@ -59,13 +59,16 @@ public class LdapHealthIndicatorTests {
@Test
public
void
indicatorExist
()
{
this
.
context
.
register
(
LdapAutoConfiguration
.
class
,
LdapDataAutoConfiguration
.
class
,
PropertyPlaceholderAutoConfiguration
.
class
,
EndpointAutoConfiguration
.
class
,
this
.
context
.
register
(
LdapAutoConfiguration
.
class
,
LdapDataAutoConfiguration
.
class
,
PropertyPlaceholderAutoConfiguration
.
class
,
EndpointAutoConfiguration
.
class
,
HealthIndicatorAutoConfiguration
.
class
);
this
.
context
.
refresh
();
LdapTemplate
ldapTemplate
=
this
.
context
.
getBean
(
LdapTemplate
.
class
);
assertThat
(
ldapTemplate
).
isNotNull
();
LdapHealthIndicator
healthIndicator
=
this
.
context
.
getBean
(
LdapHealthIndicator
.
class
);
LdapHealthIndicator
healthIndicator
=
this
.
context
.
getBean
(
LdapHealthIndicator
.
class
);
assertThat
(
healthIndicator
).
isNotNull
();
}
...
...
@@ -84,7 +87,8 @@ public class LdapHealthIndicatorTests {
public
void
ldapIsDown
()
{
LdapTemplate
ldapTemplate
=
mock
(
LdapTemplate
.
class
);
given
(
ldapTemplate
.
executeReadOnly
(
any
(
ContextExecutor
.
class
)))
.
willThrow
(
new
CommunicationException
(
new
javax
.
naming
.
CommunicationException
(
"Connection failed"
)));
.
willThrow
(
new
CommunicationException
(
new
javax
.
naming
.
CommunicationException
(
"Connection failed"
)));
LdapHealthIndicator
healthIndicator
=
new
LdapHealthIndicator
(
ldapTemplate
);
Health
health
=
healthIndicator
.
health
();
assertThat
(
health
.
getStatus
()).
isEqualTo
(
Status
.
DOWN
);
...
...
spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc
View file @
8bef0a1e
...
...
@@ -1114,6 +1114,7 @@ content into your application; rather pick only the properties that you need.
management.health.elasticsearch.indices= # Comma-separated index names.
management.health.elasticsearch.response-timeout=100 # The time, in milliseconds, to wait for a response from the cluster.
management.health.jms.enabled=true # Enable JMS health check.
management.health.ldap.enabled=true # Enable LDAP health check.
management.health.mail.enabled=true # Enable Mail health check.
management.health.mongo.enabled=true # Enable MongoDB health check.
management.health.rabbit.enabled=true # Enable RabbitMQ health check.
...
...
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