Skip to content

Commit eba60de

Browse files
committed
adds container test
1 parent 8fd0066 commit eba60de

File tree

1 file changed

+42
-1
lines changed

1 file changed

+42
-1
lines changed
Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,45 @@
1+
/*
2+
* Copyright (c) 2017 Otávio Santana and others
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v1.0
5+
* and Apache License v2.0 which accompanies this distribution.
6+
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
7+
* and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php.
8+
*
9+
* You may elect to redistribute this code under either of these licenses.
10+
*
11+
* Contributors:
12+
*
13+
* Otavio Santana
14+
*/
115
package org.jnosql.diana.elasticsearch.document;
216

3-
public class DocumentConfigurationUtils {
17+
import org.jnosql.diana.api.Settings;
18+
import org.testcontainers.containers.GenericContainer;
19+
import org.testcontainers.containers.wait.strategy.Wait;
20+
21+
import java.util.HashMap;
22+
import java.util.Map;
23+
24+
final class DocumentConfigurationUtils {
25+
26+
private static GenericContainer es =
27+
new GenericContainer("docker.elastic.co/elasticsearch/elasticsearch:6.4.1")
28+
.withExposedPorts(9200, 9300)
29+
.withEnv("discovery.type", "single-node")
30+
.waitingFor(Wait.forHttp("/")
31+
.forPort(9200)
32+
.forStatusCode(200));
33+
34+
private DocumentConfigurationUtils() {
35+
}
36+
37+
public static ElasticsearchDocumentCollectionManagerFactory getConfiguration() {
38+
es.start();
39+
ElasticsearchDocumentConfiguration configuration = new ElasticsearchDocumentConfiguration();
40+
Map<String, Object> settings = new HashMap<>();
41+
settings.put("elasticsearch-host-1", es.getContainerIpAddress() + ':' + es.getFirstMappedPort());
42+
settings.put("elasticsearch-cluster-name", "elasticsearch");
43+
return configuration.get(Settings.of(settings));
44+
}
445
}

0 commit comments

Comments
 (0)