<dependency>
<groupId>com.avides.springboot.springtainer</groupId>
<artifactId>springtainer-mockserver</artifactId>
<version>2.0.0</version>
<scope>test</scope>
</dependency>Properties consumed (in bootstrap-it.properties):
embedded.container.mockserver.enabled(default istrue)embedded.container.mockserver.startup-timeout(default is30)embedded.container.mockserver.docker-image(default ismockserver/mockserver:mockserver-7.4.0)embedded.container.mockserver.server-port(default is1080)
Properties provided (in application-it.properties):
embedded.container.mockserver.hostembedded.container.mockserver.urlembedded.container.mockserver.server-port
Example for minimal configuration in application-it.properties:
rest.any-mock-subject.url=${embedded.container.mockserver.url}
A properly configured MockServerClient is available as bean.
spring.test.context.cache.maxSize=1 ships as a classpath spring.properties
resource inside springtainer-common itself, so it's picked up automatically for every consumer - no configuration
needed on your side. This bounds Spring's test-context cache so a no-longer-current context (and, via its
ContextClosedEvent listener, its embedded container) gets evicted and cleanly closed as soon as a differently-configured
context needs the slot, instead of piling up unclosed until the whole JVM exits.
This works the same way whether tests are launched via Maven Surefire/Failsafe or directly from an IDE's own test
runner (e.g. Eclipse), since Spring resolves it from the classpath (org.springframework.core.SpringProperties) rather
than from a JVM system property.
To reduce logging insert this into the logback-configuration:
<!-- Springtainer -->
<logger name="com.github.dockerjava" level="WARN" />The container exports multiple labels to analyze running springtainers:
SPRINGTAINER_SERVICE=mockserverSPRINGTAINER_IMAGE=${embedded.container.mockserver.docker-image}SPRINGTAINER_STARTED=$currentTimestamp