Class ADBContainer

java.lang.Object
org.testcontainers.containers.GenericContainer<ADBContainer>
org.testcontainers.containers.JdbcDatabaseContainer<ADBContainer>
com.oracle.spring.testcontainers.ADBContainer
All Implemented Interfaces:
AutoCloseable, org.testcontainers.containers.Container<ADBContainer>, org.testcontainers.containers.ContainerState, org.testcontainers.containers.traits.LinkableContainer, org.testcontainers.containers.wait.strategy.WaitStrategyTarget, org.testcontainers.lifecycle.Startable

public class ADBContainer extends org.testcontainers.containers.JdbcDatabaseContainer<ADBContainer>
Testcontainers implementation for the official Oracle Autonomous AI Database Free image.

The container starts an Autonomous Transaction Processing (ATP) database by default. It configures the image's required SYS_ADMIN capability and /dev/fuse device access.

Clients connect with the TLS wallet generated by the image. The wallet is available at "/u01/app/oracle/wallets/tls_wallet"; the container manages a local copy for the standard JdbcDatabaseContainer.createConnection(String) JDBC operations.

Supported image: container-registry.oracle.com/database/adb-free

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final class 
    Handle for wallet files copied from an ADB Free container.
    static enum 
    Supported Autonomous AI Database Free workload types.

    Nested classes/interfaces inherited from class org.testcontainers.containers.JdbcDatabaseContainer

    org.testcontainers.containers.JdbcDatabaseContainer.NoDriverFoundException

    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 String
    Default image tag for the current multi-architecture image.
    static final int
    Oracle REST Data Services HTTPS port.
    static final String
    Official Oracle Autonomous AI Database Free container image.
    static final int
    MongoDB API port.
    static final int
    Mutual TLS database listener port inside the container.
    static final int
    TLS database listener port inside the container.
    static final String
    Location of the TLS wallet generated at container startup.

    Fields inherited from class org.testcontainers.containers.JdbcDatabaseContainer

    parameters, urlParameters

    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
    Creates a container using the official image and default tag.
    ADBContainer(String dockerImageName)
    Creates a container using an image name.
    ADBContainer(org.testcontainers.utility.DockerImageName dockerImageName)
    Creates a container using a parsed image name.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
     
    protected void
    containerIsStopped(com.github.dockerjava.api.command.InspectContainerResponse containerInfo)
     
    copyWalletTo(Path destination)
    Copies the generated client wallet to a local directory and updates its tnsnames.ora entries for this container's mapped host ports.
    createConnection(String queryString, Properties info)
     
    Returns the initial Autonomous AI Database name.
     
    Returns the mapped Oracle REST Data Services HTTPS port.
    Returns a JDBC URL using the database's mTLS service alias.
    Returns the mapped MongoDB API port.
    Returns the mapped mutual TLS database listener port.
    Returns the medium-service mutual TLS alias for the initial database.
     
    protected String
     
    Returns the mapped TLS database listener port.
    Returns the medium-service TLS alias for the initial database.
     
    Returns the wallet managed by this container for JDBC connections.
    protected void
     
    withAdminPassword(String adminPassword)
    Configures the mandatory database administrator password.
    withAppUser(String username, String password)
    Configures an optional application user to create after the database is ready.
    Replaces the roles granted to the configured application user.
    withArchiveLog(boolean enabled)
    Enables or disables archive logging in the initial Autonomous AI Database.
    withDatabaseName(String databaseName)
    Configures the name of the initial Autonomous AI Database.
    withPassword(String password)
    Configures the password used by the standard JDBC container operations.
    withUsername(String username)
    Selects the username used by the standard JDBC container operations.
    withWalletPassword(String walletPassword)
    Configures the mandatory password used to generate the client TLS wallet.
    Configures the Autonomous Database workload started by the image.

    Methods inherited from class org.testcontainers.containers.JdbcDatabaseContainer

    addParameter, constructUrlForConnection, constructUrlParameters, constructUrlParameters, containerIsStarted, createConnection, getConnectTimeoutSeconds, getDatabaseDelegate, getJdbcDriverInstance, getStartupTimeoutSeconds, optionallyMapResourceParameterAsVolume, optionallyMapResourceParameterAsVolume, runInitScriptIfRequired, setParameters, withConnectTimeoutSeconds, withInitScript, withInitScripts, withInitScripts, withStartupTimeoutSeconds, withUrlParam

    Methods inherited from class org.testcontainers.containers.GenericContainer

    addEnv, addExposedPort, addExposedPorts, addFileSystemBind, addFixedExposedPort, addFixedExposedPort, addLink, canBeReused, containerIsCreated, containerIsStarted, containerIsStarting, containerIsStarting, 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, start, stop, toString, waitingFor, 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 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.containers.traits.LinkableContainer

    getContainerName

    Methods inherited from interface org.testcontainers.lifecycle.Startable

    close
  • Field Details

    • IMAGE_NAME

      public static final String IMAGE_NAME
      Official Oracle Autonomous AI Database Free container image.
      See Also:
    • DEFAULT_TAG

      public static final String DEFAULT_TAG
      Default image tag for the current multi-architecture image.
      See Also:
    • TLS_PORT

      public static final int TLS_PORT
      TLS database listener port inside the container.
      See Also:
    • MTLS_PORT

      public static final int MTLS_PORT
      Mutual TLS database listener port inside the container.
      See Also:
    • HTTPS_PORT

      public static final int HTTPS_PORT
      Oracle REST Data Services HTTPS port.
      See Also:
    • MONGODB_API_PORT

      public static final int MONGODB_API_PORT
      MongoDB API port.
      See Also:
    • TLS_WALLET_PATH

      public static final String TLS_WALLET_PATH
      Location of the TLS wallet generated at container startup.
      See Also:
  • Constructor Details

    • ADBContainer

      public ADBContainer()
      Creates a container using the official image and default tag.
    • ADBContainer

      public ADBContainer(String dockerImageName)
      Creates a container using an image name.
      Parameters:
      dockerImageName - compatible Oracle Autonomous AI Database Free image name
    • ADBContainer

      public ADBContainer(org.testcontainers.utility.DockerImageName dockerImageName)
      Creates a container using a parsed image name.
      Parameters:
      dockerImageName - compatible Oracle Autonomous AI Database Free image name
  • Method Details

    • withWorkloadType

      public ADBContainer withWorkloadType(ADBContainer.WorkloadType workloadType)
      Configures the Autonomous Database workload started by the image.
      Parameters:
      workloadType - ATP or ADW
      Returns:
      this container
    • withDatabaseName

      public ADBContainer withDatabaseName(String databaseName)
      Configures the name of the initial Autonomous AI Database.

      When unset, the image creates MYATP or MYADW, based on the selected workload type.

      Overrides:
      withDatabaseName in class org.testcontainers.containers.JdbcDatabaseContainer<ADBContainer>
      Parameters:
      databaseName - alphanumeric database name
      Returns:
      this container
    • withAdminPassword

      public ADBContainer withAdminPassword(String adminPassword)
      Configures the mandatory database administrator password.
      Parameters:
      adminPassword - administrator password for the initial Autonomous Database
      Returns:
      this container
    • withWalletPassword

      public ADBContainer withWalletPassword(String walletPassword)
      Configures the mandatory password used to generate the client TLS wallet.
      Parameters:
      walletPassword - TLS wallet password
      Returns:
      this container
    • withArchiveLog

      public ADBContainer withArchiveLog(boolean enabled)
      Enables or disables archive logging in the initial Autonomous AI Database.
      Parameters:
      enabled - whether archive logging is enabled
      Returns:
      this container
    • withAppUser

      public ADBContainer withAppUser(String username, String password)
      Configures an optional application user to create after the database is ready. The user always receives CREATE SESSION; add database roles with withAppUserRoles(String...).
      Parameters:
      username - application user name
      password - application user password
      Returns:
      this container
    • withUsername

      public ADBContainer withUsername(String username)
      Selects the username used by the standard JDBC container operations.

      The administrator account is always available. An application user can be configured separately with withAppUser(String, String) or by following this method with withPassword(String).

      Overrides:
      withUsername in class org.testcontainers.containers.JdbcDatabaseContainer<ADBContainer>
      Parameters:
      username - administrator or configured application username
      Returns:
      this container
    • withPassword

      public ADBContainer withPassword(String password)
      Configures the password used by the standard JDBC container operations.

      When the administrator is selected, this is equivalent to withAdminPassword(String). When an application user is selected, it replaces that user's password.

      Overrides:
      withPassword in class org.testcontainers.containers.JdbcDatabaseContainer<ADBContainer>
      Parameters:
      password - password for the selected JDBC username
      Returns:
      this container
    • withAppUserRoles

      public ADBContainer withAppUserRoles(String... roles)
      Replaces the roles granted to the configured application user.
      Parameters:
      roles - application-user roles
      Returns:
      this container
    • getDatabaseName

      public String getDatabaseName()
      Returns the initial Autonomous AI Database name.
      Overrides:
      getDatabaseName in class org.testcontainers.containers.JdbcDatabaseContainer<ADBContainer>
      Returns:
      configured database name, or the workload-specific image default
    • getJdbcUrl

      public String getJdbcUrl()
      Returns a JDBC URL using the database's mTLS service alias.

      The generated wallet is supplied automatically by JdbcDatabaseContainer.createConnection(String).

      Specified by:
      getJdbcUrl in class org.testcontainers.containers.JdbcDatabaseContainer<ADBContainer>
      Returns:
      JDBC URL for the initial database
    • getDriverClassName

      public String getDriverClassName()
      Specified by:
      getDriverClassName in class org.testcontainers.containers.JdbcDatabaseContainer<ADBContainer>
    • getUsername

      public String getUsername()
      Specified by:
      getUsername in class org.testcontainers.containers.JdbcDatabaseContainer<ADBContainer>
    • getPassword

      public String getPassword()
      Specified by:
      getPassword in class org.testcontainers.containers.JdbcDatabaseContainer<ADBContainer>
    • getWallet

      public ADBContainer.Wallet getWallet()
      Returns the wallet managed by this container for JDBC connections.

      Call this after the container has started. The container closes the wallet when it stops; callers must not close the returned handle.

      Returns:
      managed wallet
      Throws:
      IllegalStateException - if the container has not started
    • getTlsPort

      public Integer getTlsPort()
      Returns the mapped TLS database listener port.
      Returns:
      mapped TLS port
    • getMtlsPort

      public Integer getMtlsPort()
      Returns the mapped mutual TLS database listener port.
      Returns:
      mapped mutual TLS port
    • getHttpsPort

      public Integer getHttpsPort()
      Returns the mapped Oracle REST Data Services HTTPS port.
      Returns:
      mapped HTTPS port
    • getMongoDbApiPort

      public Integer getMongoDbApiPort()
      Returns the mapped MongoDB API port.
      Returns:
      mapped MongoDB API port
    • getMtlsServiceAlias

      public String getMtlsServiceAlias()
      Returns the medium-service mutual TLS alias for the initial database.
      Returns:
      mutual TLS service alias
    • getTlsServiceAlias

      public String getTlsServiceAlias()
      Returns the medium-service TLS alias for the initial database.
      Returns:
      TLS service alias
    • copyWalletTo

      public ADBContainer.Wallet copyWalletTo(Path destination) throws IOException
      Copies the generated client wallet to a local directory and updates its tnsnames.ora entries for this container's mapped host ports.

      Call this after the container has started. Configure JDBC with the returned directory as oracle.net.tns_admin, then use getMtlsServiceAlias() or getTlsServiceAlias().

      Parameters:
      destination - local directory that receives the wallet files
      Returns:
      an auto-closeable wallet handle for the destination directory
      Throws:
      IOException - if wallet files cannot be written
    • createConnection

      public Connection createConnection(String queryString, Properties info) throws SQLException, org.testcontainers.containers.JdbcDatabaseContainer.NoDriverFoundException
      Overrides:
      createConnection in class org.testcontainers.containers.JdbcDatabaseContainer<ADBContainer>
      Throws:
      SQLException
      org.testcontainers.containers.JdbcDatabaseContainer.NoDriverFoundException
    • waitUntilContainerStarted

      protected void waitUntilContainerStarted()
      Overrides:
      waitUntilContainerStarted in class org.testcontainers.containers.JdbcDatabaseContainer<ADBContainer>
    • containerIsStopped

      protected void containerIsStopped(com.github.dockerjava.api.command.InspectContainerResponse containerInfo)
      Overrides:
      containerIsStopped in class org.testcontainers.containers.GenericContainer<ADBContainer>
    • configure

      protected void configure()
      Overrides:
      configure in class org.testcontainers.containers.GenericContainer<ADBContainer>
    • getTestQueryString

      protected String getTestQueryString()
      Specified by:
      getTestQueryString in class org.testcontainers.containers.JdbcDatabaseContainer<ADBContainer>