use of org.springframework.boot.actuate.health.CompositeHealthContributor in project spring-boot by spring-projects.
the class DataSourceHealthContributorAutoConfigurationTests method runWithRoutingAndEmbeddedDataSourceShouldIncludeRoutingDataSource.
@Test
void runWithRoutingAndEmbeddedDataSourceShouldIncludeRoutingDataSource() {
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class, RoutingDataSourceConfig.class).run((context) -> {
CompositeHealthContributor composite = context.getBean(CompositeHealthContributor.class);
assertThat(composite.getContributor("dataSource")).isInstanceOf(DataSourceHealthIndicator.class);
assertThat(composite.getContributor("routingDataSource")).isInstanceOf(RoutingDataSourceHealthContributor.class);
});
}
use of org.springframework.boot.actuate.health.CompositeHealthContributor in project spring-cloud-gcp by spring-cloud.
the class PubSubHealthIndicatorAutoConfigurationTests method compositeHealthIndicatorPresentMultiplePubSubTemplate.
@Test
public void compositeHealthIndicatorPresentMultiplePubSubTemplate() {
PubSubTemplate mockPubSubTemplate1 = mock(PubSubTemplate.class);
PubSubTemplate mockPubSubTemplate2 = mock(PubSubTemplate.class);
this.baseContextRunner.withBean("pubSubTemplate1", PubSubTemplate.class, () -> mockPubSubTemplate1).withBean("pubSubTemplate2", PubSubTemplate.class, () -> mockPubSubTemplate2).withPropertyValues("management.health.pubsub.enabled=true").run(ctx -> {
assertThatThrownBy(() -> ctx.getBean(PubSubHealthIndicator.class)).isInstanceOf(NoSuchBeanDefinitionException.class);
CompositeHealthContributor healthContributor = ctx.getBean("pubSubHealthContributor", CompositeHealthContributor.class);
assertThat(healthContributor).isNotNull();
assertThat(healthContributor.stream()).hasSize(2);
healthContributor.stream().forEach(System.out::println);
assertThat(healthContributor.stream().map(c -> ((NamedContributor) c).getName())).containsExactlyInAnyOrder("pubSubTemplate1", "pubSubTemplate2");
});
}
use of org.springframework.boot.actuate.health.CompositeHealthContributor in project spring-boot by spring-projects.
the class DataSourceHealthContributorAutoConfigurationTests method runWhenMultipleDataSourceBeansShouldCreateCompositeIndicator.
@Test
void runWhenMultipleDataSourceBeansShouldCreateCompositeIndicator() {
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class, DataSourceConfig.class).run((context) -> {
assertThat(context).hasSingleBean(CompositeHealthContributor.class);
CompositeHealthContributor contributor = context.getBean(CompositeHealthContributor.class);
String[] names = contributor.stream().map(NamedContributor::getName).toArray(String[]::new);
assertThat(names).containsExactlyInAnyOrder("dataSource", "testDataSource");
});
}
Aggregations