Class ClasspathResourceSelector
- All Implemented Interfaces:
DiscoverySelector
DiscoverySelector that selects the name of a classpath resource
so that TestEngines can load resources
from the classpath — for example, to load XML or JSON files from the classpath,
potentially within JARs.
Since engines are not expected to modify the classpath, the classpath resource represented by this selector must be on the classpath of the context class loader of the thread that uses it.
Note: Since Java 9, all resources are on the module path. Either in named or unnamed modules. These resources are also considered to be classpath resources.
- Since:
- 1.0
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class -
Method Summary
Modifier and TypeMethodDescriptionbooleanGet the name of the selected classpath resource.Get the selectedresources.Get the selectedFilePositionwithin the classpath resource.inthashCode()Return the identifier of this selector.toString()
-
Method Details
-
getClasspathResourceName
Get the name of the selected classpath resource.The name of a classpath resource must follow the semantics for resource paths as defined in
ClassLoader.getResource(String).- See Also:
-
getClasspathResources
Get the selectedresources.If the
resourceswere not provided, but only their name, this method attempts to lazily load theresourcesbased on their name and throws aPreconditionViolationExceptionif the resource cannot be loaded.- Since:
- 1.12
-
getPosition
Get the selectedFilePositionwithin the classpath resource. -
equals
-
hashCode
-
toString
-
toIdentifier
Description copied from interface:DiscoverySelectorReturn the identifier of this selector.The returned identifier must be parsable by a corresponding
DiscoverySelectorIdentifierParser.The default implementation returns
Optional.empty(). Can be overridden by concrete implementations.- Specified by:
toIdentifierin interfaceDiscoverySelector- Returns:
- an
Optionalcontaining the identifier of this selector; nevernullbut potentially empty if the selector does not support identifiers
-