Package org.axonframework.test.server
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, waitStrategyFields inherited from interface org.testcontainers.containers.ContainerState
STATE_HEALTHY -
Constructor Summary
ConstructorsConstructorDescriptionInitialize an Axon Servertest containerusing the default image name"docker.axoniq.io/axoniq/axonserver".AxonServerContainer(String dockerImageName) Initialize Axon Server with the givendockerImageName.AxonServerContainer(org.testcontainers.utility.DockerImageName dockerImageName) Initialize Axon Server with the givendockerImageName. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidprotected voiddoStart()booleanReturns the container address in ahost:portformat.Returns the mapped gRPC port used by this Axon Server container.Returns the mapped Http port used by this Axon Server container.inthashCode()protected voidoptionallyCopyResourceToContainer(String pathNameInContainer, String resourceLocation) Map (effectively replace) a directory in Docker with the content ofresourceLocationif the resource location is notnull.toString()withAxonServerHostname(String axonServerHostname) Initialize this Axon Server test container with the givenaxonServerHostname.withAxonServerInternalHostname(String axonServerInternalHostname) Initialize this Axon Server test container with the givenaxonServerInternalHostname.withAxonServerName(String axonServerName) Initialize this Axon Server test container with the givenaxonServerName.withClusterTemplate(String clusterTemplatePath) Initialize this Axon Server test container with a cluster template configuration file retrieved from the givenclusterTemplatePath.withConfiguration(String configurationPath) Initialize this Axon Server test container with a configuration file retrieved from the givenconfigurationPath.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 givendevMode.withLicense(String licensePath) Initialize this Axon Server test container with a license file retrieved from the givenlicensePath.protected voidwithOptionalEnv(String key, String value) 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, withWorkingDirectoryMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.testcontainers.containers.Container
addFileSystemBind, followOutput, followOutput, self, withEnv, withFileSystemBindMethods 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, isRunningMethods inherited from interface org.testcontainers.lifecycle.Startable
close
-
Constructor Details
-
AxonServerContainer
public AxonServerContainer()Initialize an Axon Servertest containerusing the default image name"docker.axoniq.io/axoniq/axonserver". -
AxonServerContainer
Initialize Axon Server with the givendockerImageName.- 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 givendockerImageName.- Parameters:
dockerImageName- TheDockerImageNameto initialize this test container with.
-
-
Method Details
-
configure
protected void configure()- Overrides:
configurein classorg.testcontainers.containers.GenericContainer<AxonServerContainer>
-
doStart
protected void doStart()- Overrides:
doStartin classorg.testcontainers.containers.GenericContainer<AxonServerContainer>
-
optionallyCopyResourceToContainer
protected void optionallyCopyResourceToContainer(String pathNameInContainer, String resourceLocation) Map (effectively replace) a directory in Docker with the content ofresourceLocationif the resource location is notnull.Protected to allow for changing implementation by extending the class.
- Parameters:
pathNameInContainer- The path in docker.resourceLocation- The relative classpath to the resource.
-
withOptionalEnv
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
Initialize this Axon Server test container with a license file retrieved from the givenlicensePath.- Parameters:
licensePath- The path to the license file.- Returns:
- This container itself for fluent API.
-
withConfiguration
Initialize this Axon Server test container with a configuration file retrieved from the givenconfigurationPath.- Parameters:
configurationPath- The path to the configuration file.- Returns:
- This container itself for fluent API.
-
withClusterTemplate
Initialize this Axon Server test container with a cluster template configuration file retrieved from the givenclusterTemplatePath.- Parameters:
clusterTemplatePath- The path to the cluster template file.- Returns:
- This container itself for fluent API.
-
withAxonServerName
Initialize this Axon Server test container with the givenaxonServerName.- Parameters:
axonServerName- The name of the Axon Server instance.- Returns:
- This container itself for fluent API.
-
withAxonServerInternalHostname
Initialize this Axon Server test container with the givenaxonServerInternalHostname.- Parameters:
axonServerInternalHostname- The internal hostname of the Axon Server instance.- Returns:
- This container itself for fluent API.
-
withAxonServerHostname
Initialize this Axon Server test container with the givenaxonServerHostname.- Parameters:
axonServerHostname- The hostname of the Axon Server instance.- Returns:
- This container itself for fluent API.
-
withDevMode
Initialize this Axon Server test container with the givendevMode.Development mode enables some features for development convenience. Default value is
false.- Parameters:
devMode- Abooleandictating whether to enable development mode, yes or no.- Returns:
- This container itself for fluent API.
-
withDcbContext
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- Abooleandictating whether to enable DCB context support, yes or no.- Returns:
- This container itself for fluent API.
-
getHttpPort
Returns the mapped Http port used by this Axon Server container.- Returns:
- The mapped Http port used by this Axon Server container.
-
getGrpcPort
Returns the mapped gRPC port used by this Axon Server container.- Returns:
- The mapped gRPC port used by this Axon Server container.
-
getAxonServerAddress
Returns the container address in ahost:portformat.- Returns:
- The container address in a
host:portformat.
-
equals
- Overrides:
equalsin classorg.testcontainers.containers.GenericContainer<AxonServerContainer>
-
hashCode
public int hashCode()- Overrides:
hashCodein classorg.testcontainers.containers.GenericContainer<AxonServerContainer>
-
toString
- Overrides:
toStringin classorg.testcontainers.containers.GenericContainer<AxonServerContainer>
-