Class ElasticContainer.Builder

java.lang.Object
io.ebean.test.containers.ElasticContainer.Builder
All Implemented Interfaces:
ContainerBuilder<ElasticContainer,ElasticContainer.Builder>
Enclosing class:
ElasticContainer

public static class ElasticContainer.Builder extends Object
Builder for ElasticContainer.
  • Field Details

    • platform

      protected final String platform
      The database platform.

      Expected to be one of 'postgres','mysql', 'oracle' or 'sqlserver'.

    • containerName

      protected String containerName
      Container name.
    • host

      protected String host
      The host name. When running in Docker this is often set to 172.17.0.1invalid input: '<'/code.
    • port

      protected int port
      The exposed port.
    • internalPort

      protected int internalPort
      The internal port.
    • adminPort

      protected int adminPort
      The exposed port.
    • adminInternalPort

      protected int adminInternalPort
      The internal port.
    • mirror

      protected String mirror
      Define a mirror for images to use with CI builds.
    • image

      protected String image
      Image name.
    • startMode

      protected StartMode startMode
      The mode used when starting (create, dropCreate, container [only]).
    • shutdownMode

      protected StopMode shutdownMode
      By default, via JVM shutdown hook stop and remove the container unless there is a ~/.ebean/ignore-docker-shutdown marker file.
    • maxReadyAttempts

      protected int maxReadyAttempts
      Maximum number of attempts to find the 'database ready to accept connections' log message in the container.

      100 attempts equates to 10 seconds.

    • docker

      protected String docker
      Docker command.
    • version

      protected final String version
  • Method Details

    • build

      public ElasticContainer build()
      Description copied from interface: ContainerBuilder
      Build the container.
    • start

      public ElasticContainer start()
      Description copied from interface: ContainerBuilder
      Build and start the container.
    • docker

      protected String docker()
    • getHost

      protected String getHost()
    • getPort

      protected int getPort()
    • self

      protected ElasticContainer.Builder self()
    • startMode

      public ElasticContainer.Builder startMode(StartMode startMode)
      Description copied from interface: ContainerBuilder
      Set the start mode. One of create, dropCreate, or container [only].
      Specified by:
      startMode in interface ContainerBuilder<C,SELF extends io.ebean.test.containers.BaseBuilder<C,SELF>>
    • shutdownMode

      public ElasticContainer.Builder shutdownMode(StopMode shutdownMode)
      Description copied from interface: ContainerBuilder
      Set the shutdown hook mode to automatically stop/remove the container on JVM shutdown.
      Specified by:
      shutdownMode in interface ContainerBuilder<C,SELF extends io.ebean.test.containers.BaseBuilder<C,SELF>>
    • properties

      public ElasticContainer.Builder properties(Properties properties)
      Load configuration from properties.
      Specified by:
      properties in interface ContainerBuilder<C,SELF extends io.ebean.test.containers.BaseBuilder<C,SELF>>
    • extraProperties

      protected void extraProperties(Properties properties)
      Override to configure extra properties.
    • prop

      protected String prop(Properties properties, String key, String defaultValue)
    • prop

      protected int prop(Properties properties, String key, int defaultValue)
    • containerName

      public ElasticContainer.Builder containerName(String containerName)
      Set the container name.
      Specified by:
      containerName in interface ContainerBuilder<C,SELF extends io.ebean.test.containers.BaseBuilder<C,SELF>>
    • mirror

      public ElasticContainer.Builder mirror(String mirror)
      Set a container mirror for images to use with CI builds.

      For example "my.ecr/mirror".

      The mirror is not used when deemed to be running locally. Typically determined via a ~/.ebean/ignore-docker-shutdown file or alternative marker file set via system property ebean.test.localDevelopment>.

      Specified by:
      mirror in interface ContainerBuilder<C,SELF extends io.ebean.test.containers.BaseBuilder<C,SELF>>
    • port

      public ElasticContainer.Builder port(int port)
      Set the exposed port with 0 meaning use a random port.

      When the port is set to `0` then docker will assign a random port. This port is available after the container has started.

      
      
        LocalstackContainer container = LocalstackContainer.builder("0.14")
          .port(0)
          .build();
      
        container.start();
      
        int assignedPort = container.port();
      
        AmazonDynamoDB amazonDynamoDB = container.dynamoDB();
      
       
      Specified by:
      port in interface ContainerBuilder<C,SELF extends io.ebean.test.containers.BaseBuilder<C,SELF>>
    • internalPort

      public ElasticContainer.Builder internalPort(int internalPort)
      Set the internal (to the container) port.
      Specified by:
      internalPort in interface ContainerBuilder<C,SELF extends io.ebean.test.containers.BaseBuilder<C,SELF>>
    • adminPort

      public ElasticContainer.Builder adminPort(int adminPort)
      Set the exposed admin port.
      Specified by:
      adminPort in interface ContainerBuilder<C,SELF extends io.ebean.test.containers.BaseBuilder<C,SELF>>
    • adminInternalPort

      public ElasticContainer.Builder adminInternalPort(int adminInternalPort)
      Set the internal admin (to the container) port.
      Specified by:
      adminInternalPort in interface ContainerBuilder<C,SELF extends io.ebean.test.containers.BaseBuilder<C,SELF>>
    • image

      public ElasticContainer.Builder image(String image)
      Set the docker image to use.
      Specified by:
      image in interface ContainerBuilder<C,SELF extends io.ebean.test.containers.BaseBuilder<C,SELF>>
    • maxReadyAttempts

      public ElasticContainer.Builder maxReadyAttempts(int maxReadyAttempts)
      Set the max attempts to wait for DB ready.
      Specified by:
      maxReadyAttempts in interface ContainerBuilder<C,SELF extends io.ebean.test.containers.BaseBuilder<C,SELF>>
    • docker

      public ElasticContainer.Builder docker(String docker)
      Set the docker command to use (defaults to 'docker').
      Specified by:
      docker in interface ContainerBuilder<C,SELF extends io.ebean.test.containers.BaseBuilder<C,SELF>>
    • internalConfig

      protected io.ebean.test.containers.InternalConfig internalConfig()
      Return the internal configuration.
    • buildJdbcUrl

      protected String buildJdbcUrl()
      Override to build appropriate jdbc url.
    • buildExtraJdbcUrl

      protected String buildExtraJdbcUrl()
      Override to build jdbc url for extraDb.
    • buildJdbcAdminUrl

      protected String buildJdbcAdminUrl()