Search in sources :

Example 1 with HealthContributorRegistry

use of org.springframework.boot.actuate.health.HealthContributorRegistry in project spring-boot by spring-projects.

the class AutoConfiguredHealthContributorRegistryTests method registerContributorWithGroupNameThrowsException.

@Test
void registerContributorWithGroupNameThrowsException() {
    HealthContributorRegistry registry = new AutoConfiguredHealthContributorRegistry(Collections.emptyMap(), Arrays.asList("spring", "boot"));
    assertThatIllegalStateException().isThrownBy(() -> registry.registerContributor("spring", mock(HealthContributor.class))).withMessage("HealthContributor with name \"spring\" clashes with group");
}
Also used : HealthContributorRegistry(org.springframework.boot.actuate.health.HealthContributorRegistry) HealthContributor(org.springframework.boot.actuate.health.HealthContributor) Test(org.junit.jupiter.api.Test)

Example 2 with HealthContributorRegistry

use of org.springframework.boot.actuate.health.HealthContributorRegistry in project spring-boot by spring-projects.

the class HealthEndpointAutoConfigurationTests method runCreatesHealthContributorRegistryContainingHealthBeans.

@Test
void runCreatesHealthContributorRegistryContainingHealthBeans() {
    this.contextRunner.run((context) -> {
        HealthContributorRegistry registry = context.getBean(HealthContributorRegistry.class);
        Object[] names = registry.stream().map(NamedContributor::getName).toArray();
        assertThat(names).containsExactlyInAnyOrder("simple", "additional", "ping", "reactive");
    });
}
Also used : HealthContributorRegistry(org.springframework.boot.actuate.health.HealthContributorRegistry) ReactiveHealthContributorRegistry(org.springframework.boot.actuate.health.ReactiveHealthContributorRegistry) DefaultReactiveHealthContributorRegistry(org.springframework.boot.actuate.health.DefaultReactiveHealthContributorRegistry) DefaultHealthContributorRegistry(org.springframework.boot.actuate.health.DefaultHealthContributorRegistry) Test(org.junit.jupiter.api.Test)

Example 3 with HealthContributorRegistry

use of org.springframework.boot.actuate.health.HealthContributorRegistry in project spring-boot by spring-projects.

the class HealthEndpointAutoConfigurationTests method runWhenHasHealthContributorRegistryBeanDoesNotCreateAdditionalRegistry.

@Test
void runWhenHasHealthContributorRegistryBeanDoesNotCreateAdditionalRegistry() {
    this.contextRunner.withUserConfiguration(HealthContributorRegistryConfiguration.class).run((context) -> {
        HealthContributorRegistry registry = context.getBean(HealthContributorRegistry.class);
        Object[] names = registry.stream().map(NamedContributor::getName).toArray();
        assertThat(names).isEmpty();
    });
}
Also used : HealthContributorRegistry(org.springframework.boot.actuate.health.HealthContributorRegistry) ReactiveHealthContributorRegistry(org.springframework.boot.actuate.health.ReactiveHealthContributorRegistry) DefaultReactiveHealthContributorRegistry(org.springframework.boot.actuate.health.DefaultReactiveHealthContributorRegistry) DefaultHealthContributorRegistry(org.springframework.boot.actuate.health.DefaultHealthContributorRegistry) Test(org.junit.jupiter.api.Test)

Example 4 with HealthContributorRegistry

use of org.springframework.boot.actuate.health.HealthContributorRegistry in project spring-boot by spring-projects.

the class HealthEndpointAutoConfigurationTests method runWhenNoReactorCreatesHealthContributorRegistryContainingHealthBeans.

@Test
void runWhenNoReactorCreatesHealthContributorRegistryContainingHealthBeans() {
    ClassLoader classLoader = new FilteredClassLoader(Mono.class, Flux.class);
    this.contextRunner.withClassLoader(classLoader).run((context) -> {
        HealthContributorRegistry registry = context.getBean(HealthContributorRegistry.class);
        Object[] names = registry.stream().map(NamedContributor::getName).toArray();
        assertThat(names).containsExactlyInAnyOrder("simple", "additional", "ping");
    });
}
Also used : HealthContributorRegistry(org.springframework.boot.actuate.health.HealthContributorRegistry) ReactiveHealthContributorRegistry(org.springframework.boot.actuate.health.ReactiveHealthContributorRegistry) DefaultReactiveHealthContributorRegistry(org.springframework.boot.actuate.health.DefaultReactiveHealthContributorRegistry) DefaultHealthContributorRegistry(org.springframework.boot.actuate.health.DefaultHealthContributorRegistry) FilteredClassLoader(org.springframework.boot.test.context.FilteredClassLoader) FilteredClassLoader(org.springframework.boot.test.context.FilteredClassLoader) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)4 HealthContributorRegistry (org.springframework.boot.actuate.health.HealthContributorRegistry)4 DefaultHealthContributorRegistry (org.springframework.boot.actuate.health.DefaultHealthContributorRegistry)3 DefaultReactiveHealthContributorRegistry (org.springframework.boot.actuate.health.DefaultReactiveHealthContributorRegistry)3 ReactiveHealthContributorRegistry (org.springframework.boot.actuate.health.ReactiveHealthContributorRegistry)3 HealthContributor (org.springframework.boot.actuate.health.HealthContributor)1 FilteredClassLoader (org.springframework.boot.test.context.FilteredClassLoader)1