Skip to content

Commit 1a8e36e

Browse files
committed
creates a container supplier
1 parent 29dac71 commit 1a8e36e

File tree

2 files changed

+47
-6
lines changed

2 files changed

+47
-6
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* Copyright (c) 2019 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+
*/
15+
package org.jnosql.diana.riak.key;
16+
17+
import org.jnosql.diana.api.Settings;
18+
import org.jnosql.diana.api.key.BucketManagerFactory;
19+
import org.testcontainers.containers.GenericContainer;
20+
import org.testcontainers.containers.wait.strategy.Wait;
21+
22+
import java.util.function.Supplier;
23+
24+
public enum BucketManagerFactorySupplier implements Supplier<BucketManagerFactory> {
25+
26+
INSTANCE;
27+
28+
private final GenericContainer riak =
29+
new GenericContainer("basho/riak-ts:latest")
30+
.withExposedPorts(8087)
31+
.waitingFor(Wait.forListeningPort());
32+
33+
{
34+
riak.start();
35+
}
36+
37+
@Override
38+
public BucketManagerFactory get() {
39+
Settings settings = Settings.builder()
40+
.put("riak.host", riak.getContainerIpAddress() + ':' + riak.getFirstMappedPort())
41+
.build();
42+
RiakKeyValueConfiguration configuration = new RiakKeyValueConfiguration();
43+
return configuration.get(settings);
44+
}
45+
46+
}

riak-driver/src/test/java/org/jnosql/diana/riak/key/RiakTestUtils.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,12 @@
1515
package org.jnosql.diana.riak.key;
1616

1717

18-
import com.basho.riak.client.core.RiakNode;
1918
import org.jnosql.diana.api.key.BucketManagerFactory;
2019

2120
public final class RiakTestUtils {
2221

2322

2423
public static BucketManagerFactory get() {
25-
RiakKeyValueConfiguration riakKeyValueConfiguration = new RiakKeyValueConfiguration();
26-
RiakNode node = new RiakNode.Builder()
27-
.withRemoteAddress("localhost").build();
28-
riakKeyValueConfiguration.add(node);
29-
return riakKeyValueConfiguration.get();
24+
return BucketManagerFactorySupplier.INSTANCE.get();
3025
}
3126
}

0 commit comments

Comments
 (0)