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 Classes
    Modifier and Type
    Class
    Description
    static class 
     
    static class 
     

    Nested classes/interfaces inherited from interface org.testcontainers.containers.Container

    org.testcontainers.containers.Container.ExecResult
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
     
    static final int
     

    Fields inherited from class org.testcontainers.containers.GenericContainer

    CONTAINER_RUNNING_TIMEOUT_SEC, dependencies, dockerClient, INTERNAL_HOST_HOSTNAME, waitStrategy

    Fields inherited from interface org.testcontainers.containers.ContainerState

    STATE_HEALTHY
  • Constructor Summary

    Constructors
    Constructor
    Description
    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 Type
    Method
    Description
    protected void
    containerIsStarted(com.github.dockerjava.api.command.InspectContainerResponse containerInfo)
     
    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.
    void
    Import an artifact as a primary or main one within the Microcks container.
    void
    Import an artifact as a secondary one within the Microcks container.
    Launch a conformance test on an endpoint.
    static TestResult
    testEndpoint(String microcksContainerHttpEndpoint, TestRequest testRequest)
    Launch a conformance test on an endpoint.
    Launch a conformance test on an endpoint asynchronously.
    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.
    Provide paths to artifacts that will be imported as secondary ones within the Microcks container once it will be started and healthy.
    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, 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

    Methods inherited from interface org.testcontainers.lifecycle.Startable

    close
  • Field Details

  • Constructor Details

    • MicrocksContainer

      public MicrocksContainer(String image)
      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

      public MicrocksContainer 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.
      Parameters:
      artifacts - A set of paths to artifacts that will be loaded as classpath resources
      Returns:
      self
    • withSecondaryArtifacts

      public MicrocksContainer 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.
      Parameters:
      artifacts - A set of paths to artifacts that will be loaded as classpath resources
      Returns:
      self
    • withSecret

      public MicrocksContainer withSecret(Secret secret)
      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:
      containerIsStarted in class org.testcontainers.containers.GenericContainer<MicrocksContainer>
    • getHttpEndpoint

      public String 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

      public String getSoapMockEndpoint(String service, String version)
      Get the exposed mock endpoint for a SOAP Service.
      Parameters:
      service - The name of Service/API
      version - The version of Service/API
      Returns:
      A usable endpoint to interact with Microcks mocks.
    • getRestMockEndpoint

      public String getRestMockEndpoint(String service, String version)
      Get the exposed mock endpoint for a REST API.
      Parameters:
      service - The name of Service/API
      version - The version of Service/API
      Returns:
      A usable endpoint to interact with Microcks mocks.
    • getGraphQLMockEndpoint

      public String getGraphQLMockEndpoint(String service, String version)
      Get the exposed mock endpoint for a GRPC Service.
      Parameters:
      service - The name of Service/API
      version - The version of Service/API
      Returns:
      A usable endpoint to interact with Microcks mocks.
    • getGrpcMockEndpoint

      public String 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 interrupted
      MicrocksException - If Microcks fails creating a new test giving your request.
    • testEndpointAsync

      public CompletableFuture<TestResult> testEndpointAsync(TestRequest testRequest)
      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 MicrocksContainer
      testRequest - 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-static testEndpoint(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 MicrocksContainer
      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)
      MicrocksException - If Microcks fails creating a new test giving your request.