Class PackagingTestUtils


  • public class PackagingTestUtils
    extends Object
    Test utils around jar packaging.
    • Constructor Detail

      • PackagingTestUtils

        public PackagingTestUtils()
    • Method Detail

      • assertJarContainsOnlyFilesMatching

        public static void assertJarContainsOnlyFilesMatching​(Path jarPath,
                                                              Collection<String> allowedPaths)
                                                       throws Exception
        Verifies that all files in the jar match one of the provided allow strings.

        An allow item ending on a "/" is treated as an allowed parent directory. Otherwise, it is treated as an allowed file.

        For example, given a jar containing a file META-INF/NOTICES:

        These would pass:

        • "META-INF/"
        • "META-INF/NOTICES"

        These would fail:

        • "META-INF"
        • "META-INF/NOTICE"
        • "META-INF/NOTICES/"
        Throws:
        Exception
      • assertJarContainsServiceEntry

        public static void assertJarContainsServiceEntry​(Path jarPath,
                                                         Class<?> service)
                                                  throws Exception
        Verifies that the given jar contains a service entry file for the given service.

        Caution: This only checks that the file exists; the content is not verified.

        Throws:
        Exception