Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jupiter-tools/spring-test-elasticsearch
Tools to start Elasticsearch in docker containers for tests with Spring
https://github.com/jupiter-tools/spring-test-elasticsearch
Last synced: 15 days ago
JSON representation
Tools to start Elasticsearch in docker containers for tests with Spring
- Host: GitHub
- URL: https://github.com/jupiter-tools/spring-test-elasticsearch
- Owner: jupiter-tools
- Created: 2019-11-25T13:42:00.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2020-06-12T01:15:05.000Z (over 4 years ago)
- Last Synced: 2024-11-05T19:18:17.892Z (2 months ago)
- Language: Java
- Homepage:
- Size: 21.5 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.adoc
Awesome Lists containing this project
README
# Spring Test Elasticsearch
image:https://codecov.io/gh/jupiter-tools/spring-test-elasticsearch/branch/master/graph/badge.svg["", link="https://codecov.io/gh/jupiter-tools/spring-test-elasticsearch"]
Tools to write integration tests of Spring Framework with the Elasticsearch.
## How to write integration tests on Spring Boot with Elasticsearch in docker
Add this library in dependencies:
[source,xml]
----com.jupiter-tools
spring-test-elasticsearch
0.1----
Now, you can start the Elasticsearch cluster in a docker container(TestContainers) by the using of `@ElasticsearchTestContainer` annotation in tests:
[source,java]
----
@ElasticsearchTestContainer
@SpringBootTest
class SpTestElasticTestAppApplicationTests {@Autowired
private ElasticsearchTemplate elasticsearchTemplate;@BeforeAll
static void setUp() {
// populate a data set in index
}@Test
void findTest() {
var query = GetQuery.getById("100123");
Foo foo = elasticsearchTemplate.queryForObject(query, Foo.class);
assertThat(foo).isNotNull();
}
}
----