Class HiveMQTestContainerCore<SELF extends HiveMQTestContainerCore<SELF>>
- java.lang.Object
-
- org.testcontainers.containers.FailureDetectingExternalResource
-
- org.testcontainers.containers.GenericContainer<SELF>
-
- com.hivemq.testcontainer.core.HiveMQTestContainerCore<SELF>
-
- All Implemented Interfaces:
AutoCloseable,org.junit.rules.TestRule,Container<SELF>,ContainerState,LinkableContainer,WaitStrategyTarget,Startable
public class HiveMQTestContainerCore<SELF extends HiveMQTestContainerCore<SELF>> extends GenericContainer<SELF>
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.testcontainers.containers.Container
Container.ExecResult
-
-
Field Summary
Fields Modifier and Type Field Description static intCONTROL_CENTER_PORTstatic intDEBUGGING_PORTstatic intMQTT_PORT-
Fields inherited from class org.testcontainers.containers.GenericContainer
CONTAINER_RUNNING_TIMEOUT_SEC, dependencies, dockerClient, INTERNAL_HOST_HOSTNAME
-
Fields inherited from interface org.testcontainers.containers.ContainerState
STATE_HEALTHY
-
-
Constructor Summary
Constructors Constructor Description HiveMQTestContainerCore()HiveMQTestContainerCore(@NotNull DockerImageName dockerImageName)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddisableExtension(@NotNull HiveMQExtension hiveMQExtension)Disables the extension.voiddisableExtension(@NotNull HiveMQExtension hiveMQExtension, @NotNull Duration timeout)Disables the extension.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.voidenableExtension(@NotNull HiveMQExtension hiveMQExtension)Enables the extension.voidenableExtension(@NotNull HiveMQExtension hiveMQExtension, @NotNull Duration timeout)Enables 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.intgetMqttPort()Get the mapped port for the MQTT port of the container.SELFsilent(boolean silent)Determines whether the stdout of the container is printed to System.out.voidstart()voidstop()SELFwaitForExtension(@NotNull HiveMQExtension extension)Adds a wait condition for thisHiveMQExtensionSELFwaitForExtension(@NotNull String extensionName)Adds a wait condition for the extension with this name.SELFwithControlCenter()Enables connection to the HiveMQ Control Center on host port 8080.SELFwithDebugging()Enables the possibility for remote debugging clients to connect.SELFwithExtension(@NotNull HiveMQExtension hiveMQExtension)Wraps the given class and all its subclasses into an extension and puts it into '/opt/hivemq/extensions/{extension-id}' inside the container.SELFwithExtension(@NotNull MountableFile mountableExtension)Puts the given extension folder into '/opt/hivemq/extensions/{directory-name}' inside the container.SELFwithFileInExtensionHomeFolder(@NotNull MountableFile file, @NotNull String extensionId)Puts the given file into the root of the extension's home '/opt/hivemq/extensions/{extensionId}/'.SELFwithFileInExtensionHomeFolder(@NotNull MountableFile file, @NotNull String extensionId, @NotNull String pathInExtensionHome)Puts the given file into given subdirectory of the extensions's home '/opt/hivemq/extensions/{id}/{pathInExtensionHome}/' Note: the extension must be loaded before the file is put.SELFwithFileInHomeFolder(@NotNull MountableFile file)Puts the given file into the root of the HiveMQ home folder '/opt/hivemq/'.SELFwithFileInHomeFolder(@NotNull MountableFile mountableFile, @NotNull String pathInHomeFolder)Puts the given file into the given subdirectory of the HiveMQ home folder '/opt/hivemq/{pathInHomeFolder}'.SELFwithHiveMQConfig(@NotNull MountableFile mountableConfig)Overwrites the HiveMQ configuration in '/opt/hivemq/conf/' inside the container.SELFwithLicense(@NotNull MountableFile mountableLicense)Puts the given license into '/opt/hivemq/license/' inside the container.SELFwithLogLevel(@NotNull org.slf4j.event.Level level)Sets the loggingLevelinside the container.SELFwithoutPrepackagedExtensions()Removes all prepackaged extension folders from '/opt/hivemq/extensions' before the container is built.SELFwithoutPrepackagedExtensions(@NotNull String... extensionIds)Removes the specified prepackaged extension folders from '/opt/hivemq/extensions' before the container is built.-
Methods inherited from class org.testcontainers.containers.GenericContainer
addEnv, addExposedPort, addExposedPorts, addFileSystemBind, addFixedExposedPort, addFixedExposedPort, addLink, apply, canBeReused, configure, containerIsCreated, containerIsStarted, containerIsStarted, containerIsStarting, containerIsStarting, containerIsStopped, containerIsStopping, copyFileFromContainer, createVolumeDirectory, dependsOn, dependsOn, dependsOn, doStart, equals, failed, finished, 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, isPrivilegedMode, isShouldBeReused, logger, setBinds, setCommand, setCommand, setCommandParts, setCopyToFileContainerPathMap, setDockerImageName, setEnv, setExposedPorts, setExtraHosts, setImage, setLabels, setLinkedContainers, setLogConsumers, setNetwork, setNetworkAliases, setNetworkMode, setPortBindings, setPrivilegedMode, setShmSize, setStartupAttempts, setStartupCheckStrategy, setTmpFsMapping, setVolumesFroms, setWaitStrategy, setWorkingDirectory, starting, succeeded, toString, waitingFor, waitUntilContainerStarted, withClasspathResourceMapping, withClasspathResourceMapping, withCommand, withCommand, withCopyFileToContainer, 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, getBoundPortNumbers, getContainerIpAddress, getCurrentContainerInfo, getFirstMappedPort, getHost, getLogs, getLogs, getMappedPort, isCreated, isHealthy, isRunning
-
-
-
-
Field Detail
-
DEBUGGING_PORT
public static final int DEBUGGING_PORT
- See Also:
- Constant Field Values
-
MQTT_PORT
public static final int MQTT_PORT
- See Also:
- Constant Field Values
-
CONTROL_CENTER_PORT
public static final int CONTROL_CENTER_PORT
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
HiveMQTestContainerCore
public HiveMQTestContainerCore()
-
HiveMQTestContainerCore
public HiveMQTestContainerCore(@NotNull @NotNull DockerImageName dockerImageName)
-
-
Method Detail
-
start
public void start()
- Specified by:
startin interfaceStartable- Overrides:
startin classGenericContainer<SELF extends HiveMQTestContainerCore<SELF>>
-
waitForExtension
@NotNull public SELF waitForExtension(@NotNull @NotNull String extensionName)
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 SELF 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
@NotNull public SELF withDebugging()
Enables the possibility for remote debugging clients to connect.Must be called before the container is started.
- Returns:
- self
-
withLogLevel
@NotNull public SELF 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 SELF withExtension(@NotNull @NotNull HiveMQExtension hiveMQExtension)
Wraps the given class and all its subclasses into an extension and puts it into '/opt/hivemq/extensions/{extension-id}' inside the container.Must be called before the container is started.
- Parameters:
hiveMQExtension- theHiveMQExtensionof the extension- Returns:
- self
-
withExtension
@NotNull public SELF withExtension(@NotNull @NotNull MountableFile mountableExtension)
Puts the given extension folder into '/opt/hivemq/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.
- Parameters:
mountableExtension- the extension folder on the host machine- Returns:
- self
-
withoutPrepackagedExtensions
@NotNull public SELF withoutPrepackagedExtensions(@NotNull @NotNull String... extensionIds)
Removes the specified prepackaged extension folders from '/opt/hivemq/extensions' before the container is built. Note: this creates a custom docker image.Must be called before the container is started.
- Parameters:
extensionIds- the prepackaged extensions to remove- Returns:
- self
-
withoutPrepackagedExtensions
@NotNull public SELF withoutPrepackagedExtensions()
Removes all prepackaged extension folders from '/opt/hivemq/extensions' before the container is built. Note: this creates a custom docker image.Must be called before the container is started.
- Returns:
- self
-
withLicense
@NotNull public SELF withLicense(@NotNull @NotNull 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 SELF withHiveMQConfig(@NotNull @NotNull 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 SELF withFileInExtensionHomeFolder(@NotNull @NotNull MountableFile file, @NotNull @NotNull String extensionId)
Puts the given file into the root of the extension's home '/opt/hivemq/extensions/{extensionId}/'. Note: the extension must be loaded before the file is put.Must be called before the container is started.
- Parameters:
file- the file on the host machineextensionId- the extension- Returns:
- self
-
withFileInExtensionHomeFolder
@NotNull public SELF withFileInExtensionHomeFolder(@NotNull @NotNull MountableFile file, @NotNull @NotNull String extensionId, @NotNull @NotNull String pathInExtensionHome)
Puts the given file into given subdirectory of the extensions's home '/opt/hivemq/extensions/{id}/{pathInExtensionHome}/' Note: the extension must be loaded before the file is put.Must be called before the container is started.
- Parameters:
file- the file on the host machineextensionId- the extensionpathInExtensionHome- the path- Returns:
- self
-
withFileInHomeFolder
@NotNull public SELF withFileInHomeFolder(@NotNull @NotNull MountableFile file)
Puts the given file into the root of the HiveMQ home folder '/opt/hivemq/'.Must be called before the container is started.
- Parameters:
file- the file on the host machine- Returns:
- self
-
withFileInHomeFolder
@NotNull public SELF withFileInHomeFolder(@NotNull @NotNull 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- Since:
- 1.1.0
-
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- Since:
- 1.1.0
-
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- Since:
- 1.1.0
-
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- Since:
- 1.1.0
-
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- Since:
- 1.1.0
-
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- Since:
- 1.1.0
-
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- Since:
- 1.1.0
-
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- Since:
- 1.1.0
-
silent
@NotNull public SELF silent(boolean silent)
Determines whether the stdout of the container is printed to System.out.- Parameters:
silent- whether the container is silent.- Returns:
- self
-
withControlCenter
@NotNull public SELF 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
-
stop
public void stop()
- Specified by:
stopin interfaceStartable- Overrides:
stopin classGenericContainer<SELF extends HiveMQTestContainerCore<SELF>>
-
-