Class SmileCdrContainer

java.lang.Object
org.testcontainers.containers.FailureDetectingExternalResource
org.testcontainers.containers.GenericContainer<SmileCdrContainer>
ca.cdr.test.extensions.SmileCdrContainer
All Implemented Interfaces:
AutoCloseable, org.junit.rules.TestRule, org.testcontainers.containers.Container<SmileCdrContainer>, org.testcontainers.containers.ContainerState, org.testcontainers.containers.traits.LinkableContainer, org.testcontainers.containers.wait.strategy.WaitStrategyTarget, org.testcontainers.lifecycle.Startable

public class SmileCdrContainer extends org.testcontainers.containers.GenericContainer<SmileCdrContainer>
SmileCdrContainer is a container abstraction for orchestrating Smile CDR instances within Docker environments.

Instances of this container allow for flexible customization and configuration of Smile CDR images, including properties file specifications, logback configurations, and support for customer JAR files. It supports smooth integration and automated provisioning of Smile CDR services for testing and development environments.

The design facilitates: - Configuration of Smile CDR version and the corresponding Docker image. - Mounting of custom resources such as properties files, logback configurations, or JARs. - Automatic setup of exposed ports based on specified or default configurations. - Log consumption to aid in debugging and diagnostics during container runtime. - Ensuring modular support with organized port mapping and harness configuration.

