Class WireMockContainer
- java.lang.Object
-
- org.testcontainers.containers.FailureDetectingExternalResource
-
- org.testcontainers.containers.GenericContainer<WireMockContainer>
-
- org.wiremock.integrations.testcontainers.WireMockContainer
-
- All Implemented Interfaces:
AutoCloseable,org.junit.rules.TestRule,org.testcontainers.containers.Container<WireMockContainer>,org.testcontainers.containers.ContainerState,org.testcontainers.containers.traits.LinkableContainer,org.testcontainers.containers.wait.strategy.WaitStrategyTarget,org.testcontainers.lifecycle.Startable
public class WireMockContainer extends org.testcontainers.containers.GenericContainer<WireMockContainer>
Provisions WireMock standalone server as a container. Designed to follow the WireMock Docker image (wiremock/wiremock) structure and configuration, but other images can be included too at your own risk.
-
-
Field Summary
Fields Modifier and Type Field Description static StringOFFICIAL_IMAGE_NAMEstatic org.testcontainers.utility.DockerImageNameWIREMOCK_2_LATEST
-
Constructor Summary
Constructors Constructor Description WireMockContainer(String image)Create image from the specified full image name (repo, image, tag)WireMockContainer(org.testcontainers.utility.DockerImageName dockerImage)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected voidconfigure()StringgetBaseUrl()IntegergetPort()StringgetUrl(String path)WireMockContainerwithBanner()Enable the banner when starting the WireMock container.WireMockContainerwithCliArg(String arg)Adds CLI argument to the WireMock call.WireMockContainerwithExtension(String className)Add extension that will be loaded from the classpath.WireMockContainerwithExtensions(String id, Collection<String> classNames, Collection<File> jars)Add extension that will be loaded from the specified JAR files.WireMockContainerwithExtensions(Collection<String> classNames, File jarDirectory)Add extension that will be loaded from the specified directory with JAR files.WireMockContainerwithExtensions(Collection<String> classNames, Collection<File> jars)Add extension that will be loaded from the specified JAR files.WireMockContainerwithFile(File file)Adds fileWireMockContainerwithFile(String name, File file)Adds fileWireMockContainerwithFileFromResource(Class<?> resource, String filename)WireMockContainerwithFileFromResource(String classpathResource)WireMockContainerwithFileFromResource(String name, Class<?> resource, String filename)WireMockContainerwithFileFromResource(String name, String classpathResource)WireMockContainerwithMapping(String name, Class<?> resource, String resourceJson)Deprecated.WireMockContainerwithMapping(String name, String json)Deprecated.WireMockContainerwithMappingFromJSON(String json)Add mapping JSON file from its valueWireMockContainerwithMappingFromJSON(String name, String json)Adds a JSON mapping stub to WireMock configurationWireMockContainerwithMappingFromResource(Class<?> resource, String resourceJson)Loads mapping stub from the class resourceWireMockContainerwithMappingFromResource(String resourceName)Loads mapping stub from the resource fileWireMockContainerwithMappingFromResource(String name, Class<?> resource, String resourceJson)Loads mapping stub from the class resourceWireMockContainerwithMappingFromResource(String name, String resourceName)Loads mapping stub from the resource fileWireMockContainerwithMappingFromResource(String name, URL url)Loads mapping stub from the resource fileWireMockContainerwithoutBanner()Disables the banner when starting the WireMock container.-
Methods inherited from class org.testcontainers.containers.GenericContainer
addEnv, addExposedPort, addExposedPorts, addFileSystemBind, addFixedExposedPort, addFixedExposedPort, addLink, apply, canBeReused, 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, isHostAccessible, isPrivilegedMode, isShouldBeReused, logger, setBinds, setCommand, setCommand, setCommandParts, setCopyToFileContainerPathMap, setDockerImageName, setEnv, setExposedPorts, setExtraHosts, setHostAccessible, setImage, setLabels, setLinkedContainers, setLogConsumers, setNetwork, setNetworkAliases, setNetworkMode, setPortBindings, setPrivilegedMode, setShmSize, setStartupAttempts, setStartupCheckStrategy, setTmpFsMapping, setVolumesFroms, setWaitStrategy, setWorkingDirectory, start, starting, stop, succeeded, 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, 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, execInContainerWithUser, execInContainerWithUser, getBoundPortNumbers, getContainerIpAddress, getCurrentContainerInfo, getFirstMappedPort, getHost, getLogs, getLogs, getMappedPort, isCreated, isHealthy, isRunning
-
-
-
-
Field Detail
-
OFFICIAL_IMAGE_NAME
public static final String OFFICIAL_IMAGE_NAME
- See Also:
- Constant Field Values
-
WIREMOCK_2_LATEST
public static final org.testcontainers.utility.DockerImageName WIREMOCK_2_LATEST
-
-
Constructor Detail
-
WireMockContainer
public WireMockContainer(String image)
Create image from the specified full image name (repo, image, tag)
-
WireMockContainer
public WireMockContainer(org.testcontainers.utility.DockerImageName dockerImage)
-
-
Method Detail
-
withoutBanner
public WireMockContainer withoutBanner()
Disables the banner when starting the WireMock container.- Returns:
- this instance
-
withBanner
public WireMockContainer withBanner()
Enable the banner when starting the WireMock container.- Returns:
- this instance
-
withCliArg
public WireMockContainer withCliArg(String arg)
Adds CLI argument to the WireMock call.- Parameters:
arg- Argument- Returns:
- this instance
-
withMappingFromJSON
public WireMockContainer withMappingFromJSON(String json)
Add mapping JSON file from its value- Parameters:
json- JSON sting- Returns:
- This instance
-
withMappingFromJSON
public WireMockContainer withMappingFromJSON(String name, String json)
Adds a JSON mapping stub to WireMock configuration- Parameters:
name- Name of the mapping stubjson- Configuration JSON- Returns:
- this instance
-
withMapping
@Deprecated public WireMockContainer withMapping(String name, String json)
Deprecated.
-
withMappingFromResource
public WireMockContainer withMappingFromResource(String name, Class<?> resource, String resourceJson)
Loads mapping stub from the class resource- Parameters:
name- Name of the mapping stubresource- Resource class. Name of the class will be appended to the resource pathresourceJson- Reference to the mapping definition file, starting from theresourceroot (normally package)- Returns:
- this instance
-
withMappingFromResource
public WireMockContainer withMappingFromResource(Class<?> resource, String resourceJson)
Loads mapping stub from the class resource- Parameters:
resource- Resource class. Name of the class will be appended to the resource pathresourceJson- Mapping definition file- Returns:
- this instance
-
withMapping
@Deprecated public WireMockContainer withMapping(String name, Class<?> resource, String resourceJson)
Deprecated.usewithMappingFromResource(String, Class, String). Note that the new method scopes to the package, not to class
-
withMappingFromResource
public WireMockContainer withMappingFromResource(String name, String resourceName)
Loads mapping stub from the resource file- Parameters:
name- Name of the mapping stubresourceName- Resource name and path- Returns:
- this instance
-
withMappingFromResource
public WireMockContainer withMappingFromResource(String resourceName)
Loads mapping stub from the resource file- Parameters:
resourceName- Resource name and path- Returns:
- this instance
-
withMappingFromResource
public WireMockContainer withMappingFromResource(String name, URL url)
Loads mapping stub from the resource file- Parameters:
name- Name of the mapping stuburl- Resource file URL- Returns:
- this instance
-
withFile
public WireMockContainer withFile(String name, File file)
Adds file- Parameters:
name- ID to be usedfile- File to add- Returns:
- This instance
-
withFile
public WireMockContainer withFile(File file)
Adds file- Parameters:
file- File to add- Returns:
- This instance
-
withFileFromResource
public WireMockContainer withFileFromResource(String name, String classpathResource)
-
withFileFromResource
public WireMockContainer withFileFromResource(String classpathResource)
-
withFileFromResource
public WireMockContainer withFileFromResource(String name, Class<?> resource, String filename)
-
withFileFromResource
public WireMockContainer withFileFromResource(Class<?> resource, String filename)
-
withExtensions
public WireMockContainer withExtensions(Collection<String> classNames, Collection<File> jars)
Add extension that will be loaded from the specified JAR files. In the internal engine, it will be handled as a single plugin.- Parameters:
classNames- Class names of the extension to be includedjars- JARs to be included into the container- Returns:
- this instance
-
withExtensions
public WireMockContainer withExtensions(String id, Collection<String> classNames, Collection<File> jars)
Add extension that will be loaded from the specified JAR files. In the internal engine, it will be handled as a single plugin.- Parameters:
id- Identifier top useclassNames- Class names of the extension to be includedjars- JARs to be included into the container- Returns:
- this instance
-
withExtensions
public WireMockContainer withExtensions(Collection<String> classNames, File jarDirectory)
Add extension that will be loaded from the specified directory with JAR files. In the internal engine, it will be handled as a single plugin.- Parameters:
classNames- Class names of the extension to be includedjarDirectory- Directory that stores all JARs- Returns:
- this instance
-
withExtension
public WireMockContainer withExtension(String className)
Add extension that will be loaded from the classpath. This method can be used if the extension is a part of the WireMock bundle, or a Jar is already added viawithExtensions(Collection, Collection)}. In the internal engine, it will be handled as a single plugin.- Parameters:
className- Class name of the extension- Returns:
- this instance
-
getBaseUrl
public String getBaseUrl()
-
getPort
public Integer getPort()
-
configure
protected void configure()
- Overrides:
configurein classorg.testcontainers.containers.GenericContainer<WireMockContainer>
-
-