Class AxonServerContainer

java.lang.Object
org.testcontainers.containers.GenericContainer<AxonServerContainer>
org.axonframework.test.server.AxonServerContainer
All Implemented Interfaces:
AutoCloseable, org.testcontainers.containers.Container<AxonServerContainer>, org.testcontainers.containers.ContainerState, org.testcontainers.containers.traits.LinkableContainer, org.testcontainers.containers.wait.strategy.WaitStrategyTarget, org.testcontainers.lifecycle.Startable

public class AxonServerContainer extends org.testcontainers.containers.GenericContainer<AxonServerContainer>
Constructs an Axon Server container for testing.

By default, it starts in a single-node configuration.

Author:
Lucas Campos, Steven van Beelen, 4.8.0
  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.testcontainers.containers.Container

    org.testcontainers.containers.Container.ExecResult
  • Field Summary

    Fields inherited from class org.testcontainers.containers.GenericContainer

    CONTAINER_RUNNING_TIMEOUT_SEC, dependencies, dockerClient, INTERNAL_HOST_HOSTNAME, waitStrategy

    Fields inherited from interface org.testcontainers.containers.ContainerState

    STATE_HEALTHY
  • Constructor Summary

    Constructors
    Constructor
    Description
    Initialize an Axon Server test container using the default image name "docker.axoniq.io/axoniq/axonserver".
    AxonServerContainer(String dockerImageName)
    Initialize Axon Server with the given dockerImageName.
    AxonServerContainer(org.testcontainers.utility.DockerImageName dockerImageName)
    Initialize Axon Server with the given dockerImageName.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
     
    protected void
     
    boolean
     
    Returns the container address in a host:port format.
    Returns the mapped gRPC port used by this Axon Server container.
    Returns the mapped Http port used by this Axon Server container.
    int
     
    protected void
    optionallyCopyResourceToContainer(String pathNameInContainer, String resourceLocation)
    Map (effectively replace) a directory in Docker with the content of resourceLocation if the resource location is not null.
     
    withAxonServerHostname(String axonServerHostname)
    Initialize this Axon Server test container with the given axonServerHostname.
    withAxonServerInternalHostname(String axonServerInternalHostname)
    Initialize this Axon Server test container with the given axonServerInternalHostname.
    withAxonServerName(String axonServerName)
    Initialize this Axon Server test container with the given axonServerName.
    withClusterTemplate(String clusterTemplatePath)
    Initialize this Axon Server test container with a cluster template configuration file retrieved from the given clusterTemplatePath.
    withConfiguration(String configurationPath)
    Initialize this Axon Server test container with a configuration file retrieved from the given configurationPath.
    withDcbContext(boolean dcbContext)
    Initialize this Axon Server test container with DCB (Dynamic Consistency Boundary) context support.
    withDevMode(boolean devMode)
    Initialize this Axon Server test container with the given devMode.
    withLicense(String licensePath)
    Initialize this Axon Server test container with a license file retrieved from the given licensePath.
    protected void
    Set an environment value if the value is present.

    Methods inherited from class org.testcontainers.containers.GenericContainer

    addEnv, addExposedPort, addExposedPorts, addFileSystemBind, addFixedExposedPort, addFixedExposedPort, addLink, canBeReused, containerIsCreated, containerIsStarted, containerIsStarted, containerIsStarting, containerIsStarting, containerIsStopped, containerIsStopping, copyFileFromContainer, createVolumeDirectory, dependsOn, dependsOn, dependsOn, getBinds, getCommandParts, getContainerId, getContainerInfo, getContainerName, getCopyToFileContainerPathMap, getCreateContainerCmdModifiers, getDependencies, getDockerClient, getDockerImageName, getEnv, getEnvMap, getExposedPorts, getExtraHosts, getImage, getIpAddress, getLabels, getLinkedContainers, getLivenessCheckPort, getLivenessCheckPortNumbers, getLivenessCheckPorts, getLogConsumers, getNetwork, getNetworkAliases, getNetworkMode, getPortBindings, getShmSize, getStartupAttempts, getStartupCheckStrategy, getTestHostIpAddress, getTmpFsMapping, getVolumesFroms, getWaitStrategy, getWorkingDirectory, isHostAccessible, isPrivilegedMode, isShouldBeReused, logger, setBinds, setCommand, setCommand, setCommandParts, setContainerDef, setCopyToFileContainerPathMap, setDockerImageName, setEnv, setExposedPorts, setExtraHosts, setHostAccessible, setImage, setLabels, setLinkedContainers, setLogConsumers, setNetwork, setNetworkAliases, setNetworkMode, setPortBindings, setPrivilegedMode, setShmSize, setStartupAttempts, setStartupCheckStrategy, setTmpFsMapping, setVolumesFroms, setWaitStrategy, setWorkingDirectory, start, stop, waitingFor, waitUntilContainerStarted, withAccessToHost, withClasspathResourceMapping, withClasspathResourceMapping, withCommand, withCommand, withCopyFileToContainer, withCopyToContainer, withCreateContainerCmdModifier, withEnv, withEnv, withExposedPorts, withExtraHost, withFileSystemBind, withImagePullPolicy, withLabel, withLabels, withLogConsumer, withMinimumRunningDuration, withNetwork, withNetworkAliases, withNetworkMode, withPrivilegedMode, withReuse, withSharedMemorySize, withStartupAttempts, withStartupCheckStrategy, withStartupTimeout, withTmpFs, withVolumesFrom, withWorkingDirectory

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.testcontainers.containers.Container

    addFileSystemBind, followOutput, followOutput, self, withEnv, withFileSystemBind

    Methods inherited from interface org.testcontainers.containers.ContainerState

    copyFileFromContainer, copyFileToContainer, copyFileToContainer, execInContainer, execInContainer, execInContainer, execInContainer, execInContainerWithUser, execInContainerWithUser, getBoundPortNumbers, getContainerIpAddress, getCurrentContainerInfo, getFirstMappedPort, getHost, getLogs, getLogs, getMappedPort, isCreated, isHealthy, isRunning

    Methods inherited from interface org.testcontainers.lifecycle.Startable

    close
  • Constructor Details

    • AxonServerContainer

      public AxonServerContainer()
      Initialize an Axon Server test container using the default image name "docker.axoniq.io/axoniq/axonserver".
    • AxonServerContainer

      public AxonServerContainer(String dockerImageName)
      Initialize Axon Server with the given dockerImageName.
      Parameters:
      dockerImageName - The name of the Docker image to initialize this test container with.
    • AxonServerContainer

      public AxonServerContainer(org.testcontainers.utility.DockerImageName dockerImageName)
      Initialize Axon Server with the given dockerImageName.
      Parameters:
      dockerImageName - The DockerImageName to initialize this test container with.
  • Method Details

    • configure

      protected void configure()
      Overrides:
      configure in class org.testcontainers.containers.GenericContainer<AxonServerContainer>
    • doStart

      protected void doStart()
      Overrides:
      doStart in class org.testcontainers.containers.GenericContainer<AxonServerContainer>
    • optionallyCopyResourceToContainer

      protected void optionallyCopyResourceToContainer(String pathNameInContainer, String resourceLocation)
      Map (effectively replace) a directory in Docker with the content of resourceLocation if the resource location is not null.

      Protected to allow for changing implementation by extending the class.

      Parameters:
      pathNameInContainer - The path in docker.
      resourceLocation - The relative classpath to the resource.
    • withOptionalEnv

      protected void withOptionalEnv(String key, String value)
      Set an environment value if the value is present.

      Protected to allow for changing implementation by extending the class

      Parameters:
      key - Environment value key, usually a constant.
      value - Environment value to be set.
    • withLicense

      public AxonServerContainer withLicense(String licensePath)
      Initialize this Axon Server test container with a license file retrieved from the given licensePath.
      Parameters:
      licensePath - The path to the license file.
      Returns:
      This container itself for fluent API.
    • withConfiguration

      public AxonServerContainer withConfiguration(String configurationPath)
      Initialize this Axon Server test container with a configuration file retrieved from the given configurationPath.
      Parameters:
      configurationPath - The path to the configuration file.
      Returns:
      This container itself for fluent API.
    • withClusterTemplate

      public AxonServerContainer withClusterTemplate(String clusterTemplatePath)
      Initialize this Axon Server test container with a cluster template configuration file retrieved from the given clusterTemplatePath.
      Parameters:
      clusterTemplatePath - The path to the cluster template file.
      Returns:
      This container itself for fluent API.
    • withAxonServerName

      public AxonServerContainer withAxonServerName(String axonServerName)
      Initialize this Axon Server test container with the given axonServerName.
      Parameters:
      axonServerName - The name of the Axon Server instance.
      Returns:
      This container itself for fluent API.
    • withAxonServerInternalHostname

      public AxonServerContainer withAxonServerInternalHostname(String axonServerInternalHostname)
      Initialize this Axon Server test container with the given axonServerInternalHostname.
      Parameters:
      axonServerInternalHostname - The internal hostname of the Axon Server instance.
      Returns:
      This container itself for fluent API.
    • withAxonServerHostname

      public AxonServerContainer withAxonServerHostname(String axonServerHostname)
      Initialize this Axon Server test container with the given axonServerHostname.
      Parameters:
      axonServerHostname - The hostname of the Axon Server instance.
      Returns:
      This container itself for fluent API.
    • withDevMode

      public AxonServerContainer withDevMode(boolean devMode)
      Initialize this Axon Server test container with the given devMode.

      Development mode enables some features for development convenience. Default value is false.

      Parameters:
      devMode - A boolean dictating whether to enable development mode, yes or no.
      Returns:
      This container itself for fluent API.
    • withDcbContext

      public AxonServerContainer withDcbContext(boolean dcbContext)
      Initialize this Axon Server test container with DCB (Dynamic Consistency Boundary) context support.

      When enabled, the default context will be created with DCB support, allowing for more flexible consistency boundaries in event-sourced applications. DCB enables defining consistency boundaries dynamically based on event tags rather than being limited to aggregate-based boundaries.

      Default value is false.

      Parameters:
      dcbContext - A boolean dictating whether to enable DCB context support, yes or no.
      Returns:
      This container itself for fluent API.
    • getHttpPort

      public Integer getHttpPort()
      Returns the mapped Http port used by this Axon Server container.
      Returns:
      The mapped Http port used by this Axon Server container.
    • getGrpcPort

      public Integer getGrpcPort()
      Returns the mapped gRPC port used by this Axon Server container.
      Returns:
      The mapped gRPC port used by this Axon Server container.
    • getAxonServerAddress

      public String getAxonServerAddress()
      Returns the container address in a host:port format.
      Returns:
      The container address in a host:port format.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class org.testcontainers.containers.GenericContainer<AxonServerContainer>
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class org.testcontainers.containers.GenericContainer<AxonServerContainer>
    • toString

      public String toString()
      Overrides:
      toString in class org.testcontainers.containers.GenericContainer<AxonServerContainer>