Package org.opennms.smoketest.containers
Class OpenNMSContainer
- java.lang.Object
-
- org.testcontainers.containers.FailureDetectingExternalResource
-
- org.testcontainers.containers.GenericContainer
-
- org.opennms.smoketest.containers.OpenNMSContainer
-
- All Implemented Interfaces:
AutoCloseable
,org.junit.rules.TestRule
,KarafContainer
,org.testcontainers.containers.Container
,org.testcontainers.containers.ContainerState
,org.testcontainers.containers.traits.LinkableContainer
,org.testcontainers.containers.wait.strategy.WaitStrategyTarget
,org.testcontainers.lifecycle.Startable
,org.testcontainers.lifecycle.TestLifecycleAware
public class OpenNMSContainer extends org.testcontainers.containers.GenericContainer implements KarafContainer, org.testcontainers.lifecycle.TestLifecycleAware
This class encapsulates all the logic required to start an OpenNMS container and interface with the services it provides.- Author:
- jwhite
-
-
Field Summary
Fields Modifier and Type Field Description static String
ADMIN_PASSWORD
static String
ADMIN_USER
static String
ALIAS
static String
CASSANDRA_ALIAS
static String
DB_ALIAS
static String
ELASTIC_ALIAS
static String
KAFKA_ALIAS
static int
OPENNMS_WEB_PORT
-
Constructor Summary
Constructors Constructor Description OpenNMSContainer(StackModel model, OpenNMSProfile profile)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
afterTest(org.testcontainers.lifecycle.TestDescription description, Optional<Throwable> throwable)
URL
getBaseUrlExternal()
static URL
getBaseUrlInternal()
List<String>
getFeaturesOnBoot()
StackModel
getModel()
InetSocketAddress
getNetworkProtocolAddress(NetworkProtocol protocol)
RestClient
getRestClient()
InetSocketAddress
getSshAddress()
Properties
getSystemProperties()
InetSocketAddress
getWebAddress()
int
getWebPort()
SshClient
ssh()
Create a new SSH client connected to the Karaf shell in this container.-
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, start, starting, stop, 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
addEnv, addExposedPort, addExposedPorts, addFileSystemBind, addFileSystemBind, addLink, followOutput, followOutput, getBinds, getCommandParts, getDockerClient, getDockerImageName, getEnv, getEnvMap, getExtraHosts, getImage, getLinkedContainers, getPortBindings, getTestHostIpAddress, self, setBinds, setCommand, setCommand, setCommandParts, setDockerImageName, setEnv, setExposedPorts, setExtraHosts, setImage, setLinkedContainers, setPortBindings, setWaitStrategy, waitingFor, withClasspathResourceMapping, withClasspathResourceMapping, withCommand, withCommand, withCopyFileToContainer, withEnv, withEnv, withEnv, withExposedPorts, withExtraHost, withFileSystemBind, withFileSystemBind, withImagePullPolicy, withLabel, withLabels, withLogConsumer, withMinimumRunningDuration, withNetwork, withNetworkAliases, withNetworkMode, withPrivilegedMode, withStartupCheckStrategy, withStartupTimeout, withVolumesFrom, withWorkingDirectory
-
Methods inherited from interface org.testcontainers.containers.ContainerState
copyFileFromContainer, copyFileFromContainer, copyFileToContainer, copyFileToContainer, execInContainer, execInContainer, getBoundPortNumbers, getContainerId, getContainerInfo, getContainerIpAddress, getCurrentContainerInfo, getExposedPorts, getFirstMappedPort, getHost, getLogs, getLogs, getMappedPort, isCreated, isHealthy, isRunning
-
-
-
-
Field Detail
-
ALIAS
public static final String ALIAS
- See Also:
- Constant Field Values
-
DB_ALIAS
public static final String DB_ALIAS
- See Also:
- Constant Field Values
-
KAFKA_ALIAS
public static final String KAFKA_ALIAS
- See Also:
- Constant Field Values
-
ELASTIC_ALIAS
public static final String ELASTIC_ALIAS
- See Also:
- Constant Field Values
-
CASSANDRA_ALIAS
public static final String CASSANDRA_ALIAS
- See Also:
- Constant Field Values
-
ADMIN_USER
public static final String ADMIN_USER
- See Also:
- Constant Field Values
-
ADMIN_PASSWORD
public static final String ADMIN_PASSWORD
- See Also:
- Constant Field Values
-
OPENNMS_WEB_PORT
public static final int OPENNMS_WEB_PORT
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
OpenNMSContainer
public OpenNMSContainer(StackModel model, OpenNMSProfile profile)
-
-
Method Detail
-
getBaseUrlInternal
public static URL getBaseUrlInternal()
- Returns:
- the URL in a form consumable by containers networked with this one using the alias and internal port
-
getBaseUrlExternal
public URL getBaseUrlExternal()
- Returns:
- the URL in a form consumable by the host using the mapped port
-
getRestClient
public RestClient getRestClient()
-
getSshAddress
public InetSocketAddress getSshAddress()
-
ssh
public SshClient ssh()
Description copied from interface:KarafContainer
Create a new SSH client connected to the Karaf shell in this container.- Specified by:
ssh
in interfaceKarafContainer
- Returns:
- a new SSH client for this container
-
getWebPort
public int getWebPort()
-
getWebAddress
public InetSocketAddress getWebAddress()
-
getSystemProperties
public Properties getSystemProperties()
-
getNetworkProtocolAddress
public InetSocketAddress getNetworkProtocolAddress(NetworkProtocol protocol)
-
getModel
public StackModel getModel()
-
-