This plugin comes with some commented examples in the
data-jolokia 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 deploy. 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
# Use two ("data" and "server") connected containers mvn clean install # Use a single image with tomcat and data: mvn -Pmerge clean install # Use a property based configuration: mvn -Pprops clean install
The sever used is by default Tomcat 7. This server can easily be
changed with the system properties
server.version. The following variants are available:
server.versioncan be 3.3, 4.0, 5.5, 6.0, 7.0 or 8.0
server.versioncan be 4, 5, 6, 7, 8 or 9
mvn -Dserver.name=jetty -Dserver.version=9 clean install
In addition to running the integration test with building images, starting containers, running tests and stopping containers one can also only start the containers:
In order to get the dynamically exposed port, use
docker ps. You can connect to the
Jolokia agent inside the container then with an URL like
For stopping the server simply call
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 with embedded Tomcat
- DB Schema is created during startup via Flyway
- PostgreSQL container is connected via a Docker 'link'
- Simple integration test which exercises the service
The different plugins can be enabled with different Maven profiles,
the one for this plugin is called
fabric8io (and the others
For more information please look over there.