Skip to content

jam2in/arcus-test-container

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Arcus TestContainer

CI License

Testcontainers Arcus is an extension of Testcontainers that supports Arcus (Standalone and Cluster) containers.


Getting Started


Gradle

dependencies {
    testImplementation "com.jam2in.arcus:arcus-test-container:0.0.1-SNAPSHOT"
}

Maven

<dependency>
    <groupId>com.jam2in.arcus</groupId>
    <artifactId>arcus-test-container</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <scope>test</scope>
</dependency>

Usage

container that are restarted for every test method

  1. 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();
  }
}
  1. 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();
  }
}

container that are shared between all methods of a test class

  1. 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();
  }
}
  1. 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();
  }
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages