Class LocalstackContainer

java.lang.Object
io.ebean.test.containers.LocalstackContainer
All Implemented Interfaces:
Container<LocalstackContainer>

public class LocalstackContainer extends Object
Localstack container support.


     LocalstackContainer container = LocalstackContainer.builder("0.14")
       // .port(4566)
       // .image("localstack/localstack:0.14")
       .build();

     container.start();

     AmazonDynamoDB amazonDynamoDB = container.dynamoDB();
     createTable(amazonDynamoDB);

 
  • Field Details

    • buildConfig

      protected final io.ebean.test.containers.BaseBuilder<?,?> buildConfig
    • config

      protected io.ebean.test.containers.InternalConfig config
    • commands

      protected final Commands commands
    • waitForConnectivityAttempts

      protected int waitForConnectivityAttempts
    • shutdownMode

      protected StopMode shutdownMode
    • usingContainerId

      protected boolean usingContainerId
    • usingRandomPort

      protected boolean usingRandomPort
    • removeOnExit

      protected boolean removeOnExit
  • Constructor Details

  • Method Details

    • start

      public LocalstackContainer start()
      Description copied from interface: Container
      Start and return the container.

      Throws an IllegalStateException if the container can not be started.

    • builder

      public static LocalstackContainer.Builder builder(String version)
      Create a builder for LocalstackContainer given the localstack image version.
    • newBuilder

      @Deprecated public static LocalstackContainer.Builder newBuilder(String version)
      Deprecated.
      Deprecated - migrate to builder().
    • dynamoDB

      public com.amazonaws.services.dynamodbv2.AmazonDynamoDB dynamoDB()
      Return the AmazonDynamoDB (V1 SDK) that can be used for this container.

      This should be used AFTER the container is started.

    • kinesis

      public com.amazonaws.services.kinesis.AmazonKinesis kinesis()
      Return AmazonKinesis (V1 SDK) that can be used for this container.

      This should be used AFTER the container is started.

    • sns

      public com.amazonaws.services.sns.AmazonSNS sns()
      Return the AmazonSNS (V1 SDK) client for this container.
    • sqs

      public com.amazonaws.services.sqs.AmazonSQS sqs()
      Return the AmazonSQS (V1 SDK) client for this container.
    • sdk2

      public AwsSDKv2 sdk2()
      Return the AWS v2 SDK compatible helper that provides API for DynamoDB client, SNSClient, SQQClient etc.
    • sdk1

      public AwsSDKv1 sdk1()
      Return the AWS v1 SDK compatible helper that provides API for AmazonDynamoDB client, AmazonSNS, AmazonSQS etc.
    • endpoint

      public URI endpoint()
    • endpointUrl

      public String endpointUrl()
    • awsRegion

      public String awsRegion()
    • runProcess

      protected ProcessBuilder runProcess()
      Return the ProcessBuilder used to execute the container run command.
    • config

      public ContainerConfig config()
      Description copied from interface: Container
      Returns the container configuration.
      Specified by:
      config in interface Container<C extends Container<C>>
    • startMaybe

      public boolean startMaybe()
      Description copied from interface: Container
      Start the container returning true if successful.
      Specified by:
      startMaybe in interface Container<C extends Container<C>>
    • startOrThrow

      public void startOrThrow()
      Description copied from interface: Container
      Start the container or throw a IllegalStateException.
      Specified by:
      startOrThrow in interface Container<C extends Container<C>>
    • port

      public int port()
      Description copied from interface: Container
      Return the port this container is using.

      This is typically useful if the container was started with a random port and, we need to know what that port was.

      Specified by:
      port in interface Container<C extends Container<C>>
    • setDefaultContainerName

      protected void setDefaultContainerName()
      Set a default container name if not using random port.
    • isRunning

      public boolean isRunning()
      Description copied from interface: Container
      Return true if the container is running.
      Specified by:
      isRunning in interface Container<C extends Container<C>>
    • registerShutdownHook

      public void registerShutdownHook()
      Register a JVM Shutdown hook to stop the container with the given mode.
    • shutdownHook

      protected boolean shutdownHook(boolean started)
    • startWithConnectivity

      protected boolean startWithConnectivity()
    • stop

      public void stop()
      Stop using the configured stopMode of 'stop' or 'remove'.

      Remove additionally removes the container (expected use in build agents).

      Specified by:
      stop in interface Container<C extends Container<C>>
    • stopRemove

      public void stopRemove()
      Stop and remove the container effectively deleting the container.
      Specified by:
      stopRemove in interface Container<C extends Container<C>>
    • createProcessBuilder

      protected ProcessBuilder createProcessBuilder(List<String> args)
    • dockerRun

      protected List<String> dockerRun()
    • readUrlContent

      protected String readUrlContent(String url) throws IOException
      Return http GET content given the url.
      Throws:
      IOException