commit
b6bcd555b7
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -25,7 +25,6 @@ import org.springframework.boot.autoconfigure.AutoConfiguration;
|
|||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.cassandra.CassandraAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.data.cassandra.CassandraDataAutoConfiguration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
/**
|
||||
|
@ -36,8 +35,8 @@ import org.springframework.context.annotation.Import;
|
|||
* @author Stephane Nicoll
|
||||
* @since 2.1.0
|
||||
*/
|
||||
@AutoConfiguration(after = { CassandraAutoConfiguration.class, CassandraDataAutoConfiguration.class,
|
||||
CassandraReactiveHealthContributorAutoConfiguration.class })
|
||||
@AutoConfiguration(
|
||||
after = { CassandraAutoConfiguration.class, CassandraReactiveHealthContributorAutoConfiguration.class })
|
||||
@ConditionalOnClass(CqlSession.class)
|
||||
@ConditionalOnEnabledHealthIndicator("cassandra")
|
||||
@Import(CassandraDriverConfiguration.class)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -24,8 +24,8 @@ import org.springframework.boot.actuate.autoconfigure.health.ConditionalOnEnable
|
|||
import org.springframework.boot.actuate.cassandra.CassandraDriverReactiveHealthIndicator;
|
||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.cassandra.CassandraAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.data.cassandra.CassandraReactiveDataAutoConfiguration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
/**
|
||||
|
@ -36,7 +36,7 @@ import org.springframework.context.annotation.Import;
|
|||
* @author Stephane Nicoll
|
||||
* @since 2.1.0
|
||||
*/
|
||||
@AutoConfiguration(after = CassandraReactiveDataAutoConfiguration.class)
|
||||
@AutoConfiguration(after = CassandraAutoConfiguration.class)
|
||||
@ConditionalOnClass({ CqlSession.class, Flux.class })
|
||||
@ConditionalOnEnabledHealthIndicator("cassandra")
|
||||
@Import(CassandraReactiveDriverConfiguration.class)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2024 the original author or authors.
|
||||
* Copyright 2012-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -22,9 +22,7 @@ import org.junit.jupiter.api.Test;
|
|||
import org.springframework.boot.actuate.autoconfigure.health.HealthContributorAutoConfiguration;
|
||||
import org.springframework.boot.actuate.cassandra.CassandraDriverHealthIndicator;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
||||
import org.springframework.boot.test.context.FilteredClassLoader;
|
||||
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
||||
import org.springframework.data.cassandra.core.CassandraOperations;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
@ -42,29 +40,20 @@ class CassandraHealthContributorAutoConfigurationTests {
|
|||
HealthContributorAutoConfiguration.class));
|
||||
|
||||
@Test
|
||||
void runWithoutCqlSessionOrCassandraOperationsShouldNotCreateIndicator() {
|
||||
void runWithoutCqlSessionShouldNotCreateIndicator() {
|
||||
this.contextRunner.run((context) -> assertThat(context).doesNotHaveBean("cassandraHealthContributor")
|
||||
.doesNotHaveBean(CassandraDriverHealthIndicator.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void runWithCqlSessionOnlyShouldCreateDriverIndicator() {
|
||||
void runWithCqlSessionShouldCreateDriverIndicator() {
|
||||
this.contextRunner.withBean(CqlSession.class, () -> mock(CqlSession.class))
|
||||
.run((context) -> assertThat(context).hasSingleBean(CassandraDriverHealthIndicator.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
void runWithCqlSessionAndSpringDataAbsentShouldCreateDriverIndicator() {
|
||||
this.contextRunner.withBean(CqlSession.class, () -> mock(CqlSession.class))
|
||||
.withClassLoader(new FilteredClassLoader("org.springframework.data"))
|
||||
.run((context) -> assertThat(context).hasSingleBean(CassandraDriverHealthIndicator.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void runWhenDisabledShouldNotCreateIndicator() {
|
||||
this.contextRunner.withBean(CqlSession.class, () -> mock(CqlSession.class))
|
||||
.withBean(CassandraOperations.class, () -> mock(CassandraOperations.class))
|
||||
.withPropertyValues("management.health.cassandra.enabled:false")
|
||||
.run((context) -> assertThat(context).doesNotHaveBean("cassandraHealthContributor")
|
||||
.doesNotHaveBean(CassandraDriverHealthIndicator.class));
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2024 the original author or authors.
|
||||
* Copyright 2012-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -20,13 +20,9 @@ import com.datastax.oss.driver.api.core.CqlSession;
|
|||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.actuate.autoconfigure.health.HealthContributorAutoConfiguration;
|
||||
import org.springframework.boot.actuate.cassandra.CassandraDriverHealthIndicator;
|
||||
import org.springframework.boot.actuate.cassandra.CassandraDriverReactiveHealthIndicator;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
||||
import org.springframework.boot.test.context.FilteredClassLoader;
|
||||
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
||||
import org.springframework.data.cassandra.core.CassandraOperations;
|
||||
import org.springframework.data.cassandra.core.ReactiveCassandraOperations;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
@ -44,41 +40,21 @@ class CassandraReactiveHealthContributorAutoConfigurationTests {
|
|||
CassandraHealthContributorAutoConfiguration.class, HealthContributorAutoConfiguration.class));
|
||||
|
||||
@Test
|
||||
void runWithoutCqlSessionOrReactiveCassandraOperationsShouldNotCreateIndicator() {
|
||||
void runWithoutCqlSessionShouldNotCreateIndicator() {
|
||||
this.contextRunner.run((context) -> assertThat(context).doesNotHaveBean("cassandraHealthContributor")
|
||||
.doesNotHaveBean(CassandraDriverReactiveHealthIndicator.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void runWithCqlSessionOnlyShouldCreateDriverIndicator() {
|
||||
void runWithCqlSessionShouldCreateIndicator() {
|
||||
this.contextRunner.withBean(CqlSession.class, () -> mock(CqlSession.class))
|
||||
.run((context) -> assertThat(context).hasBean("cassandraHealthContributor")
|
||||
.hasSingleBean(CassandraDriverReactiveHealthIndicator.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void runWithCqlSessionAndReactiveCassandraOperationsShouldCreateDriverIndicator() {
|
||||
this.contextRunner.withBean(CqlSession.class, () -> mock(CqlSession.class))
|
||||
.withBean(ReactiveCassandraOperations.class, () -> mock(ReactiveCassandraOperations.class))
|
||||
.withBean(CassandraOperations.class, () -> mock(CassandraOperations.class))
|
||||
.run((context) -> assertThat(context).hasBean("cassandraHealthContributor")
|
||||
.hasSingleBean(CassandraDriverReactiveHealthIndicator.class)
|
||||
.doesNotHaveBean(CassandraDriverHealthIndicator.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
void runWithCqlSessionAndSpringDataAbsentShouldCreateDriverIndicator() {
|
||||
this.contextRunner.withBean(CqlSession.class, () -> mock(CqlSession.class))
|
||||
.withClassLoader(new FilteredClassLoader("org.springframework.data"))
|
||||
.run((context) -> assertThat(context).hasBean("cassandraHealthContributor")
|
||||
.hasSingleBean(CassandraDriverReactiveHealthIndicator.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void runWhenDisabledShouldNotCreateIndicator() {
|
||||
this.contextRunner.withBean(CqlSession.class, () -> mock(CqlSession.class))
|
||||
.withBean(ReactiveCassandraOperations.class, () -> mock(ReactiveCassandraOperations.class))
|
||||
.withPropertyValues("management.health.cassandra.enabled:false")
|
||||
.run((context) -> assertThat(context).doesNotHaveBean("cassandraHealthContributor"));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue