diff --git a/README.md b/README.md index 812c9de..9ee6d67 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,134 @@ -# TestContainers Arcus +# Arcus TestContainer 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 + + org.jam2in + arcus-test-container + 1.0.0-SNAPSHOT + test + +``` + +## 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 set = arcusClient.set("test", 10, "testValue"); + + //then + assertThat(set.get()).isTrue(); + } +} +``` \ No newline at end of file