This class was generated partly with the help of Claude Sonnet 3.7

  • Nested Class Summary

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

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

    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
     
    SmileCdrContainer(String theSmileCdrVersion)
    Use this constructor to change the version of Smile CDR, but use Smile's container registry.
    SmileCdrContainer(org.testcontainers.utility.DockerImageName imageName)
    Use this constructor to provide a completely custom Docker Image Name to use.
  • Method Summary

    Modifier and Type
    Method
    Description
     
     
    Gets the port values organized by Module Type and Module ID.
    void
     
     
    Binds the target/classes and target/test-classes directories into the container's `/classes` directory.
    withCustomerJars(String... theJarNames)
    Specifies which JAR files from the cdr-interceptor-starterproject's target folder should be copied into the SmileCdrContainer at /home/smile/smilecdr/customerlib/.
     
    withCustomLogback(String theCustomLogbackLocation)
     
    Enables remote debugging for the Smile CDR instance running in this container.
    withDebugEnabled(boolean theSuspendUntilDebuggerAttached)
    Enables remote debugging for the Smile CDR instance running in this container.
    withPreseedFiles(String... filesToMount)
     
    withPropertiesFile(String thePropertiesFileLocation)
     

    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, isHostAccessible, isPrivilegedMode, isShouldBeReused, logger, setBinds, setCommand, setCommand, setCommandParts, setContainerDef, setCopyToFileContainerPathMap, setDockerImageName, setEnv, setExposedPorts, setExtraHosts, setHostAccessible, setImage, setLabels, setLinkedContainers, setLogConsumers, setNetwork, setNetworkAliases, setNetworkMode, setPortBindings, setPrivilegedMode, setShmSize, setStartupAttempts, setStartupCheckStrategy, setTmpFsMapping, setVolumesFroms, setWaitStrategy, setWorkingDirectory, 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, execInContainer, execInContainer, execInContainerWithUser, execInContainerWithUser, getBoundPortNumbers, getContainerIpAddress, getCurrentContainerInfo, getFirstMappedPort, getHost, getLogs, getLogs, getMappedPort, isCreated, isHealthy, isRunning

    Methods inherited from interface org.testcontainers.lifecycle.Startable

    close
  • Constructor Details

    • SmileCdrContainer

    • SmileCdrContainer

      public SmileCdrContainer(String theSmileCdrVersion)
      Use this constructor to change the version of Smile CDR, but use Smile's container registry.
    • SmileCdrContainer

      public SmileCdrContainer(org.testcontainers.utility.DockerImageName imageName)
      Use this constructor to provide a completely custom Docker Image Name to use. Use this if you need to use your own private registry
  • Method Details

    • start

      public void start()
      Specified by:
      start in interface org.testcontainers.lifecycle.Startable
      Overrides:
      start in class org.testcontainers.containers.GenericContainer<SmileCdrContainer>
    • withBoundProjectClasspath

      Binds the target/classes and target/test-classes directories into the container's `/classes` directory. Only mounts directories if they exist and are non-empty.
      Returns:
      the SmileCdrContainer.
    • withPreseedFiles

      public SmileCdrContainer withPreseedFiles(String... filesToMount)
    • withCustomHarnessContext

    • withPropertiesFile

      public SmileCdrContainer withPropertiesFile(String thePropertiesFileLocation)
    • withCustomLogback

      public SmileCdrContainer withCustomLogback(String theCustomLogbackLocation)
    • withAllTroubleshootingLogsEnabled

    • withCustomerJars

      public SmileCdrContainer withCustomerJars(String... theJarNames)
      Specifies which JAR files from the cdr-interceptor-starterproject's target folder should be copied into the SmileCdrContainer at /home/smile/smilecdr/customerlib/.

      First looks in the classpath for a jar with a given name. If it does not find one, it also looks in the target/ directory. If it still doesn't find one, then it fails.

      Parameters:
      theJarNames - A comma-separated list of JAR filenames to copy. If null or empty, all JAR files in the target directory will be copied.
      Returns:
      This container instance for method chaining
    • withDebugEnabled

      Enables remote debugging for the Smile CDR instance running in this container. When enabled, the container will expose port 5005 (fixed mapping) and wait for a debugger to attach before completing startup (suspend=y).

      How to Connect IntelliJ IDEA Debugger:

      1. Run ? Edit Configurations ? Add New ? Remote JVM Debug
      2. Set Host: localhost (or container host)
      3. Set Port: 5005 (always fixed to this port)
      4. Set Debugger mode: Attach to remote JVM
      5. Click Debug - the container will resume startup once debugger connects

      Example Usage:

       
       @Container
       SmileCdrContainer container = new SmileCdrContainer()
           .withPropertiesFile("/my-config.properties")
           .withDebugEnabled();
      
       // Port 5005 is always used - no need to query for mapped port
       // Just connect your debugger to localhost:5005
       
       

      IMPORTANT: The container will pause during startup until a debugger connects. This is intentional to allow setting breakpoints before code execution begins. Port 5005 must be available on the host machine.

      Returns:
      This container instance for method chaining
    • withDebugEnabled

      public SmileCdrContainer withDebugEnabled(boolean theSuspendUntilDebuggerAttached)
      Enables remote debugging for the Smile CDR instance running in this container. When enabled, the container will expose port 5005 (fixed mapping). - If `theSuspendUntilDebuggerAttached` is true, the container will pause until a debugger is connected. - If `theSuspendUntilDebuggerAttached` is false, the container will boot without waiting for the debugger.

      How to Connect IntelliJ IDEA Debugger:

      1. Run ? Edit Configurations ? Add New ? Remote JVM Debug
      2. Set Host: localhost (or container host)
      3. Set Port: 5005 (always fixed to this port)
      4. Set Debugger mode: Attach to remote JVM
      5. Click Debug - the container will resume startup once debugger connects

      Example Usage:

       
       @Container
       SmileCdrContainer container = new SmileCdrContainer()
           .withPropertiesFile("/my-config.properties")
           .withDebugEnabled(false);
      
       // Port 5005 is always used - no need to query for mapped port
       // Just connect your debugger to localhost:5005
       
       

      IMPORTANT: If you have set `theSuspendUntilDebuggerAttached` to True, the container will pause during startup until a debugger connects. This is intentional to allow setting breakpoints before code execution begins. Port 5005 must be available on the host machine.

      Parameters:
      theSuspendUntilDebuggerAttached - if set to true, blocks the container startup until a debugger connects.
      Returns:
      This container instance for method chaining
    • getHarness

    • getPortMapping

    • getPortValuesByModuleType

      Gets the port values organized by Module Type and Module ID.
      Returns:
      A map where the key is the Module Type and the value is a map of Module ID to port