|
|
@ -62,31 +62,33 @@ public class LdapHealthIndicatorTests {
|
|
|
|
this.context.register(LdapAutoConfiguration.class,
|
|
|
|
this.context.register(LdapAutoConfiguration.class,
|
|
|
|
LdapDataAutoConfiguration.class,
|
|
|
|
LdapDataAutoConfiguration.class,
|
|
|
|
PropertyPlaceholderAutoConfiguration.class,
|
|
|
|
PropertyPlaceholderAutoConfiguration.class,
|
|
|
|
EndpointAutoConfiguration.class,
|
|
|
|
EndpointAutoConfiguration.class, HealthIndicatorAutoConfiguration.class);
|
|
|
|
HealthIndicatorAutoConfiguration.class);
|
|
|
|
|
|
|
|
this.context.refresh();
|
|
|
|
this.context.refresh();
|
|
|
|
LdapTemplate ldapTemplate = this.context.getBean(LdapTemplate.class);
|
|
|
|
LdapTemplate ldapTemplate = this.context.getBean(LdapTemplate.class);
|
|
|
|
assertThat(ldapTemplate).isNotNull();
|
|
|
|
assertThat(ldapTemplate).isNotNull();
|
|
|
|
LdapHealthIndicator healthIndicator = this.context.getBean(
|
|
|
|
LdapHealthIndicator healthIndicator = this.context
|
|
|
|
LdapHealthIndicator.class);
|
|
|
|
.getBean(LdapHealthIndicator.class);
|
|
|
|
assertThat(healthIndicator).isNotNull();
|
|
|
|
assertThat(healthIndicator).isNotNull();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
public void ldapIsUp() {
|
|
|
|
public void ldapIsUp() {
|
|
|
|
LdapTemplate ldapTemplate = mock(LdapTemplate.class);
|
|
|
|
LdapTemplate ldapTemplate = mock(LdapTemplate.class);
|
|
|
|
given(ldapTemplate.executeReadOnly(any(ContextExecutor.class))).willReturn("3");
|
|
|
|
given(ldapTemplate.executeReadOnly((ContextExecutor<String>) any()))
|
|
|
|
|
|
|
|
.willReturn("3");
|
|
|
|
LdapHealthIndicator healthIndicator = new LdapHealthIndicator(ldapTemplate);
|
|
|
|
LdapHealthIndicator healthIndicator = new LdapHealthIndicator(ldapTemplate);
|
|
|
|
Health health = healthIndicator.health();
|
|
|
|
Health health = healthIndicator.health();
|
|
|
|
assertThat(health.getStatus()).isEqualTo(Status.UP);
|
|
|
|
assertThat(health.getStatus()).isEqualTo(Status.UP);
|
|
|
|
assertThat(health.getDetails().get("version")).isEqualTo("3");
|
|
|
|
assertThat(health.getDetails().get("version")).isEqualTo("3");
|
|
|
|
verify(ldapTemplate).executeReadOnly(any(ContextExecutor.class));
|
|
|
|
verify(ldapTemplate).executeReadOnly((ContextExecutor<String>) any());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
public void ldapIsDown() {
|
|
|
|
public void ldapIsDown() {
|
|
|
|
LdapTemplate ldapTemplate = mock(LdapTemplate.class);
|
|
|
|
LdapTemplate ldapTemplate = mock(LdapTemplate.class);
|
|
|
|
given(ldapTemplate.executeReadOnly(any(ContextExecutor.class)))
|
|
|
|
given(ldapTemplate.executeReadOnly((ContextExecutor<String>) any()))
|
|
|
|
.willThrow(new CommunicationException(
|
|
|
|
.willThrow(new CommunicationException(
|
|
|
|
new javax.naming.CommunicationException("Connection failed")));
|
|
|
|
new javax.naming.CommunicationException("Connection failed")));
|
|
|
|
LdapHealthIndicator healthIndicator = new LdapHealthIndicator(ldapTemplate);
|
|
|
|
LdapHealthIndicator healthIndicator = new LdapHealthIndicator(ldapTemplate);
|
|
|
@ -94,7 +96,7 @@ public class LdapHealthIndicatorTests {
|
|
|
|
assertThat(health.getStatus()).isEqualTo(Status.DOWN);
|
|
|
|
assertThat(health.getStatus()).isEqualTo(Status.DOWN);
|
|
|
|
assertThat((String) health.getDetails().get("error"))
|
|
|
|
assertThat((String) health.getDetails().get("error"))
|
|
|
|
.contains("Connection failed");
|
|
|
|
.contains("Connection failed");
|
|
|
|
verify(ldapTemplate).executeReadOnly(any(ContextExecutor.class));
|
|
|
|
verify(ldapTemplate).executeReadOnly((ContextExecutor<String>) any());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|