TestPackage provides a clean way to package your functional tests and run them as a jar file with sharding and package level run options. All that we need to do is created a maven/gradle subproject for functional tests and have the testpackage’s dependency and manifest file entry to get an executable jar package.
Once the jar is created all we need to do is run ‘java -jar the-test-package.jar package.that.contain.tests’. This helps a lot in continuous delivery where the functional test artifact can be created at the build stage and promoted to run at the functional test stage without having to access the source code and rebuild later.
In one of the spring web applications we decided to use Log4J2 with SLF4J; when we deployed the web app in tomcat server along with the required jars we stumbled on the issue multiple binding for SLF4J and spring dependencies not getting satisfied. We had used Gradle and there were transitive dependencies which included log4j-12xx.jar and slf4j-log4j.jar as some of the dependencies in the project were using log4j version 1 for logging. Here is how we were able to start logging using log4j2.
Exclude the log4j-12xx.jar and slf4j-log modules from the gradle build
all*.exclude group: "org.slf4j", module: "slf4j-log4j12"
all*.exclude group: "log4j", module: "log4j"
Add the following jars
org.slf4j:log4j-over-slf4j|route all the log4j v1 to slf4j
Add the log4j2.xml configurations to the classpath or as specified at log4j manual