Class ClasspathHellDuplicatesCheckRule

  • All Implemented Interfaces:
    org.junit.rules.TestRule

    public class ClasspathHellDuplicatesCheckRule
    extends Object
    implements org.junit.rules.TestRule
    JUnit Rule to run detect duplicate entries on the classpath. Usage:
    public static @ClassRule ClasspathHellDuplicatesCheckRule
         dupes = new ClasspathHellDuplicatesCheckRule();

    NB that the basepom/duplicate-finder-maven-plugin already runs as part of odlparent. It has a similar purpose, but covers build time instead of runtime testing. This JUnit Rule class is thus recommended to be used in particular in tests which previously ran into JAR Hell issues, and for which non-regression with a clear failure message in case of future similar problems is important. (This provides more details at runtime than duplicate-finder-maven-plugin does at build time.)

    Author:
    Michael Vorburger.ch
    • Constructor Detail

      • ClasspathHellDuplicatesCheckRule

        public ClasspathHellDuplicatesCheckRule()
    • Method Detail

      • apply

        public org.junit.runners.model.Statement apply​(org.junit.runners.model.Statement base,
                                                       org.junit.runner.Description description)
        Specified by:
        apply in interface org.junit.rules.TestRule
      • checkClasspath

        protected void checkClasspath()