Class MicrocksContainer
java.lang.Object
org.testcontainers.containers.FailureDetectingExternalResource
org.testcontainers.containers.GenericContainer<MicrocksContainer>
io.github.microcks.testcontainers.MicrocksContainer
- All Implemented Interfaces:
AutoCloseable,org.junit.rules.TestRule,org.testcontainers.containers.Container<MicrocksContainer>,org.testcontainers.containers.ContainerState,org.testcontainers.containers.traits.LinkableContainer,org.testcontainers.containers.wait.strategy.WaitStrategyTarget,org.testcontainers.lifecycle.Startable
public class MicrocksContainer
extends org.testcontainers.containers.GenericContainer<MicrocksContainer>
Testcontainers implementation for main Microcks container.
- Author:
- laurent
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classNested classes/interfaces inherited from interface org.testcontainers.containers.Container
org.testcontainers.containers.Container.ExecResult -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intFields inherited from class org.testcontainers.containers.GenericContainer
CONTAINER_RUNNING_TIMEOUT_SEC, dependencies, dockerClient, INTERNAL_HOST_HOSTNAME, waitStrategyFields inherited from interface org.testcontainers.containers.ContainerState
STATE_HEALTHY -
Constructor Summary
ConstructorsConstructorDescriptionMicrocksContainer(String image) Build a new MicrocksContainer with its container image name as string.MicrocksContainer(org.testcontainers.utility.DockerImageName imageName) Build a new MicrocksContainer with its full container image name. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcontainerIsStarted(com.github.dockerjava.api.command.InspectContainerResponse containerInfo) getGraphQLMockEndpoint(String service, String version) Get the exposed mock endpoint for a GRPC Service.Get the exposed mock endpoint for a GRPC Service.Get the Http endpoint where Microcks can be accessed (you'd have to append '/api' to access APIs)getRestMockEndpoint(String service, String version) Get the exposed mock endpoint for a REST API.getSoapMockEndpoint(String service, String version) Get the exposed mock endpoint for a SOAP Service.voidimportAsMainArtifact(File artifact) Import an artifact as a primary or main one within the Microcks container.voidimportAsSecondaryArtifact(File artifact) Import an artifact as a secondary one within the Microcks container.testEndpoint(TestRequest testRequest) Launch a conformance test on an endpoint.static TestResulttestEndpoint(String microcksContainerHttpEndpoint, TestRequest testRequest) Launch a conformance test on an endpoint.testEndpointAsync(TestRequest testRequest) Launch a conformance test on an endpoint asynchronously.static CompletableFuture<TestResult>testEndpointAsync(String microcksContainerHttpEndpoint, TestRequest testRequest) Launch a conformance test on an endpoint asynchronously.withMainArtifacts(String... artifacts) Provide paths to artifacts that will be imported as primary or main ones within the Microcks container once it will be started and healthy.withSecondaryArtifacts(String... artifacts) Provide paths to artifacts that will be imported as secondary ones within the Microcks container once it will be started and healthy.withSecret(Secret secret) Provide Secret that should be imported in Microcks after startup.Methods inherited from class org.testcontainers.containers.GenericContainer
addEnv, addExposedPort, addExposedPorts, addFileSystemBind, addFixedExposedPort, addFixedExposedPort, addLink, apply, canBeReused, configure, containerIsCreated, 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, 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, execInContainerWithUser, execInContainerWithUser, getBoundPortNumbers, getContainerIpAddress, getCurrentContainerInfo, getFirstMappedPort, getHost, getLogs, getLogs, getMappedPort, isCreated, isHealthy, isRunningMethods inherited from interface org.testcontainers.lifecycle.Startable
close
-
Field Details
-
MICROCKS_HTTP_PORT
public static final int MICROCKS_HTTP_PORT- See Also:
-
MICROCKS_GRPC_PORT
public static final int MICROCKS_GRPC_PORT- See Also:
-
-
Constructor Details
-
MicrocksContainer
Build a new MicrocksContainer with its container image name as string. This image must be compatible with quay.io/microcks/microcks-uber image.- Parameters:
image- The name (with tag/version) of Microcks Uber distribution to use.
-
MicrocksContainer
public MicrocksContainer(org.testcontainers.utility.DockerImageName imageName) Build a new MicrocksContainer with its full container image name. This image must be compatible with quay.io/microcks/microcks-uber image.- Parameters:
imageName- The name (with tag/version) of Microcks Uber distribution to use.
-
-
Method Details
-
withMainArtifacts
Provide paths to artifacts that will be imported as primary or main ones within the Microcks container once it will be started and healthy.- Parameters:
artifacts- A set of paths to artifacts that will be loaded as classpath resources- Returns:
- self
-
withSecondaryArtifacts
Provide paths to artifacts that will be imported as secondary ones within the Microcks container once it will be started and healthy.- Parameters:
artifacts- A set of paths to artifacts that will be loaded as classpath resources- Returns:
- self
-
withSecret
Provide Secret that should be imported in Microcks after startup.- Parameters:
secret- The description of a secret to access remote Git repotisory, test endpoint or broker.- Returns:
- self
-
containerIsStarted
protected void containerIsStarted(com.github.dockerjava.api.command.InspectContainerResponse containerInfo) - Overrides:
containerIsStartedin classorg.testcontainers.containers.GenericContainer<MicrocksContainer>
-
getHttpEndpoint
Get the Http endpoint where Microcks can be accessed (you'd have to append '/api' to access APIs)- Returns:
- The Http endpoint for talking to container.
-
getSoapMockEndpoint
Get the exposed mock endpoint for a SOAP Service.- Parameters:
service- The name of Service/APIversion- The version of Service/API- Returns:
- A usable endpoint to interact with Microcks mocks.
-
getRestMockEndpoint
Get the exposed mock endpoint for a REST API.- Parameters:
service- The name of Service/APIversion- The version of Service/API- Returns:
- A usable endpoint to interact with Microcks mocks.
-
getGraphQLMockEndpoint
Get the exposed mock endpoint for a GRPC Service.- Parameters:
service- The name of Service/APIversion- The version of Service/API- Returns:
- A usable endpoint to interact with Microcks mocks.
-
getGrpcMockEndpoint
Get the exposed mock endpoint for a GRPC Service.- Returns:
- A usable endpoint to interact with Microcks mocks.
-
importAsMainArtifact
public void importAsMainArtifact(File artifact) throws IOException, InterruptedException, MicrocksException Import an artifact as a primary or main one within the Microcks container.- Parameters:
artifact- The file representing artifact (OpenAPI, Postman collection, Protobuf, GraphQL schema, ...)- Throws:
IOException- If file cannot be read of transmission exception occurs.InterruptedException- If connection to the docker container is interrupted.MicrocksException- If artifact cannot be correctly imported in container (probably malformed)
-
importAsSecondaryArtifact
public void importAsSecondaryArtifact(File artifact) throws IOException, InterruptedException, MicrocksException Import an artifact as a secondary one within the Microcks container.- Parameters:
artifact- The file representing artifact (OpenAPI, Postman collection, Protobuf, GraphQL schema, ...)- Throws:
IOException- If file cannot be read of transmission exception occurs.InterruptedException- If connection to the docker container is interrupted.MicrocksException- If artifact cannot be correctly imported in container (probably malformed)
-
testEndpoint
public TestResult testEndpoint(TestRequest testRequest) throws IOException, InterruptedException, MicrocksException Launch a conformance test on an endpoint.- Parameters:
testRequest- The test specifications (API under test, endpoint, runner, ...)- Returns:
- The final TestResult containing information on success/failure as well as details on test cases.
- Throws:
IOException- If connection to Microcks container failed (no route to host, low-level network stuffs)InterruptedException- If connection to Microcks container is interruptedMicrocksException- If Microcks fails creating a new test giving your request.
-
testEndpointAsync
Launch a conformance test on an endpoint asynchronously.- Parameters:
testRequest- The test specifications (API under test, endpoint, runner, ...)- Returns:
- A completable future that will allow to retrieve a TestResult once test is finished.
-
testEndpointAsync
public static CompletableFuture<TestResult> testEndpointAsync(String microcksContainerHttpEndpoint, TestRequest testRequest) Launch a conformance test on an endpoint asynchronously.- Parameters:
microcksContainerHttpEndpoint- The Http endpoint where to reach running MicrocksContainertestRequest- The test specifications (API under test, endpoint, runner, ...)- Returns:
- A completable future that will allow to retrieve a TestResult once test is finished.
-
testEndpoint
public static TestResult testEndpoint(String microcksContainerHttpEndpoint, TestRequest testRequest) throws IOException, MicrocksException Launch a conformance test on an endpoint. This may be a fallback to non-statictestEndpoint(TestRequest testRequest)method if you don't have direct access to the MicrocksContainer instance you want to run this test on.- Parameters:
microcksContainerHttpEndpoint- The Http endpoint where to reach running MicrocksContainertestRequest- The test specifications (API under test, endpoint, runner, ...)- Returns:
- The final TestResult containing information on success/failure as well as details on test cases.
- Throws:
IOException- If connection to Microcks container failed (no route to host, low-level network stuffs)MicrocksException- If Microcks fails creating a new test giving your request.
-