Class GenericTestContainerProvider

  • All Implemented Interfaces:
    io.micronaut.core.order.Ordered, io.micronaut.testresources.core.TestResourcesResolver

    public class GenericTestContainerProvider
    extends java.lang.Object
    implements io.micronaut.testresources.core.TestResourcesResolver
    A generic test containers provider. This provider is special in the sense that it requires user provided configuration in order to spawn containers. Therefore, the application configuration must contain entries under the "test-resources.containers" property prefix. A generic container is represented with a name, a container image, and exposes a number of ports. For example, imagine that a service requires an SMTP server to work property. Then it is likely that some configuration property needs to point to the server port. If that property is smtp.port, then it is possible to expose a test container which will resolve that property using the following configuration:
     test-resources:
       containers:
         fakesmtp:
           image-name: ghusta/fakesmtp:2.0
           hostnames:
             - smtp.host
           exposed-ports:
             - smtp.port: 25
     
    The mapped port from test containers will then be automatically be assigned to the smtp.port property, and the host name of the running test container will automatically be assigned to the smtp.host property.
    • Field Summary

      • Fields inherited from interface io.micronaut.core.order.Ordered

        HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
      • Fields inherited from interface io.micronaut.testresources.core.TestResourcesResolver

        TEST_RESOURCES_PROPERTY
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int getOrder()  
      java.util.List<java.lang.String> getResolvableProperties​(java.util.Map<java.lang.String,​java.util.Collection<java.lang.String>> propertyEntries, java.util.Map<java.lang.String,​java.lang.Object> testResourcesConfig)  
      java.util.Optional<java.lang.String> resolve​(java.lang.String propertyName, java.util.Map<java.lang.String,​java.lang.Object> properties, java.util.Map<java.lang.String,​java.lang.Object> testResourcesConfiguration)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface io.micronaut.testresources.core.TestResourcesResolver

        getRequiredProperties, getRequiredPropertyEntries
    • Constructor Detail

      • GenericTestContainerProvider

        public GenericTestContainerProvider()
    • Method Detail

      • getOrder

        public int getOrder()
        Specified by:
        getOrder in interface io.micronaut.core.order.Ordered
      • getResolvableProperties

        public java.util.List<java.lang.String> getResolvableProperties​(java.util.Map<java.lang.String,​java.util.Collection<java.lang.String>> propertyEntries,
                                                                        java.util.Map<java.lang.String,​java.lang.Object> testResourcesConfig)
        Specified by:
        getResolvableProperties in interface io.micronaut.testresources.core.TestResourcesResolver
      • resolve

        public java.util.Optional<java.lang.String> resolve​(java.lang.String propertyName,
                                                            java.util.Map<java.lang.String,​java.lang.Object> properties,
                                                            java.util.Map<java.lang.String,​java.lang.Object> testResourcesConfiguration)
        Specified by:
        resolve in interface io.micronaut.testresources.core.TestResourcesResolver