Class ClasspathResourceSource
- java.lang.Object
-
- org.junit.platform.engine.support.descriptor.ClasspathResourceSource
-
- All Implemented Interfaces:
java.io.Serializable
,TestSource
@API(status=STABLE, since="1.0") public class ClasspathResourceSource extends java.lang.Object implements TestSource
Classpath resource basedTestSource
with an optional position.- Since:
- 1.0
- See Also:
ClasspathResourceSelector
, Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
CLASSPATH_SCHEME
URI
scheme for classpath resources: "classpath"private java.lang.String
classpathResourceName
private FilePosition
filePosition
private static long
serialVersionUID
-
Constructor Summary
Constructors Modifier Constructor Description private
ClasspathResourceSource(java.lang.String classpathResourceName)
private
ClasspathResourceSource(java.lang.String classpathResourceName, FilePosition filePosition)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object o)
static ClasspathResourceSource
from(java.lang.String classpathResourceName)
Create a newClasspathResourceSource
using the supplied classpath resource name.static ClasspathResourceSource
from(java.lang.String classpathResourceName, FilePosition filePosition)
Create a newClasspathResourceSource
using the supplied classpath resource name andFilePosition
.static ClasspathResourceSource
from(java.net.URI uri)
Create a newClasspathResourceSource
from the suppliedURI
.java.lang.String
getClasspathResourceName()
Get the name of the source classpath resource.java.util.Optional<FilePosition>
getPosition()
Get theFilePosition
, if available.int
hashCode()
java.lang.String
toString()
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
CLASSPATH_SCHEME
public static final java.lang.String CLASSPATH_SCHEME
URI
scheme for classpath resources: "classpath"- Since:
- 1.3
- See Also:
- Constant Field Values
-
classpathResourceName
private final java.lang.String classpathResourceName
-
filePosition
private final FilePosition filePosition
-
-
Constructor Detail
-
ClasspathResourceSource
private ClasspathResourceSource(java.lang.String classpathResourceName)
-
ClasspathResourceSource
private ClasspathResourceSource(java.lang.String classpathResourceName, FilePosition filePosition)
-
-
Method Detail
-
from
public static ClasspathResourceSource from(java.lang.String classpathResourceName)
Create a newClasspathResourceSource
using the supplied classpath resource name.The name of a classpath resource must follow the semantics for resource paths as defined in
ClassLoader.getResource(String)
.If the supplied classpath resource name is prefixed with a slash (
/
), the slash will be removed.- Parameters:
classpathResourceName
- the name of the classpath resource; nevernull
or blank- See Also:
ClassLoader.getResource(String)
,ClassLoader.getResourceAsStream(String)
,ClassLoader.getResources(String)
-
from
public static ClasspathResourceSource from(java.lang.String classpathResourceName, FilePosition filePosition)
Create a newClasspathResourceSource
using the supplied classpath resource name andFilePosition
.The name of a classpath resource must follow the semantics for resource paths as defined in
ClassLoader.getResource(String)
.If the supplied classpath resource name is prefixed with a slash (
/
), the slash will be removed.- Parameters:
classpathResourceName
- the name of the classpath resource; nevernull
or blankfilePosition
- the position in the classpath resource; may benull
-
from
public static ClasspathResourceSource from(java.net.URI uri)
Create a newClasspathResourceSource
from the suppliedURI
.The
path
component of theURI
(excluding the query) will be used as the classpath resource name. The query component of theURI
, if present, will be used to retrieve theFilePosition
viaFilePosition.fromQuery(String)
.- Parameters:
uri
- theURI
for the classpath resource; nevernull
- Returns:
- a new
ClasspathResourceSource
; nevernull
- Throws:
PreconditionViolationException
- if the suppliedURI
isnull
or if the scheme of the suppliedURI
is not equal to theCLASSPATH_SCHEME
- Since:
- 1.3
- See Also:
CLASSPATH_SCHEME
-
getClasspathResourceName
public java.lang.String getClasspathResourceName()
Get the name of the source classpath resource.The name of a classpath resource follows the semantics for resource paths as defined in
ClassLoader.getResource(String)
.- See Also:
ClassLoader.getResource(String)
,ClassLoader.getResourceAsStream(String)
,ClassLoader.getResources(String)
-
getPosition
public final java.util.Optional<FilePosition> getPosition()
Get theFilePosition
, if available.
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-