Polish "Add test slice for Spring Data Cassandra"

See gh-17490
This commit is contained in:
Stephane Nicoll
2020-08-05 10:53:20 +02:00
parent ae152b176b
commit 313b2bef6f
22 changed files with 174 additions and 162 deletions

View File

@@ -6947,6 +6947,34 @@ TIP: Sometimes writing Spring WebFlux tests is not enough; Spring Boot can help
[[boot-features-testing-spring-boot-applications-testing-autoconfigured-cassandra-test]]
==== 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` beans are not loaded into the `ApplicationContext`.
(For more about using Cassandra with Spring Boot, see "<<boot-features-cassandra>>", earlier in this chapter.)
TIP: A list of the auto-configuration settings that are enabled by `@DataCassandraTest` can be <<appendix-test-auto-configuration.adoc#test-auto-configuration,found in the appendix>>.
The following example shows a typical setup for using Cassandra tests in Spring Boot:
[source,java,indent=0]
----
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.data.cassandra.DataCassandraTest;
@DataCassandraTest
class ExampleDataCassandraTests {
@Autowired
private YourRepository repository;
//
}
----
[[boot-features-testing-spring-boot-applications-testing-autoconfigured-jpa-test]]
==== Auto-configured Data JPA Tests
You can use the `@DataJpaTest` annotation to test JPA applications.