Class PackageUtils

  • @API(status=INTERNAL,
    public final class PackageUtils
    extends Object
    Collection of utilities for working with packages.


    These utilities are intended solely for usage within the JUnit framework itself. Any usage by external parties is not supported. Use at your own risk!

    • Method Detail

      • assertPackageNameIsValid

        public static void assertPackageNameIsValid​(String packageName)
        Assert that the supplied package name is valid in terms of Java syntax.

        Note: this method does not actually verify if the named package exists in the classpath.

        The default package is represented by an empty string ("").

        packageName - the package name to validate
        PreconditionViolationException - if the supplied package name is null, contains only whitespace, or contains parts that are not valid in terms of Java syntax (e.g., containing keywords such as void, import, etc.)
        See Also:
      • getAttribute

        public static Optional<String> getAttribute​(Class<?> type,
                                                    String name)
        Get the value of the specified attribute name, specified as a string, or an empty Optional if the attribute was not found. The attribute name is case-insensitive.

        This method also returns an empty Optional value holder if any exception is caught while loading the manifest file via the JAR file of the specified type.

        type - the type to get the attribute for
        name - the attribute name as a string
        an Optional containing the attribute value; never null but potentially empty
        PreconditionViolationException - if the supplied type is null or the specified name is blank
        See Also: