Search in sources :

Example 1 with HealthComponent

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

the class HealthEndpointAutoConfigurationTests method runCreatesHealthEndpointWebExtension.

@Test
void runCreatesHealthEndpointWebExtension() {
    this.contextRunner.run((context) -> {
        HealthEndpointWebExtension webExtension = context.getBean(HealthEndpointWebExtension.class);
        WebEndpointResponse<HealthComponent> response = webExtension.health(ApiVersion.V3, WebServerNamespace.SERVER, SecurityContext.NONE, true, "simple");
        Health health = (Health) response.getBody();
        assertThat(response.getStatus()).isEqualTo(200);
        assertThat(health.getDetails()).containsEntry("counter", 42);
    });
}
Also used : HealthEndpointWebExtension(org.springframework.boot.actuate.health.HealthEndpointWebExtension) ReactiveHealthEndpointWebExtension(org.springframework.boot.actuate.health.ReactiveHealthEndpointWebExtension) HealthComponent(org.springframework.boot.actuate.health.HealthComponent) Health(org.springframework.boot.actuate.health.Health) Test(org.junit.jupiter.api.Test)

Example 2 with HealthComponent

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

the class HealthEndpointAutoConfigurationTests method runWhenHasHealthEndpointWebExtensionBeanDoesNotCreateExtraHealthEndpointWebExtension.

@Test
void runWhenHasHealthEndpointWebExtensionBeanDoesNotCreateExtraHealthEndpointWebExtension() {
    this.contextRunner.withUserConfiguration(HealthEndpointWebExtensionConfiguration.class).run((context) -> {
        HealthEndpointWebExtension webExtension = context.getBean(HealthEndpointWebExtension.class);
        WebEndpointResponse<HealthComponent> response = webExtension.health(ApiVersion.V3, WebServerNamespace.SERVER, SecurityContext.NONE, true, "simple");
        assertThat(response).isNull();
    });
}
Also used : HealthEndpointWebExtension(org.springframework.boot.actuate.health.HealthEndpointWebExtension) ReactiveHealthEndpointWebExtension(org.springframework.boot.actuate.health.ReactiveHealthEndpointWebExtension) HealthComponent(org.springframework.boot.actuate.health.HealthComponent) Test(org.junit.jupiter.api.Test)

Example 3 with HealthComponent

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

the class CloudFoundryReactiveHealthEndpointWebExtensionTests method healthComponentsAlwaysPresent.

@Test
void healthComponentsAlwaysPresent() {
    this.contextRunner.run((context) -> {
        CloudFoundryReactiveHealthEndpointWebExtension extension = context.getBean(CloudFoundryReactiveHealthEndpointWebExtension.class);
        HealthComponent body = extension.health(ApiVersion.V3).block(Duration.ofSeconds(30)).getBody();
        HealthComponent health = ((CompositeHealth) body).getComponents().entrySet().iterator().next().getValue();
        assertThat(((Health) health).getDetails()).containsEntry("spring", "boot");
    });
}
Also used : HealthComponent(org.springframework.boot.actuate.health.HealthComponent) CompositeHealth(org.springframework.boot.actuate.health.CompositeHealth) Health(org.springframework.boot.actuate.health.Health) CompositeHealth(org.springframework.boot.actuate.health.CompositeHealth) Test(org.junit.jupiter.api.Test)

Example 4 with HealthComponent

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

the class CloudFoundryHealthEndpointWebExtensionTests method healthComponentsAlwaysPresent.

@Test
void healthComponentsAlwaysPresent() {
    this.contextRunner.run((context) -> {
        CloudFoundryHealthEndpointWebExtension extension = context.getBean(CloudFoundryHealthEndpointWebExtension.class);
        HealthComponent body = extension.health(ApiVersion.V3).getBody();
        HealthComponent health = ((CompositeHealth) body).getComponents().entrySet().iterator().next().getValue();
        assertThat(((Health) health).getDetails()).containsEntry("spring", "boot");
    });
}
Also used : HealthComponent(org.springframework.boot.actuate.health.HealthComponent) CompositeHealth(org.springframework.boot.actuate.health.CompositeHealth) Health(org.springframework.boot.actuate.health.Health) CompositeHealth(org.springframework.boot.actuate.health.CompositeHealth) Test(org.junit.jupiter.api.Test)

Example 5 with HealthComponent

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

the class HealthEndpointAutoConfigurationTests method runWhenHasReactiveHealthEndpointWebExtensionBeanDoesNotCreateExtraReactiveHealthEndpointWebExtension.

@Test
void runWhenHasReactiveHealthEndpointWebExtensionBeanDoesNotCreateExtraReactiveHealthEndpointWebExtension() {
    this.reactiveContextRunner.withUserConfiguration(ReactiveHealthEndpointWebExtensionConfiguration.class).run((context) -> {
        ReactiveHealthEndpointWebExtension webExtension = context.getBean(ReactiveHealthEndpointWebExtension.class);
        Mono<WebEndpointResponse<? extends HealthComponent>> response = webExtension.health(ApiVersion.V3, WebServerNamespace.SERVER, SecurityContext.NONE, true, "simple");
        assertThat(response).isNull();
    });
}
Also used : HealthComponent(org.springframework.boot.actuate.health.HealthComponent) WebEndpointResponse(org.springframework.boot.actuate.endpoint.web.WebEndpointResponse) ReactiveHealthEndpointWebExtension(org.springframework.boot.actuate.health.ReactiveHealthEndpointWebExtension) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)6 HealthComponent (org.springframework.boot.actuate.health.HealthComponent)6 Health (org.springframework.boot.actuate.health.Health)4 ReactiveHealthEndpointWebExtension (org.springframework.boot.actuate.health.ReactiveHealthEndpointWebExtension)4 WebEndpointResponse (org.springframework.boot.actuate.endpoint.web.WebEndpointResponse)2 CompositeHealth (org.springframework.boot.actuate.health.CompositeHealth)2 HealthEndpointWebExtension (org.springframework.boot.actuate.health.HealthEndpointWebExtension)2