Add DataElasticsearchTest annotation

See gh-29911
This commit is contained in:
Eddú Meléndez
2022-02-20 01:18:43 -06:00
committed by Andy Wilkinson
parent 9f00c3acf5
commit e22f78bc6a
22 changed files with 829 additions and 0 deletions

View File

@@ -339,6 +339,7 @@ boot-features-testing-spring-boot-applications-testing-autoconfigured-json-tests
boot-features-testing-spring-boot-applications-testing-autoconfigured-mvc-tests=features.testing.spring-boot-applications.spring-mvc-tests
boot-features-testing-spring-boot-applications-testing-autoconfigured-webflux-tests=features.testing.spring-boot-applications.spring-webflux-tests
boot-features-testing-spring-boot-applications-testing-autoconfigured-cassandra-test=features.testing.spring-boot-applications.autoconfigured-spring-data-cassandra
boot-features-testing-spring-boot-applications-testing-autoconfigured-elasticsearch-test=features.testing.spring-boot-applications.autoconfigured-spring-data-elasticsearch
boot-features-testing-spring-boot-applications-testing-autoconfigured-jpa-test=features.testing.spring-boot-applications.autoconfigured-spring-data-jpa
boot-features-testing-spring-boot-applications-testing-autoconfigured-jdbc-test=features.testing.spring-boot-applications.autoconfigured-jdbc
boot-features-testing-spring-boot-applications-testing-autoconfigured-data-jdbc-test=features.testing.spring-boot-applications.autoconfigured-spring-data-jdbc

View File

@@ -472,6 +472,22 @@ include::code:MyDataCassandraTests[]
[[features.testing.spring-boot-applications.autoconfigured-spring-data-elasticsearch]]
==== Auto-configured Data Elasticsearch Tests
You can use `@DataElasticsearchTest` to test Elasticsearch applications.
By default, it configures a `ElasticsearchRestTemplate`, scans for `@Document` classes, and configures Spring Data Elasticsearch repositories.
Regular `@Component` and `@ConfigurationProperties` beans are not scanned when the `@DataElasticsearchTest` annotation is used.
`@EnableConfigurationProperties` can be used to include `@ConfigurationProperties` beans.
(For more about using Elasticsearch with Spring Boot, see "<<data#data.nosql.elasticsearch>>", earlier in this chapter.)
TIP: A list of the auto-configuration settings that are enabled by `@DataElasticsearchTest` can be <<test-auto-configuration#appendix.test-auto-configuration,found in the appendix>>.
The following example shows a typical setup for using Elasticsearch tests in Spring Boot:
include::code:MyDataElasticsearchTests[]
[[features.testing.spring-boot-applications.autoconfigured-spring-data-jpa]]
==== Auto-configured Data JPA Tests
You can use the `@DataJpaTest` annotation to test JPA applications.