Testcontainers Arcus is an extension of Testcontainers that supports Arcus (Standalone and Cluster) containers.
dependencies {
testImplementation "com.jam2in.arcus:arcus-test-container:0.0.1-SNAPSHOT"
}
<dependency>
<groupId>com.jam2in.arcus</groupId>
<artifactId>arcus-test-container</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>test</scope>
</dependency>
- single node
@Testcontainers
public class ArcusContainerTest {
@Container
private final ArcusContainer arcusContainer = ArcusContainer.create();
@Test
void testcase() {
//given
ArcusClient arcusClient = new ArcusClient(
new DefaultConnectionFactory(),
new ArrayList<>(Arrays.asList(new InetSocketAddress(
"127.0.0.1",
arcusContainer.getFirstMappedPort()))));
//when
Boolean b = arcusClient.set("test", 10, "singleTestValue").get();
//then
assertThat(b).isTrue();
}
}
- cluster
@Testcontainers
public class ArcusClusterContainerTest {
@Container
private final ArcusClusterContainer arcusCluster = ArcusClusterContainer.create();
@Test
void testcase() {
//given
ArcusClientPool arcusClient = ArcusClient.createArcusClientPool(
arcusCluster.getHostPorts(),
"test",
new ConnectionFactoryBuilder(),
2);
//when
Boolean b = arcusClient.set("test", 10, "singleTestValue").get();
//then
assertThat(b).isTrue();
}
}
- single node
public class ArcusContainerTestBase {
protected static final ArcusContainer ARCUS_CONTAINER;
static {
ARCUS_CONTAINER = ArcusContainer.create();
ARCUS_CONTAINER.start();
}
}
public class ArcusContainerTest extends ArcusContainerTestBase {
@Test
void testcase() {
//given
ArcusClient arcusClient = new ArcusClient(
new DefaultConnectionFactory(),
new ArrayList<>(Arrays.asList(new InetSocketAddress(
"127.0.0.1",
ARCUS_CONTAINER.getFirstMappedPort()))));
//when
Boolean b = arcusClient.set("test", 10, "singleTestValue").get();
//then
assertThat(b).isTrue();
}
}
- cluster
public class ArcusClusterTestBase {
protected static final ArcusClusterContainer ARCUS_CLUSTER_CONTAINER;
static {
ARCUS_CLUSTER_CONTAINER = ArcusClusterContainer.create();
ARCUS_CLUSTER_CONTAINER.start();
}
}
public class ArcusClusterContainerTest extends ArcusClusterTestBase {
@Test
void createArcusContainerSingle() {
//given
ArcusClientPool arcusClient = ArcusClient.createArcusClientPool(
ARCUS_CLUSTER_CONTAINER.getHostPorts(),
"test",
new ConnectionFactoryBuilder(),
2);
//when
OperationFuture<Boolean> set = arcusClient.set("test", 10, "testValue");
//then
assertThat(set.get()).isTrue();
}
}