use of org.springframework.boot.actuate.health.Health in project spring-boot by spring-projects.
the class RedisHealthIndicatorTests method healthWhenClusterStateIsOkShouldBeUp.
@Test
void healthWhenClusterStateIsOkShouldBeUp() {
RedisConnectionFactory redisConnectionFactory = createClusterConnectionFactory("ok");
RedisHealthIndicator healthIndicator = new RedisHealthIndicator(redisConnectionFactory);
Health health = healthIndicator.health();
assertThat(health.getStatus()).isEqualTo(Status.UP);
assertThat(health.getDetails().get("cluster_size")).isEqualTo(4L);
assertThat(health.getDetails().get("slots_up")).isEqualTo(4L);
assertThat(health.getDetails().get("slots_fail")).isEqualTo(0L);
then(redisConnectionFactory).should(atLeastOnce()).getConnection();
}
use of org.springframework.boot.actuate.health.Health in project spring-boot by spring-projects.
the class HazelcastHealthIndicatorTests method hazelcastDown.
@Test
void hazelcastDown() {
HazelcastInstance hazelcast = mock(HazelcastInstance.class);
given(hazelcast.executeTransaction(any())).willThrow(new HazelcastException());
Health health = new HazelcastHealthIndicator(hazelcast).health();
assertThat(health.getStatus()).isEqualTo(Status.DOWN);
}
use of org.springframework.boot.actuate.health.Health in project spring-boot by spring-projects.
the class JmsHealthIndicatorTests method jmsBrokerIsDown.
@Test
void jmsBrokerIsDown() throws JMSException {
ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
given(connectionFactory.createConnection()).willThrow(new JMSException("test", "123"));
JmsHealthIndicator indicator = new JmsHealthIndicator(connectionFactory);
Health health = indicator.health();
assertThat(health.getStatus()).isEqualTo(Status.DOWN);
assertThat(health.getDetails().get("provider")).isNull();
}
use of org.springframework.boot.actuate.health.Health in project spring-boot by spring-projects.
the class JmsHealthIndicatorTests method whenConnectionStartIsUnresponsiveStatusIsDown.
@Test
void whenConnectionStartIsUnresponsiveStatusIsDown() throws JMSException {
ConnectionMetaData connectionMetaData = mock(ConnectionMetaData.class);
given(connectionMetaData.getJMSProviderName()).willReturn("JMS test provider");
Connection connection = mock(Connection.class);
UnresponsiveStartAnswer unresponsiveStartAnswer = new UnresponsiveStartAnswer();
willAnswer(unresponsiveStartAnswer).given(connection).start();
willAnswer((invocation) -> {
unresponsiveStartAnswer.connectionClosed();
return null;
}).given(connection).close();
ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
given(connectionFactory.createConnection()).willReturn(connection);
JmsHealthIndicator indicator = new JmsHealthIndicator(connectionFactory);
Health health = indicator.health();
assertThat(health.getStatus()).isEqualTo(Status.DOWN);
assertThat((String) health.getDetails().get("error")).contains("Connection closed");
}
use of org.springframework.boot.actuate.health.Health in project spring-boot by spring-projects.
the class LdapHealthIndicatorTests method ldapIsDown.
@Test
@SuppressWarnings("unchecked")
void ldapIsDown() {
LdapTemplate ldapTemplate = mock(LdapTemplate.class);
given(ldapTemplate.executeReadOnly((ContextExecutor<String>) any())).willThrow(new CommunicationException(new javax.naming.CommunicationException("Connection failed")));
LdapHealthIndicator healthIndicator = new LdapHealthIndicator(ldapTemplate);
Health health = healthIndicator.health();
assertThat(health.getStatus()).isEqualTo(Status.DOWN);
assertThat((String) health.getDetails().get("error")).contains("Connection failed");
then(ldapTemplate).should().executeReadOnly((ContextExecutor<String>) any());
}
Aggregations