public class Container
extends java.lang.Object
| Constructor and Description |
|---|
Container(java.lang.String name,
com.spotify.docker.client.messages.ContainerConfig config,
boolean alwaysRemoveContainer,
ContainerListener listener)
Construct a container.
|
| Modifier and Type | Method and Description |
|---|---|
protected com.spotify.docker.client.DockerClient |
createDockerClient() |
com.spotify.docker.client.DockerClient |
getClient() |
java.lang.String |
getContainerId() |
java.lang.String |
getHost() |
com.spotify.docker.client.messages.ContainerInfo |
getInfo() |
int |
getPort(java.lang.String portName) |
static boolean |
isSocketAlive(java.net.SocketAddress socketAddress,
int timeout) |
void |
stop() |
void |
waitForLog(int timeout,
java.util.concurrent.TimeUnit unit,
java.lang.String... messages)
Wait for nth occurrence of message to appear in docker logs within the specified timeframe.
|
void |
waitForLog(java.lang.String... messages)
Wait for a sequence of messages to appear in docker logs.
|
void |
waitForPort(int port)
Wait for the specified port to accept socket connection.
|
void |
waitForPort(int port,
int timeout,
java.util.concurrent.TimeUnit unit)
Wait for the specified port to accept socket connection within a given timeframe.
|
public Container(java.lang.String name,
com.spotify.docker.client.messages.ContainerConfig config,
boolean alwaysRemoveContainer,
ContainerListener listener)
name - name to assign to container, or null to use defaultconfig - the container configurationalwaysRemoveContainer - true if we should always remove container, e.g. "docker rm" after unit tests; by
default, the docker container is left around so that it can be reused again.listener - listener for container events, may be nullpublic static boolean isSocketAlive(java.net.SocketAddress socketAddress,
int timeout)
protected com.spotify.docker.client.DockerClient createDockerClient()
public final com.spotify.docker.client.DockerClient getClient()
public final java.lang.String getContainerId()
public final java.lang.String getHost()
public final com.spotify.docker.client.messages.ContainerInfo getInfo()
public final int getPort(java.lang.String portName)
public void stop()
public final void waitForLog(int timeout,
java.util.concurrent.TimeUnit unit,
java.lang.String... messages)
throws com.spotify.docker.client.exceptions.DockerException,
java.lang.InterruptedException
timeout - timeout valueunit - timeout unitsmessages - The sequence of messages to wait forcom.spotify.docker.client.exceptions.DockerException - if docker throws exception while tailing logsjava.lang.InterruptedException - if thread interrupted while waiting for timeoutpublic final void waitForLog(java.lang.String... messages)
throws com.spotify.docker.client.exceptions.DockerException,
java.lang.InterruptedException
messages - The sequence of messages to wait forcom.spotify.docker.client.exceptions.DockerException - if docker throws exception while tailing logsjava.lang.InterruptedException - if thread interrupted while waiting for timeoutpublic final void waitForPort(int port)
port - target port numberpublic final void waitForPort(int port,
int timeout,
java.util.concurrent.TimeUnit unit)
port - target port numbertimeout - timeout valueunit - timeout units