|
|
|
@ -26,6 +26,7 @@ import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfigurati
|
|
|
|
|
import org.springframework.boot.autoconfigure.cassandra.CassandraAutoConfiguration;
|
|
|
|
|
import org.springframework.boot.autoconfigure.data.cassandra.city.City;
|
|
|
|
|
import org.springframework.boot.autoconfigure.domain.EntityScan;
|
|
|
|
|
import org.springframework.boot.test.util.EnvironmentTestUtils;
|
|
|
|
|
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
|
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
|
|
import org.springframework.context.annotation.ComponentScan;
|
|
|
|
@ -33,6 +34,7 @@ import org.springframework.context.annotation.Configuration;
|
|
|
|
|
import org.springframework.context.annotation.FilterType;
|
|
|
|
|
import org.springframework.data.cassandra.core.CassandraTemplate;
|
|
|
|
|
import org.springframework.data.cassandra.mapping.CassandraMappingContext;
|
|
|
|
|
import org.springframework.data.cassandra.mapping.SimpleUserTypeResolver;
|
|
|
|
|
import org.springframework.test.util.ReflectionTestUtils;
|
|
|
|
|
|
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat;
|
|
|
|
@ -42,6 +44,7 @@ import static org.mockito.Mockito.mock;
|
|
|
|
|
* Tests for {@link CassandraDataAutoConfiguration}
|
|
|
|
|
*
|
|
|
|
|
* @author Eddú Meléndez
|
|
|
|
|
* @author Mark Paluch
|
|
|
|
|
*/
|
|
|
|
|
public class CassandraDataAutoConfigurationTests {
|
|
|
|
|
|
|
|
|
@ -57,6 +60,8 @@ public class CassandraDataAutoConfigurationTests {
|
|
|
|
|
@Test
|
|
|
|
|
public void templateExists() {
|
|
|
|
|
this.context = new AnnotationConfigApplicationContext();
|
|
|
|
|
EnvironmentTestUtils.addEnvironment(this.context,
|
|
|
|
|
"spring.data.cassandra.keyspaceName:boot_test");
|
|
|
|
|
this.context.register(TestExcludeConfiguration.class, TestConfiguration.class,
|
|
|
|
|
PropertyPlaceholderAutoConfiguration.class,
|
|
|
|
|
CassandraAutoConfiguration.class, CassandraDataAutoConfiguration.class);
|
|
|
|
@ -69,6 +74,8 @@ public class CassandraDataAutoConfigurationTests {
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
|
public void entityScanShouldSetInitialEntitySet() throws Exception {
|
|
|
|
|
this.context = new AnnotationConfigApplicationContext();
|
|
|
|
|
EnvironmentTestUtils.addEnvironment(this.context,
|
|
|
|
|
"spring.data.cassandra.keyspaceName:boot_test");
|
|
|
|
|
this.context.register(TestConfiguration.class, EntityScanConfig.class,
|
|
|
|
|
PropertyPlaceholderAutoConfiguration.class,
|
|
|
|
|
CassandraAutoConfiguration.class, CassandraDataAutoConfiguration.class);
|
|
|
|
@ -80,6 +87,21 @@ public class CassandraDataAutoConfigurationTests {
|
|
|
|
|
assertThat(initialEntitySet).containsOnly(City.class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void userTypeResolverShouldBeSet() throws Exception {
|
|
|
|
|
this.context = new AnnotationConfigApplicationContext();
|
|
|
|
|
EnvironmentTestUtils.addEnvironment(this.context,
|
|
|
|
|
"spring.data.cassandra.keyspaceName:boot_test");
|
|
|
|
|
this.context.register(TestConfiguration.class,
|
|
|
|
|
PropertyPlaceholderAutoConfiguration.class,
|
|
|
|
|
CassandraAutoConfiguration.class, CassandraDataAutoConfiguration.class);
|
|
|
|
|
this.context.refresh();
|
|
|
|
|
CassandraMappingContext mappingContext = this.context
|
|
|
|
|
.getBean(CassandraMappingContext.class);
|
|
|
|
|
assertThat(ReflectionTestUtils.getField(mappingContext, "userTypeResolver"))
|
|
|
|
|
.isInstanceOf(SimpleUserTypeResolver.class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Configuration
|
|
|
|
|
@ComponentScan(excludeFilters = @ComponentScan.Filter(classes = {
|
|
|
|
|
Session.class }, type = FilterType.ASSIGNABLE_TYPE))
|
|
|
|
|