-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
133 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,135 @@ | ||
# TestContainers Arcus | ||
# Arcus TestContainer | ||
|
||
![CI](https://github.com/jam2in/arcus-test-container/actions/workflows/ci.yml/badge.svg) | ||
![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg) | ||
|
||
Testcontainers Arcus is an extension of Testcontainers that supports Arcus (Standalone and Cluster) containers. | ||
___ | ||
## Getting Started | ||
___ | ||
### Gradle | ||
```groovy | ||
dependencies { | ||
testImplementation "org.jam2in:arcus-test-container:1.0.0-SNAPSHOT" | ||
} | ||
``` | ||
|
||
### Maven | ||
```xml | ||
<dependency> | ||
<groupId>org.jam2in</groupId> | ||
<artifactId>arcus-test-container</artifactId> | ||
<version>1.0.0-SNAPSHOT</version> | ||
<scope>test</scope> | ||
</dependency> | ||
``` | ||
|
||
## Usage | ||
### container that are restarted for every test method | ||
1. single node | ||
```java | ||
@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", 11211)))); | ||
|
||
//when | ||
Boolean b = arcusClient.set("test", 10, "singleTestValue").get(); | ||
|
||
//then | ||
assertThat(b).isTrue(); | ||
} | ||
} | ||
``` | ||
2. cluster | ||
|
||
```java | ||
@Testcontainers | ||
public class ArcusClusterContainerTest { | ||
|
||
@Container | ||
private final ArcusClusterContainer arcusCluster = ArcusClusterContainer.create(); | ||
|
||
@Test | ||
void testcase() { | ||
//given | ||
ArcusClientPool arcusClient = ArcusClient.createArcusClientPool("test", new ConnectionFactoryBuilder(), 2); | ||
|
||
//when | ||
Boolean b = arcusClient.set("test", 10, "singleTestValue").get(); | ||
|
||
//then | ||
assertThat(b).isTrue(); | ||
} | ||
} | ||
``` | ||
### container that are shared between all methods of a test class | ||
1. single node | ||
|
||
```java | ||
public class ArcusContainerTestBase { | ||
|
||
protected static final ArcusContainer ARCUS_CONTAINER; | ||
|
||
static { | ||
ARCUS_CONTAINER = ArcusContainer.create(); | ||
ARCUS_CONTAINER.start(); | ||
} | ||
} | ||
``` | ||
```java | ||
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", 11211)))); | ||
|
||
//when | ||
Boolean b = arcusClient.set("test", 10, "singleTestValue").get(); | ||
|
||
//then | ||
assertThat(b).isTrue(); | ||
} | ||
} | ||
``` | ||
|
||
2. cluster | ||
|
||
```java | ||
public class ArcusClusterTestBase { | ||
|
||
protected static final ArcusClusterContainer ARCUS_CLUSTER_CONTAINER; | ||
|
||
static { | ||
ARCUS_CLUSTER_CONTAINER = ArcusClusterContainer.create(); | ||
ARCUS_CLUSTER_CONTAINER.start(); | ||
} | ||
} | ||
``` | ||
```java | ||
public class ArcusClusterContainerTest extends ArcusClusterTestBase { | ||
|
||
@Test | ||
void createArcusContainerSingle() { | ||
//given | ||
ArcusClientPool arcusClient = ArcusClient.createArcusClientPool("test", new ConnectionFactoryBuilder(), 2); | ||
|
||
//when | ||
OperationFuture<Boolean> set = arcusClient.set("test", 10, "testValue"); | ||
|
||
//then | ||
assertThat(set.get()).isTrue(); | ||
} | ||
} | ||
``` |