Auto-configured Data Cassandra Tests
You can use @DataCassandraTest to test Cassandra applications.
By default, it configures a CassandraTemplate, scans for @Table classes, and configures Spring Data Cassandra repositories.
Regular @Component and @ConfigurationProperties beans are not scanned when the @DataCassandraTest annotation is used.
@EnableConfigurationProperties can be used to include @ConfigurationProperties beans.
(For more about using Cassandra with Spring Boot, see "Cassandra".)
A list of the auto-configuration settings that are enabled by @DataCassandraTest can be found in the appendix.
|
The following example shows a typical setup for using Cassandra tests in Spring Boot:
-
Java
-
Kotlin
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.data.cassandra.DataCassandraTest;
@DataCassandraTest
class MyDataCassandraTests {
@Autowired
private SomeRepository repository;
}
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.autoconfigure.data.cassandra.DataCassandraTest
@DataCassandraTest
class MyDataCassandraTests(@Autowired val repository: SomeRepository)