Class OracleContainer

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

public class OracleContainer extends OracleFreeContainer<OracleContainer>
Testcontainers implementation for the official Oracle AI Database Free image.

The image provides the SYS, SYSTEM, and PDBADMIN accounts. This container creates a TEST application user in FREEPDB1 by default.

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

Exposed port: 1521

  • Nested Class Summary

    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 role granted to the application user.
    static final String
    Default image tag.
    static final String
    Default application user.

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

    Modifier and Type
    Method
    Description
    protected void
     
     
     
     
     
    Uses a SID-style connection to FREE as SYSTEM instead of connecting to the FREEPDB1 service.
    withAdminPassword(String adminPassword)
    Sets the password used by administrative accounts.
    Replaces the roles granted to the application user.
    withCharacterSet(String characterSet)
    Configures the database character set.
    withDatabaseName(String databaseName)
     
    withPassword(String password)
    Sets the administrator password used by a container without an application-user mode.
    withUrlParam(String paramName, String paramValue)
     
    withUsername(String username)
     

    Methods inherited from class org.testcontainers.containers.JdbcDatabaseContainer

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

    Methods inherited from class org.testcontainers.containers.GenericContainer

    addEnv, addExposedPort, addExposedPorts, addFileSystemBind, addFixedExposedPort, addFixedExposedPort, addLink, canBeReused, containerIsCreated, 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, 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

  • Constructor Details

    • OracleContainer

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

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

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

    • configure

      protected void configure()
      Overrides:
      configure in class OracleFreeContainer<OracleContainer>
    • getJdbcUrl

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

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

      public String getPassword()
      Overrides:
      getPassword in class OracleFreeContainer<OracleContainer>
    • getDatabaseName

      public String getDatabaseName()
      Overrides:
      getDatabaseName in class org.testcontainers.containers.JdbcDatabaseContainer<OracleContainer>
    • withUsername

      public OracleContainer withUsername(String username)
      Overrides:
      withUsername in class org.testcontainers.containers.JdbcDatabaseContainer<OracleContainer>
    • withPassword

      public OracleContainer withPassword(String password)
      Description copied from class: OracleFreeContainer
      Sets the administrator password used by a container without an application-user mode.
      Overrides:
      withPassword in class OracleFreeContainer<OracleContainer>
    • withAdminPassword

      public OracleContainer withAdminPassword(String adminPassword)
      Sets the password used by administrative accounts.
      Overrides:
      withAdminPassword in class OracleFreeContainer<OracleContainer>
      Parameters:
      adminPassword - administrator password
      Returns:
      this container
    • withAppUserRoles

      public OracleContainer withAppUserRoles(String... roles)
      Replaces the roles granted to the application user.

      Role names are normalized to uppercase, validated as unquoted Oracle identifiers, and deduplicated. The application user always receives the CREATE SESSION system privilege. Pass no roles to grant only that privilege.

      Parameters:
      roles - application-user roles
      Returns:
      this container
    • withDatabaseName

      public OracleContainer withDatabaseName(String databaseName)
      Overrides:
      withDatabaseName in class org.testcontainers.containers.JdbcDatabaseContainer<OracleContainer>
    • usingSid

      public OracleContainer usingSid()
      Uses a SID-style connection to FREE as SYSTEM instead of connecting to the FREEPDB1 service.
      Returns:
      this container
    • withCharacterSet

      public OracleContainer withCharacterSet(String characterSet)
      Configures the database character set.
      Parameters:
      characterSet - Oracle character set name
      Returns:
      this container
    • withUrlParam

      public OracleContainer withUrlParam(String paramName, String paramValue)
      Overrides:
      withUrlParam in class org.testcontainers.containers.JdbcDatabaseContainer<OracleContainer>