Class DiscoverySelectors

    • Method Detail

      • selectClasspathRoots

        public static List<ClasspathRootSelector> selectClasspathRoots​(Set<Path> classpathRoots)
        Create a list of ClasspathRootSelectors for the supplied classpath roots (directories or JAR files).

        Since the supplied paths are converted to URIs, the FileSystem that created them must be the default or one that has been created by an installed FileSystemProvider.

        Since engines are not expected to modify the classpath, the classpath roots represented by the resulting selectors must be on the classpath of the context class loader of the thread that uses these selectors.

        Parameters:
        classpathRoots - set of directories and JAR files in the filesystem that represent classpath roots; never null
        Returns:
        a list of selectors for the supplied classpath roots; elements which do not physically exist in the filesystem will be filtered out
        See Also:
        ClasspathRootSelector, Thread.getContextClassLoader()
      • selectModule

        @API(status=EXPERIMENTAL,
             since="1.1")
        public static ModuleSelector selectModule​(String moduleName)
        Create a ModuleSelector for the supplied module name.

        The unnamed module is not supported.

        Parameters:
        moduleName - the module name to select; never null or blank
        Since:
        1.1
        See Also:
        ModuleSelector
      • selectModules

        @API(status=EXPERIMENTAL,
             since="1.1")
        public static List<ModuleSelector> selectModules​(Set<String> moduleNames)
        Create a list of ModuleSelectors for the supplied module names.

        The unnamed module is not supported.

        Parameters:
        moduleNames - the module names to select; never null, never containing null or blank
        Since:
        1.1
        See Also:
        ModuleSelector
      • selectPackage

        public static PackageSelector selectPackage​(String packageName)
        Create a PackageSelector for the supplied package name.

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

        Parameters:
        packageName - the package name to select; never null and never containing whitespace only
        See Also:
        PackageSelector
      • selectClass

        public static ClassSelector selectClass​(Class<?> clazz)
        Create a ClassSelector for the supplied Class.
        Parameters:
        clazz - the class to select; never null
        See Also:
        ClassSelector
      • selectClass

        public static ClassSelector selectClass​(String className)
        Create a ClassSelector for the supplied class name.
        Parameters:
        className - the fully qualified name of the class to select; never null or blank
        See Also:
        ClassSelector
      • selectMethod

        public static MethodSelector selectMethod​(String fullyQualifiedMethodName)
                                           throws PreconditionViolationException
        Create a MethodSelector for the supplied fully qualified method name.

        The following formats are supported.

        • [fully qualified class name]#[methodName]
        • [fully qualified class name]#[methodName](parameter type list)

        The parameter type list is a comma-separated list of primitive names or fully qualified class names for the types of parameters accepted by the method.

        Array parameter types may be specified using either the JVM's internal String representation (e.g., [[I for int[][], [Ljava.lang.String; for java.lang.String[], etc.) or source code syntax (e.g., int[][], java.lang.String[], etc.).

        Examples

        MethodFully Qualified Method Name
        java.lang.String.chars()java.lang.String#chars
        java.lang.String.chars()java.lang.String#chars()
        java.lang.String.equalsIgnoreCase(String)java.lang.String#equalsIgnoreCase(java.lang.String)
        java.lang.String.substring(int, int)java.lang.String#substring(int, int)
        example.Calc.avg(int[])example.Calc#avg([I)
        example.Calc.avg(int[])example.Calc#avg(int[])
        example.Matrix.multiply(double[][])example.Matrix#multiply([[D)
        example.Matrix.multiply(double[][])example.Matrix#multiply(double[][])
        example.Service.process(String[])example.Service#process([Ljava.lang.String;)
        example.Service.process(String[])example.Service#process(java.lang.String[])
        example.Service.process(String[][])example.Service#process([[Ljava.lang.String;)
        example.Service.process(String[][])example.Service#process(java.lang.String[][])
        Parameters:
        fullyQualifiedMethodName - the fully qualified name of the method to select; never null or blank
        Throws:
        PreconditionViolationException
        See Also:
        MethodSelector
      • selectMethod

        public static MethodSelector selectMethod​(String className,
                                                  String methodName)
        Create a MethodSelector for the supplied class name and method name.
        Parameters:
        className - the fully qualified name of the class in which the method is declared, or a subclass thereof; never null or blank
        methodName - the name of the method to select; never null or blank
        See Also:
        MethodSelector
      • selectMethod

        public static MethodSelector selectMethod​(String className,
                                                  String methodName,
                                                  String methodParameterTypes)
        Create a MethodSelector for the supplied class name, method name, and method parameter types.

        The parameter types String is typically a comma-separated list of atomic types, fully qualified class names, or array types; however, the exact syntax depends on the underlying test engine.

        Parameters:
        className - the fully qualified name of the class in which the method is declared, or a subclass thereof; never null or blank
        methodName - the name of the method to select; never null or blank
        methodParameterTypes - the method parameter types as a single string; never null though potentially an empty string if the method does not accept arguments
        See Also:
        MethodSelector
      • selectMethod

        public static MethodSelector selectMethod​(Class<?> javaClass,
                                                  String methodName)
        Create a MethodSelector for the supplied Class and method name.
        Parameters:
        javaClass - the class in which the method is declared, or a subclass thereof; never null
        methodName - the name of the method to select; never null or blank
        See Also:
        MethodSelector
      • selectMethod

        public static MethodSelector selectMethod​(Class<?> javaClass,
                                                  String methodName,
                                                  String methodParameterTypes)
        Create a MethodSelector for the supplied Class, method name, and method parameter types.

        The parameter types String is typically a comma-separated list of atomic types, fully qualified class names, or array types; however, the exact syntax depends on the underlying test engine.

        Parameters:
        javaClass - the class in which the method is declared, or a subclass thereof; never null
        methodName - the name of the method to select; never null or blank
        methodParameterTypes - the method parameter types as a single string; never null though potentially an empty string if the method does not accept arguments
        See Also:
        MethodSelector
      • selectMethod

        public static MethodSelector selectMethod​(Class<?> javaClass,
                                                  Method method)
        Create a MethodSelector for the supplied Class and Method.
        Parameters:
        javaClass - the class in which the method is declared, or a subclass thereof; never null
        method - the method to select; never null
        See Also:
        MethodSelector
      • selectUniqueId

        public static UniqueIdSelector selectUniqueId​(String uniqueId)
        Create a UniqueIdSelector for the supplied unique ID.
        Parameters:
        uniqueId - the unique ID to select; never null or blank
        See Also:
        UniqueIdSelector