Polish "Add HealthIndicator for Hazelcast"
See gh-17499
This commit is contained in:
@@ -16,11 +16,7 @@
|
||||
|
||||
package org.springframework.boot.actuate.autoconfigure.hazelcast;
|
||||
|
||||
import com.hazelcast.client.config.ClientConfig;
|
||||
import com.hazelcast.config.Config;
|
||||
import com.hazelcast.core.Hazelcast;
|
||||
import com.hazelcast.core.HazelcastInstance;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.actuate.autoconfigure.health.HealthIndicatorAutoConfiguration;
|
||||
@@ -40,17 +36,10 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
*/
|
||||
class HazelcastHealthIndicatorAutoConfigurationIntegrationTests {
|
||||
|
||||
private final HazelcastInstance hazelcastServer = Hazelcast.newHazelcastInstance(new Config());
|
||||
|
||||
private ApplicationContextRunner contextRunner = new ApplicationContextRunner().withBean(ClientConfig.class)
|
||||
private ApplicationContextRunner contextRunner = new ApplicationContextRunner()
|
||||
.withConfiguration(AutoConfigurations.of(HazelcastHealthIndicatorAutoConfiguration.class,
|
||||
HazelcastAutoConfiguration.class, HealthIndicatorAutoConfiguration.class));
|
||||
|
||||
@AfterEach
|
||||
void shutdown() {
|
||||
this.hazelcastServer.shutdown();
|
||||
}
|
||||
|
||||
@Test
|
||||
void hazelcastUp() {
|
||||
this.contextRunner.run((context) -> {
|
||||
@@ -66,7 +55,7 @@ class HazelcastHealthIndicatorAutoConfigurationIntegrationTests {
|
||||
@Test
|
||||
void hazelcastDown() {
|
||||
this.contextRunner.run((context) -> {
|
||||
shutdown();
|
||||
context.getBean(HazelcastInstance.class).shutdown();
|
||||
assertThat(context).hasSingleBean(HazelcastHealthIndicator.class);
|
||||
Health health = context.getBean(HazelcastHealthIndicator.class).health();
|
||||
assertThat(health.getStatus()).isEqualTo(Status.DOWN);
|
||||
|
||||
@@ -48,7 +48,6 @@ class HazelcastHealthIndicatorAutoConfigurationTests {
|
||||
void runWhenDisabledShouldNotCreateIndicator() {
|
||||
this.contextRunner.withPropertyValues("management.health.hazelcast.enabled:false")
|
||||
.run((context) -> assertThat(context).doesNotHaveBean(HazelcastHealthIndicator.class)
|
||||
.doesNotHaveBean(HazelcastHealthIndicator.class)
|
||||
.hasSingleBean(ApplicationHealthIndicator.class));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user