Class 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
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 ClassesModifier and TypeClassDescriptionstatic final classHandle for wallet files copied from an ADB Free container.static enumSupported Autonomous AI Database Free workload types.Nested classes/interfaces inherited from class org.testcontainers.containers.JdbcDatabaseContainer
org.testcontainers.containers.JdbcDatabaseContainer.NoDriverFoundExceptionNested classes/interfaces inherited from interface org.testcontainers.containers.Container
org.testcontainers.containers.Container.ExecResult -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringDefault image tag for the current multi-architecture image.static final intOracle REST Data Services HTTPS port.static final StringOfficial Oracle Autonomous AI Database Free container image.static final intMongoDB API port.static final intMutual TLS database listener port inside the container.static final intTLS database listener port inside the container.static final StringLocation of the TLS wallet generated at container startup.Fields inherited from class org.testcontainers.containers.JdbcDatabaseContainer
parameters, urlParametersFields 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
ConstructorsConstructorDescriptionCreates 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 TypeMethodDescriptionprotected voidprotected voidcontainerIsStopped(com.github.dockerjava.api.command.InspectContainerResponse containerInfo) copyWalletTo(Path destination) Copies the generated client wallet to a local directory and updates itstnsnames.oraentries 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 StringReturns 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 voidwithAdminPassword(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.withAppUserRoles(String... roles) 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.withWorkloadType(ADBContainer.WorkloadType workloadType) 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, withUrlParamMethods 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, withWorkingDirectoryMethods 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.containers.traits.LinkableContainer
getContainerNameMethods inherited from interface org.testcontainers.lifecycle.Startable
close
-
Field Details
-
IMAGE_NAME
Official Oracle Autonomous AI Database Free container image.- See Also:
-
DEFAULT_TAG
Default image tag for the current multi-architecture image.- See Also:
-
TLS_PORT
public static final int TLS_PORTTLS database listener port inside the container.- See Also:
-
MTLS_PORT
public static final int MTLS_PORTMutual TLS database listener port inside the container.- See Also:
-
HTTPS_PORT
public static final int HTTPS_PORTOracle REST Data Services HTTPS port.- See Also:
-
MONGODB_API_PORT
public static final int MONGODB_API_PORTMongoDB API port.- See Also:
-
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
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
Configures the Autonomous Database workload started by the image.- Parameters:
workloadType- ATP or ADW- Returns:
- this container
-
withDatabaseName
Configures the name of the initial Autonomous AI Database.When unset, the image creates
MYATPorMYADW, based on the selected workload type.- Overrides:
withDatabaseNamein classorg.testcontainers.containers.JdbcDatabaseContainer<ADBContainer>- Parameters:
databaseName- alphanumeric database name- Returns:
- this container
-
withAdminPassword
Configures the mandatory database administrator password.- Parameters:
adminPassword- administrator password for the initial Autonomous Database- Returns:
- this container
-
withWalletPassword
Configures the mandatory password used to generate the client TLS wallet.- Parameters:
walletPassword- TLS wallet password- Returns:
- this container
-
withArchiveLog
Enables or disables archive logging in the initial Autonomous AI Database.- Parameters:
enabled- whether archive logging is enabled- Returns:
- this container
-
withAppUser
Configures an optional application user to create after the database is ready. The user always receivesCREATE SESSION; add database roles withwithAppUserRoles(String...).- Parameters:
username- application user namepassword- application user password- Returns:
- this container
-
withUsername
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 withwithPassword(String).- Overrides:
withUsernamein classorg.testcontainers.containers.JdbcDatabaseContainer<ADBContainer>- Parameters:
username- administrator or configured application username- Returns:
- this container
-
withPassword
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:
withPasswordin classorg.testcontainers.containers.JdbcDatabaseContainer<ADBContainer>- Parameters:
password- password for the selected JDBC username- Returns:
- this container
-
withAppUserRoles
Replaces the roles granted to the configured application user.- Parameters:
roles- application-user roles- Returns:
- this container
-
getDatabaseName
Returns the initial Autonomous AI Database name.- Overrides:
getDatabaseNamein classorg.testcontainers.containers.JdbcDatabaseContainer<ADBContainer>- Returns:
- configured database name, or the workload-specific image default
-
getJdbcUrl
Returns a JDBC URL using the database's mTLS service alias.The generated wallet is supplied automatically by
JdbcDatabaseContainer.createConnection(String).- Specified by:
getJdbcUrlin classorg.testcontainers.containers.JdbcDatabaseContainer<ADBContainer>- Returns:
- JDBC URL for the initial database
-
getDriverClassName
- Specified by:
getDriverClassNamein classorg.testcontainers.containers.JdbcDatabaseContainer<ADBContainer>
-
getUsername
- Specified by:
getUsernamein classorg.testcontainers.containers.JdbcDatabaseContainer<ADBContainer>
-
getPassword
- Specified by:
getPasswordin classorg.testcontainers.containers.JdbcDatabaseContainer<ADBContainer>
-
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
-
getMtlsPort
Returns the mapped mutual TLS database listener port.- Returns:
- mapped mutual TLS port
-
getHttpsPort
Returns the mapped Oracle REST Data Services HTTPS port.- Returns:
- mapped HTTPS port
-
getMongoDbApiPort
Returns the mapped MongoDB API port.- Returns:
- mapped MongoDB API port
-
getMtlsServiceAlias
Returns the medium-service mutual TLS alias for the initial database.- Returns:
- mutual TLS service alias
-
getTlsServiceAlias
Returns the medium-service TLS alias for the initial database.- Returns:
- TLS service alias
-
copyWalletTo
Copies the generated client wallet to a local directory and updates itstnsnames.oraentries 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 usegetMtlsServiceAlias()orgetTlsServiceAlias().- 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:
createConnectionin classorg.testcontainers.containers.JdbcDatabaseContainer<ADBContainer>- Throws:
SQLExceptionorg.testcontainers.containers.JdbcDatabaseContainer.NoDriverFoundException
-
waitUntilContainerStarted
protected void waitUntilContainerStarted()- Overrides:
waitUntilContainerStartedin classorg.testcontainers.containers.JdbcDatabaseContainer<ADBContainer>
-
containerIsStopped
protected void containerIsStopped(com.github.dockerjava.api.command.InspectContainerResponse containerInfo) - Overrides:
containerIsStoppedin classorg.testcontainers.containers.GenericContainer<ADBContainer>
-
configure
protected void configure()- Overrides:
configurein classorg.testcontainers.containers.GenericContainer<ADBContainer>
-
getTestQueryString
- Specified by:
getTestQueryStringin classorg.testcontainers.containers.JdbcDatabaseContainer<ADBContainer>
-