Class HiveMQContainer
- All Implemented Interfaces:
AutoCloseable,org.testcontainers.containers.Container<HiveMQContainer>,org.testcontainers.containers.ContainerState,org.testcontainers.containers.traits.LinkableContainer,org.testcontainers.containers.wait.strategy.WaitStrategyTarget,org.testcontainers.lifecycle.Startable
Supported images: hivemq/hivemq4, hivemq/hivemq-ce
Exposed ports:
- MQTT: 1883
- Control Center: 8080
- Debug: 9000
-
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_HOSTNAMEFields inherited from interface org.testcontainers.containers.ContainerState
STATE_HEALTHY -
Constructor Summary
ConstructorsConstructorDescriptionHiveMQContainer(@NotNull org.testcontainers.utility.DockerImageName dockerImageName) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidprotected voidcontainerIsStarted(@NotNull com.github.dockerjava.api.command.InspectContainerResponse containerInfo) voiddisableExtension(@NotNull String extensionName, @NotNull String extensionDirectory) Disables the extension with the given name and extension directory name.voiddisableExtension(@NotNull String extensionName, @NotNull String extensionDirectory, @NotNull Duration timeout) Disables the extension with the given name and extension directory name.voiddisableExtension(@NotNull HiveMQExtension hiveMQExtension) Disables the extension.voiddisableExtension(@NotNull HiveMQExtension hiveMQExtension, @NotNull Duration timeout) Disables the extension.voidenableExtension(@NotNull String extensionName, @NotNull String extensionDirectory) Enables the extension with the given name and extension directory name.voidenableExtension(@NotNull String extensionName, @NotNull String extensionDirectory, @NotNull Duration timeout) Enables the extension with the given name and extension directory name.voidenableExtension(@NotNull HiveMQExtension hiveMQExtension) Enables the extension.voidenableExtension(@NotNull HiveMQExtension hiveMQExtension, @NotNull Duration timeout) Enables the extension.intGet the mapped port for the MQTT port of the container.@NotNull HiveMQContainerwaitForExtension(@NotNull String extensionName) Adds a wait condition for the extension with this name.@NotNull HiveMQContainerwaitForExtension(@NotNull HiveMQExtension extension) Adds a wait condition for thisHiveMQExtension@NotNull HiveMQContainerEnables connection to the HiveMQ Control Center on host port 8080.@NotNull HiveMQContainerEnables the possibility for remote debugging clients to connect.@NotNull HiveMQContainerwithExtension(@NotNull HiveMQExtension hiveMQExtension) Wraps the given class and all its subclasses into an extension and puts it into '/opt/hivemq/temp-extensions/{extension-id}' inside the container.@NotNull HiveMQContainerwithExtension(@NotNull org.testcontainers.utility.MountableFile mountableExtension) Puts the given extension folder into '/opt/hivemq/temp-extensions/{directory-name}' inside the container.@NotNull HiveMQContainerwithFileInExtensionHomeFolder(@NotNull org.testcontainers.utility.MountableFile file, @NotNull String extensionId) Puts the given file into the root of the extension's home '/opt/hivemq/temp-extensions/{extensionId}/'.@NotNull HiveMQContainerwithFileInExtensionHomeFolder(@NotNull org.testcontainers.utility.MountableFile file, @NotNull String extensionId, @NotNull String pathInExtensionHome) Puts the given file into given subdirectory of the extensions's home '/opt/hivemq/temp-extensions/{id}/{pathInExtensionHome}/'@NotNull HiveMQContainerwithFileInHomeFolder(@NotNull org.testcontainers.utility.MountableFile mountableFile, @NotNull String pathInHomeFolder) Puts the given file into the given subdirectory of the HiveMQ home folder '/opt/hivemq/{pathInHomeFolder}'.@NotNull HiveMQContainerwithHiveMQConfig(@NotNull org.testcontainers.utility.MountableFile mountableConfig) Overwrites the HiveMQ configuration in '/opt/hivemq/conf/' inside the container.@NotNull HiveMQContainerwithLicense(@NotNull org.testcontainers.utility.MountableFile mountableLicense) Puts the given license into '/opt/hivemq/license/' inside the container.@NotNull HiveMQContainerwithLogLevel(@NotNull org.slf4j.event.Level level) Sets the loggingLevelinside the container.@NotNull HiveMQContainerRemoves all prepackaged extension folders from '/opt/hivemq/extensions' before the container is started.@NotNull HiveMQContainerwithoutPrepackagedExtensions(@NotNull String... extensionIds) Removes the specified prepackaged extension folders from '/opt/hivemq/extensions' before the container is started.Methods inherited from class org.testcontainers.containers.GenericContainer
addEnv, addExposedPort, addExposedPorts, addFileSystemBind, addFixedExposedPort, addFixedExposedPort, addLink, canBeReused, containerIsCreated, containerIsStarted, containerIsStarting, containerIsStarting, containerIsStopped, containerIsStopping, copyFileFromContainer, createVolumeDirectory, dependsOn, dependsOn, dependsOn, doStart, equals, 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, hashCode, 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, toString, 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
-
HiveMQContainer
public HiveMQContainer(@NotNull @NotNull org.testcontainers.utility.DockerImageName dockerImageName)
-
-
Method Details
-
configure
protected void configure()- Overrides:
configurein classorg.testcontainers.containers.GenericContainer<HiveMQContainer>
-
containerIsStarted
protected void containerIsStarted(@NotNull @NotNull com.github.dockerjava.api.command.InspectContainerResponse containerInfo) - Overrides:
containerIsStartedin classorg.testcontainers.containers.GenericContainer<HiveMQContainer>
-
waitForExtension
Adds a wait condition for the extension with this name.Must be called before the container is started.
- Parameters:
extensionName- the extension to wait for- Returns:
- self
-
waitForExtension
@NotNull public @NotNull HiveMQContainer waitForExtension(@NotNull @NotNull HiveMQExtension extension) Adds a wait condition for thisHiveMQExtensionMust be called before the container is started.
- Parameters:
extension- the extension to wait for- Returns:
- self
-
withDebugging
Enables the possibility for remote debugging clients to connect.Must be called before the container is started.
- Returns:
- self
-
withLogLevel
@NotNull public @NotNull HiveMQContainer withLogLevel(@NotNull @NotNull org.slf4j.event.Level level) Sets the loggingLevelinside the container.Must be called before the container is started.
- Parameters:
level- theLevel- Returns:
- self
-
withExtension
@NotNull public @NotNull HiveMQContainer withExtension(@NotNull @NotNull HiveMQExtension hiveMQExtension) Wraps the given class and all its subclasses into an extension and puts it into '/opt/hivemq/temp-extensions/{extension-id}' inside the container.Must be called before the container is started.
The contents of the '/opt/hivemq/temp-extensions/' directory are copied to '/opt/hivemq/extensions/' before the container is started.
- Parameters:
hiveMQExtension- theHiveMQExtensionof the extension- Returns:
- self
-
withExtension
@NotNull public @NotNull HiveMQContainer withExtension(@NotNull @NotNull org.testcontainers.utility.MountableFile mountableExtension) Puts the given extension folder into '/opt/hivemq/temp-extensions/{directory-name}' inside the container. It must at least contain a valid hivemq-extension.xml and a valid extension.jar in order to be executed. The directory-name is taken from the id defined in the hivemq-extension.xml.Must be called before the container is started.
The contents of the '/opt/hivemq/temp-extensions/' directory are copied to '/opt/hivemq/extensions/' before the container is started.
- Parameters:
mountableExtension- the extension folder on the host machine- Returns:
- self
-
withoutPrepackagedExtensions
@NotNull public @NotNull HiveMQContainer withoutPrepackagedExtensions(@NotNull @NotNull String... extensionIds) Removes the specified prepackaged extension folders from '/opt/hivemq/extensions' before the container is started.Must be called before the container is started.
- Parameters:
extensionIds- the prepackaged extensions to remove- Returns:
- self
-
withoutPrepackagedExtensions
Removes all prepackaged extension folders from '/opt/hivemq/extensions' before the container is started.Must be called before the container is started.
- Returns:
- self
-
withLicense
@NotNull public @NotNull HiveMQContainer withLicense(@NotNull @NotNull org.testcontainers.utility.MountableFile mountableLicense) Puts the given license into '/opt/hivemq/license/' inside the container. It must end with '.lic' or '.elic'.Must be called before the container is started.
- Parameters:
mountableLicense- the license file on the host machine- Returns:
- self
-
withHiveMQConfig
@NotNull public @NotNull HiveMQContainer withHiveMQConfig(@NotNull @NotNull org.testcontainers.utility.MountableFile mountableConfig) Overwrites the HiveMQ configuration in '/opt/hivemq/conf/' inside the container.Must be called before the container is started.
- Parameters:
mountableConfig- the config file on the host machine- Returns:
- self
-
withFileInExtensionHomeFolder
@NotNull public @NotNull HiveMQContainer withFileInExtensionHomeFolder(@NotNull @NotNull org.testcontainers.utility.MountableFile file, @NotNull @NotNull String extensionId) Puts the given file into the root of the extension's home '/opt/hivemq/temp-extensions/{extensionId}/'.Must be called before the container is started.
The contents of the '/opt/hivemq/temp-extensions/' directory are copied to '/opt/hivemq/extensions/' before the container is started.
- Parameters:
file- the file on the host machineextensionId- the extension- Returns:
- self
-
withFileInExtensionHomeFolder
@NotNull public @NotNull HiveMQContainer withFileInExtensionHomeFolder(@NotNull @NotNull org.testcontainers.utility.MountableFile file, @NotNull @NotNull String extensionId, @NotNull @NotNull String pathInExtensionHome) Puts the given file into given subdirectory of the extensions's home '/opt/hivemq/temp-extensions/{id}/{pathInExtensionHome}/'Must be called before the container is started.
The contents of the '/opt/hivemq/temp-extensions/' directory are copied to '/opt/hivemq/extensions/' before the container is started.
- Parameters:
file- the file on the host machineextensionId- the extensionpathInExtensionHome- the path- Returns:
- self
-
withFileInHomeFolder
@NotNull public @NotNull HiveMQContainer withFileInHomeFolder(@NotNull @NotNull org.testcontainers.utility.MountableFile mountableFile, @NotNull @NotNull String pathInHomeFolder) Puts the given file into the given subdirectory of the HiveMQ home folder '/opt/hivemq/{pathInHomeFolder}'.Must be called before the container is started.
- Parameters:
mountableFile- the file on the host machinepathInHomeFolder- the path- Returns:
- self
-
disableExtension
public void disableExtension(@NotNull @NotNull String extensionName, @NotNull @NotNull String extensionDirectory, @NotNull @NotNull Duration timeout) throws TimeoutException Disables the extension with the given name and extension directory name. This method blocks until the HiveMQ log for successful disabling is consumed or it times out after {timeOut}. Note: Disabling Extensions is a HiveMQ Enterprise feature, it will not work when using the HiveMQ Community Edition.This can only be called once the container is started.
- Parameters:
extensionName- the name of the extension to disableextensionDirectory- the name of the extension's directorytimeout- the timeout- Throws:
TimeoutException- if the extension was not disabled within the configured timeout
-
disableExtension
public void disableExtension(@NotNull @NotNull String extensionName, @NotNull @NotNull String extensionDirectory) throws TimeoutException Disables the extension with the given name and extension directory name. This method blocks until the HiveMQ log for successful disabling is consumed or it times out after 60 seconds. Note: Disabling Extensions is a HiveMQ Enterprise feature, it will not work when using the HiveMQ Community Edition.This can only be called once the container is started.
- Parameters:
extensionName- the name of the extension to disableextensionDirectory- the name of the extension's directory- Throws:
TimeoutException- if the extension was not disabled within 60 seconds
-
disableExtension
public void disableExtension(@NotNull @NotNull HiveMQExtension hiveMQExtension, @NotNull @NotNull Duration timeout) throws TimeoutException Disables the extension. This method blocks until the HiveMQ log for successful disabling is consumed or it times out after {timeOut}. Note: Disabling Extensions is a HiveMQ Enterprise feature, it will not work when using the HiveMQ Community Edition.This can only be called once the container is started.
- Parameters:
hiveMQExtension- the extensiontimeout- the timeout- Throws:
TimeoutException- if the extension was not disabled within the configured timeout
-
disableExtension
public void disableExtension(@NotNull @NotNull HiveMQExtension hiveMQExtension) throws TimeoutException Disables the extension. This method blocks until the HiveMQ log for successful disabling is consumed or it times out after 60 seconds. Note: Disabling Extensions is a HiveMQ Enterprise feature, it will not work when using the HiveMQ Community Edition.This can only be called once the container is started.
- Parameters:
hiveMQExtension- the extension- Throws:
TimeoutException- if the extension was not disabled within 60 seconds
-
enableExtension
public void enableExtension(@NotNull @NotNull String extensionName, @NotNull @NotNull String extensionDirectory, @NotNull @NotNull Duration timeout) throws TimeoutException Enables the extension with the given name and extension directory name. This method blocks until the HiveMQ log for successful enabling is consumed or it times out after {timeOut}. Note: Enabling Extensions is a HiveMQ Enterprise feature, it will not work when using the HiveMQ Community Edition.This can only be called once the container is started.
- Parameters:
extensionName- the name of the extension to disableextensionDirectory- the name of the extension's directorytimeout- the timeout- Throws:
TimeoutException- if the extension was not enabled within the configured timeout
-
enableExtension
public void enableExtension(@NotNull @NotNull String extensionName, @NotNull @NotNull String extensionDirectory) throws TimeoutException Enables the extension with the given name and extension directory name. This method blocks until the HiveMQ log for successful enabling is consumed or it times out after 60 seconds. Note: Enabling Extensions is a HiveMQ Enterprise feature, it will not work when using the HiveMQ Community Edition.This can only be called once the container is started.
- Parameters:
extensionName- the name of the extension to disableextensionDirectory- the name of the extension's directory- Throws:
TimeoutException- if the extension was not enabled within 60 seconds
-
enableExtension
public void enableExtension(@NotNull @NotNull HiveMQExtension hiveMQExtension, @NotNull @NotNull Duration timeout) throws TimeoutException Enables the extension. This method blocks until the HiveMQ log for successful enabling is consumed or it times out after {timeOut}. Note: Enabling Extensions is a HiveMQ Enterprise feature, it will not work when using the HiveMQ Community Edition.This can only be called once the container is started.
- Parameters:
hiveMQExtension- the extensiontimeout- the timeout- Throws:
TimeoutException- if the extension was not enabled within the configured timeout
-
enableExtension
public void enableExtension(@NotNull @NotNull HiveMQExtension hiveMQExtension) throws TimeoutException Enables the extension. This method blocks until the HiveMQ log for successful enabling is consumed or it times out after {timeOut}. Note: Enabling Extensions is a HiveMQ Enterprise feature, it will not work when using the HiveMQ Community Edition.This can only be called once the container is started.
- Parameters:
hiveMQExtension- the extension- Throws:
TimeoutException- if the extension was not enabled within 60 seconds
-
withControlCenter
Enables connection to the HiveMQ Control Center on host port 8080. Note: the control center is a HiveMQ 4 Enterprise feature.Must be called before the container is started.
- Returns:
- self
-
getMqttPort
public int getMqttPort()Get the mapped port for the MQTT port of the container.Must be called after the container is started.
- Returns:
- the port on the host machine for mqtt clients to connect
-