I am building a complex server (tomcat) structure via assembly, containing libs, deployments, datasource settings ...
I would like to test the contents of the dir/zip before deployment making sure that everything is there, in the right location and with the correct filtered properties.
How can I apply (unit) tests that analyse the dir and assert that certain files exists and have the correct content?
I would suggest to to create an integration test which runs after the package phase. This can handled via the maven-failsafe-plugin which can be bound to integration-test
phase. You need of course follow the naming conventions of the maven-failsafe-plugin.
To access the generated file you can use a system property which is given to maven-failsafe-plugin configuration. Like:
<systemPropertyVariables>
<fileName>${project.build.finalName}</fileName>
<folder>${project.build.outputDirectory}</folder>
</systemPropertyVariables>
This will give the whole file name of the resulting artifact if you using a separate module to create those distribution artifact. I'm not 100% sure what about the classifier which is created based on the <id>..</id>
in the assembly descriptor file.
The folder
will give you the location where the artifacts are being created.
You might also being interested in the following plugin.