This plugin comes with some commented examples in the samples/ directory:
data-jolokia-demo is a setup for testing the Jolokia HTTP-JMX bridge in a tomcat. It uses a Docker data container which is linked into the Tomcat container and contains the WAR files to deply. There are two flavor of tests
-
One with two image where a (almost naked) data container with the war file is created and then mounted into the server image during startup before the integration test.
-
When using the profile
-Pmergethen a single image with Tomcat and the dependent war files is created. During startup of a container from the created image, a deploy script will link over the war files into Tomat so that they are automatically deployed.
For running the tests call
mvn clean install
mvn -Pmerge clean installThe sever used is by default Tomcat 7. This server can easily be
changed with the system properties server.name and
server.version. The following variants are available:
- For
server.name=tomcattheserver.versioncan be 3.3, 4.0, 5.5, 6.0, 7.0 or 8.0 - For
server.name=jettytheserver.versioncan be 4, 5, 6, 7, 8 or 9
Example:
mvn -Dserver.name=jetty -Dserver.version=9 clean installcargo-jolokia-demo will use Docker to start a Tomcat 7 server with dynamic port mapping, which is used for remote deployment via Cargo and running the integration tests.
In order to help in the decision, which plugin to use, there is a sample project rhuss/shootout-docker-maven, which has more complex sample project involving two images:
- Vanilla PostgreSQL 9 Image
- HTTP Request Logging Service
- MicroService mit embedded Tomcat
- DB Schema is created during startup vai Flyway
- PostgreSQL container is connected via a Docker 'link'
- Simple integration test which excercises the service
The different plugins can be enabled with different Maven profiles,
the one for this plugin is called rhuss (and the others wouterd,
alexec and spotify).
For more information please look over there.