|
|
@ -33,9 +33,8 @@ import org.springframework.boot.autoconfigure.data.empty.EmptyDataPackage;
|
|
|
|
import org.springframework.boot.test.context.assertj.AssertableApplicationContext;
|
|
|
|
import org.springframework.boot.test.context.assertj.AssertableApplicationContext;
|
|
|
|
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
|
|
|
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
|
import org.springframework.context.annotation.ComponentScan;
|
|
|
|
|
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
import org.springframework.context.annotation.FilterType;
|
|
|
|
import org.springframework.context.annotation.Import;
|
|
|
|
import org.springframework.data.cassandra.core.mapping.CassandraMappingContext;
|
|
|
|
import org.springframework.data.cassandra.core.mapping.CassandraMappingContext;
|
|
|
|
import org.springframework.data.cassandra.repository.config.EnableCassandraRepositories;
|
|
|
|
import org.springframework.data.cassandra.repository.config.EnableCassandraRepositories;
|
|
|
|
import org.springframework.test.util.ReflectionTestUtils;
|
|
|
|
import org.springframework.test.util.ReflectionTestUtils;
|
|
|
@ -58,7 +57,7 @@ class CassandraRepositoriesAutoConfigurationTests {
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
void testDefaultRepositoryConfiguration() {
|
|
|
|
void testDefaultRepositoryConfiguration() {
|
|
|
|
this.contextRunner.withUserConfiguration(TestConfiguration.class).run((context) -> {
|
|
|
|
this.contextRunner.withUserConfiguration(DefaultConfiguration.class).run((context) -> {
|
|
|
|
assertThat(context).hasSingleBean(CityRepository.class);
|
|
|
|
assertThat(context).hasSingleBean(CityRepository.class);
|
|
|
|
assertThat(context).hasSingleBean(Cluster.class);
|
|
|
|
assertThat(context).hasSingleBean(Cluster.class);
|
|
|
|
assertThat(getInitialEntitySet(context)).hasSize(1);
|
|
|
|
assertThat(getInitialEntitySet(context)).hasSize(1);
|
|
|
@ -67,32 +66,30 @@ class CassandraRepositoriesAutoConfigurationTests {
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
void testNoRepositoryConfiguration() {
|
|
|
|
void testNoRepositoryConfiguration() {
|
|
|
|
this.contextRunner.withUserConfiguration(TestExcludeConfiguration.class, EmptyConfiguration.class)
|
|
|
|
this.contextRunner.withUserConfiguration(EmptyConfiguration.class).run((context) -> {
|
|
|
|
.run((context) -> {
|
|
|
|
assertThat(context).hasSingleBean(Cluster.class);
|
|
|
|
assertThat(context).hasSingleBean(Cluster.class);
|
|
|
|
assertThat(getInitialEntitySet(context)).isEmpty();
|
|
|
|
assertThat(getInitialEntitySet(context)).hasSize(1).containsOnly(City.class);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
void doesNotTriggerDefaultRepositoryDetectionIfCustomized() {
|
|
|
|
void doesNotTriggerDefaultRepositoryDetectionIfCustomized() {
|
|
|
|
this.contextRunner.withUserConfiguration(TestExcludeConfiguration.class, CustomizedConfiguration.class)
|
|
|
|
this.contextRunner.withUserConfiguration(CustomizedConfiguration.class).run((context) -> {
|
|
|
|
.run((context) -> {
|
|
|
|
assertThat(context).hasSingleBean(CityCassandraRepository.class);
|
|
|
|
assertThat(context).hasSingleBean(CityCassandraRepository.class);
|
|
|
|
assertThat(getInitialEntitySet(context)).hasSize(1).containsOnly(City.class);
|
|
|
|
assertThat(getInitialEntitySet(context)).hasSize(1).containsOnly(City.class);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
void enablingReactiveRepositoriesDisablesImperativeRepositories() {
|
|
|
|
void enablingReactiveRepositoriesDisablesImperativeRepositories() {
|
|
|
|
this.contextRunner.withUserConfiguration(TestConfiguration.class)
|
|
|
|
this.contextRunner.withUserConfiguration(DefaultConfiguration.class)
|
|
|
|
.withPropertyValues("spring.data.cassandra.repositories.type=reactive")
|
|
|
|
.withPropertyValues("spring.data.cassandra.repositories.type=reactive")
|
|
|
|
.run((context) -> assertThat(context).doesNotHaveBean(CityCassandraRepository.class));
|
|
|
|
.run((context) -> assertThat(context).doesNotHaveBean(CityCassandraRepository.class));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
void enablingNoRepositoriesDisablesImperativeRepositories() {
|
|
|
|
void enablingNoRepositoriesDisablesImperativeRepositories() {
|
|
|
|
this.contextRunner.withUserConfiguration(TestConfiguration.class)
|
|
|
|
this.contextRunner.withUserConfiguration(DefaultConfiguration.class)
|
|
|
|
.withPropertyValues("spring.data.cassandra.repositories.type=none")
|
|
|
|
.withPropertyValues("spring.data.cassandra.repositories.type=none")
|
|
|
|
.run((context) -> assertThat(context).doesNotHaveBean(CityCassandraRepository.class));
|
|
|
|
.run((context) -> assertThat(context).doesNotHaveBean(CityCassandraRepository.class));
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -104,7 +101,6 @@ class CassandraRepositoriesAutoConfigurationTests {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Configuration(proxyBeanMethods = false)
|
|
|
|
@Configuration(proxyBeanMethods = false)
|
|
|
|
@TestAutoConfigurationPackage(City.class)
|
|
|
|
|
|
|
|
static class TestConfiguration {
|
|
|
|
static class TestConfiguration {
|
|
|
|
|
|
|
|
|
|
|
|
@Bean
|
|
|
|
@Bean
|
|
|
@ -116,21 +112,23 @@ class CassandraRepositoriesAutoConfigurationTests {
|
|
|
|
|
|
|
|
|
|
|
|
@Configuration(proxyBeanMethods = false)
|
|
|
|
@Configuration(proxyBeanMethods = false)
|
|
|
|
@TestAutoConfigurationPackage(EmptyDataPackage.class)
|
|
|
|
@TestAutoConfigurationPackage(EmptyDataPackage.class)
|
|
|
|
|
|
|
|
@Import(TestConfiguration.class)
|
|
|
|
static class EmptyConfiguration {
|
|
|
|
static class EmptyConfiguration {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Configuration(proxyBeanMethods = false)
|
|
|
|
@Configuration(proxyBeanMethods = false)
|
|
|
|
@TestAutoConfigurationPackage(CassandraRepositoriesAutoConfigurationTests.class)
|
|
|
|
@TestAutoConfigurationPackage(City.class)
|
|
|
|
@EnableCassandraRepositories(basePackageClasses = CityCassandraRepository.class)
|
|
|
|
@Import(TestConfiguration.class)
|
|
|
|
static class CustomizedConfiguration {
|
|
|
|
static class DefaultConfiguration {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Configuration(proxyBeanMethods = false)
|
|
|
|
@Configuration(proxyBeanMethods = false)
|
|
|
|
@ComponentScan(
|
|
|
|
@TestAutoConfigurationPackage(CassandraRepositoriesAutoConfigurationTests.class)
|
|
|
|
excludeFilters = @ComponentScan.Filter(classes = { Session.class }, type = FilterType.ASSIGNABLE_TYPE))
|
|
|
|
@EnableCassandraRepositories(basePackageClasses = CityCassandraRepository.class)
|
|
|
|
static class TestExcludeConfiguration {
|
|
|
|
@Import(TestConfiguration.class)
|
|
|
|
|
|
|
|
static class CustomizedConfiguration {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|