Class SmileCdrContainer
- All Implemented Interfaces:
AutoCloseable,org.testcontainers.containers.Container<SmileCdrContainer>,org.testcontainers.containers.ContainerState,org.testcontainers.containers.traits.LinkableContainer,org.testcontainers.containers.wait.strategy.WaitStrategyTarget,org.testcontainers.lifecycle.Startable
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, waitStrategyFields inherited from interface org.testcontainers.containers.ContainerState
STATE_HEALTHY -
Constructor Summary
ConstructorsConstructorDescriptionSmileCdrContainer(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 TypeMethodDescriptionReturns this container's harness, creating it on first call.Maps each port a module listens on inside the container to the port it is reachable on from the host.Gets the port values organized by Module Type and Module ID.Discards the cached harness and builds a replacement, which rediscovers the node's modules and ports.voidstart()voidstop()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/.withCustomHarnessContext(HarnessContext theHarnessContext) Sets theHarnessContextthe harness is built from.withCustomLogback(String theCustomLogbackLocation) withCustomLogback(Path theCustomLogbackFile) Uses a logback configuration from the host filesystem as the container'scustomerlib/logback-smile-custom.xml.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) Uses a properties file from the classpath as the container'scdr-config-Master.properties.withPropertiesFile(Path thePropertiesFile) Uses a properties file from the host filesystem as the container'scdr-config-Master.properties, for configuration that is generated or selected at runtime rather than packaged on the test classpath.Methods inherited from class org.testcontainers.containers.GenericContainer
addEnv, addExposedPort, addExposedPorts, addFileSystemBind, addFixedExposedPort, addFixedExposedPort, addLink, canBeReused, configure, containerIsCreated, containerIsStarted, containerIsStarted, containerIsStarting, containerIsStarting, containerIsStopped, containerIsStopping, copyFileFromContainer, createVolumeDirectory, dependsOn, dependsOn, dependsOn, doStart, equals, 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, 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, execInContainer, execInContainer, execInContainerWithUser, execInContainerWithUser, getBoundPortNumbers, getContainerIpAddress, getCurrentContainerInfo, getFirstMappedPort, getHost, getLogs, getLogs, getMappedPort, isCreated, isHealthy, isRunningMethods inherited from interface org.testcontainers.lifecycle.Startable
close
-
Constructor Details
-
SmileCdrContainer
public SmileCdrContainer() -
SmileCdrContainer
Use this constructor to change the version of Smile CDR, but use Smile's container registry. -
SmileCdrContainer
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
- Specified by:
startin interfaceorg.testcontainers.lifecycle.Startable- Overrides:
startin classorg.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
-
withCustomHarnessContext
@Nonnull public SmileCdrContainer withCustomHarnessContext(@Nonnull HarnessContext theHarnessContext) Sets theHarnessContextthe harness is built from. Discards any harness already handed out, so that a context set after the firstgetHarness()still takes effect rather than being silently ignored. -
withPropertiesFile
Uses a properties file from the classpath as the container'scdr-config-Master.properties. -
withPropertiesFile
Uses a properties file from the host filesystem as the container'scdr-config-Master.properties, for configuration that is generated or selected at runtime rather than packaged on the test classpath. -
withCustomLogback
-
withCustomLogback
Uses a logback configuration from the host filesystem as the container'scustomerlib/logback-smile-custom.xml. -
withAllTroubleshootingLogsEnabled
-
withCustomerJars
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:
- Run → Edit Configurations → Add New → Remote JVM Debug
- Set Host: localhost (or container host)
- Set Port: 5005 (always fixed to this port)
- Set Debugger mode: Attach to remote JVM
- 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:5005IMPORTANT: 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
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:
- Run → Edit Configurations → Add New → Remote JVM Debug
- Set Host: localhost (or container host)
- Set Port: 5005 (always fixed to this port)
- Set Debugger mode: Attach to remote JVM
- 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:5005IMPORTANT: 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
Returns this container's harness, creating it on first call.The harness is cached because it owns an HTTP connection pool and a cookie store: handing out a fresh one per call would mean each caller got its own session, which any multi-request login flow depends on sharing. The cached harness is closed and discarded when the container stops, so a restarted container gets a harness bound to its new port mapping.
A harness reads the node's modules and their ports once, when it is built. A test that adds, removes or re-ports a module through the Admin JSON API must therefore call
refreshHarness(); callinggetHarness()again returns the same harness, still holding the configuration from before the change.A harness a caller closed itself is replaced rather than handed back:
SmileHarnessisAutoCloseable, so a try-with-resources around this call would otherwise shut the connection pool and leave every later call returning a harness whose every request fails. -
refreshHarness
Discards the cached harness and builds a replacement, which rediscovers the node's modules and ports. Call this after changing module configuration through the Admin JSON API.Any session held by the old harness ends with it, and any reference still pointing at it is dead — use the returned harness rather than the one you were holding.
- Returns:
- the replacement harness, already bound to the node's current configuration
-
stop
- Specified by:
stopin interfaceorg.testcontainers.lifecycle.Startable- Overrides:
stopin classorg.testcontainers.containers.GenericContainer<SmileCdrContainer>
-
getPortMapping
Maps each port a module listens on inside the container to the port it is reachable on from the host. On the host network (withNetworkMode("host")) every port maps to itself. -
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
-