Class TestContainers


  • public final class TestContainers
    extends java.lang.Object
    An utility class used to manage the lifecycle of test containers. We preserve the list of open containers in-memory in a static field, because we want them to live as long as the VM is live. It is possible to explicitly shutdown all containers by calling the closeAll() method.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void closeAll()  
      static void closeScope​(java.lang.String id)  
      static java.util.List<org.testcontainers.containers.GenericContainer<?>> findByRequestedProperty​(io.micronaut.testresources.core.Scope scope, java.lang.String property)  
      static java.util.Map<java.lang.String,​org.testcontainers.containers.Network> getNetworks()  
      static java.util.Map<io.micronaut.testresources.core.Scope,​java.util.List<org.testcontainers.containers.GenericContainer<?>>> listAll()
      Lists all containers.
      static java.util.Map<io.micronaut.testresources.core.Scope,​java.util.List<org.testcontainers.containers.GenericContainer<?>>> listByScope​(java.lang.String id)  
      static org.testcontainers.containers.Network network​(java.lang.String name)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • listAll

        public static java.util.Map<io.micronaut.testresources.core.Scope,​java.util.List<org.testcontainers.containers.GenericContainer<?>>> listAll()
        Lists all containers.
        Returns:
        the containers
      • listByScope

        public static java.util.Map<io.micronaut.testresources.core.Scope,​java.util.List<org.testcontainers.containers.GenericContainer<?>>> listByScope​(java.lang.String id)
      • network

        public static org.testcontainers.containers.Network network​(java.lang.String name)
      • closeAll

        public static void closeAll()
      • getNetworks

        public static java.util.Map<java.lang.String,​org.testcontainers.containers.Network> getNetworks()
      • closeScope

        public static void closeScope​(java.lang.String id)
      • findByRequestedProperty

        public static java.util.List<org.testcontainers.containers.GenericContainer<?>> findByRequestedProperty​(io.micronaut.testresources.core.Scope scope,
                                                                                                                java.lang.String property)