Class MethodSource
- java.lang.Object
-
- org.junit.platform.engine.support.descriptor.MethodSource
-
- All Implemented Interfaces:
java.io.Serializable,TestSource
@API(status=STABLE, since="1.0") public class MethodSource extends java.lang.Object implements TestSourceMethod basedTestSource.This class stores the method name along with the names of its parameter types because
Methoddoes not implementSerializable.- Since:
- 1.0
- See Also:
MethodSelector, Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.StringclassNameprivate java.lang.Class<?>javaClassprivate java.lang.reflect.MethodjavaMethodprivate java.lang.StringmethodNameprivate java.lang.StringmethodParameterTypesprivate static longserialVersionUID
-
Constructor Summary
Constructors Modifier Constructor Description privateMethodSource(java.lang.Class<?> testClass, java.lang.reflect.Method testMethod)privateMethodSource(java.lang.reflect.Method testMethod)privateMethodSource(java.lang.String className, java.lang.String methodName)privateMethodSource(java.lang.String className, java.lang.String methodName, java.lang.String methodParameterTypes)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object o)static MethodSourcefrom(java.lang.Class<?> testClass, java.lang.reflect.Method testMethod)Create a newMethodSourceusing the suppliedclassandmethod.static MethodSourcefrom(java.lang.reflect.Method testMethod)Create a newMethodSourceusing the suppliedmethod.static MethodSourcefrom(java.lang.String className, java.lang.String methodName)Create a newMethodSourceusing the supplied class name and method name.static MethodSourcefrom(java.lang.String className, java.lang.String methodName, java.lang.Class<?>... methodParameterTypes)Create a newMethodSourceusing the supplied class name, method name, and method parameter types.static MethodSourcefrom(java.lang.String className, java.lang.String methodName, java.lang.String methodParameterTypes)Create a newMethodSourceusing the supplied class name, method name, and method parameter types.java.lang.StringgetClassName()Get the class name of this source.java.lang.Class<?>getJavaClass()Get the Java class of this source.java.lang.reflect.MethodgetJavaMethod()Get the Java method of this source.java.lang.StringgetMethodName()Get the method name of this source.java.lang.StringgetMethodParameterTypes()Get the method parameter types of this source.inthashCode()private voidlazyLoadJavaClass()private voidlazyLoadJavaMethod()java.lang.StringtoString()
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
className
private final java.lang.String className
-
methodName
private final java.lang.String methodName
-
methodParameterTypes
private final java.lang.String methodParameterTypes
-
javaClass
private java.lang.Class<?> javaClass
-
javaMethod
private transient java.lang.reflect.Method javaMethod
-
-
Constructor Detail
-
MethodSource
private MethodSource(java.lang.String className, java.lang.String methodName)
-
MethodSource
private MethodSource(java.lang.String className, java.lang.String methodName, java.lang.String methodParameterTypes)
-
MethodSource
private MethodSource(java.lang.reflect.Method testMethod)
-
MethodSource
private MethodSource(java.lang.Class<?> testClass, java.lang.reflect.Method testMethod)- Since:
- 1.3
-
-
Method Detail
-
from
public static MethodSource from(java.lang.String className, java.lang.String methodName)
Create a newMethodSourceusing the supplied class name and method name.- Parameters:
className- the class name; must not benullor blankmethodName- the method name; must not benullor blank
-
from
public static MethodSource from(java.lang.String className, java.lang.String methodName, java.lang.String methodParameterTypes)
Create a newMethodSourceusing the supplied class name, method name, and method parameter types.- Parameters:
className- the class name; must not benullor blankmethodName- the method name; must not benullor blankmethodParameterTypes- a comma-separated list of fully qualified class names representing the method parameter types
-
from
@API(status=STABLE, since="1.5") public static MethodSource from(java.lang.String className, java.lang.String methodName, java.lang.Class<?>... methodParameterTypes)Create a newMethodSourceusing the supplied class name, method name, and method parameter types.- Parameters:
className- the class name; must not benullor blankmethodName- the method name; must not benullor blankmethodParameterTypes- a varargs array of classes representing the method parameter types- Since:
- 1.5
-
from
public static MethodSource from(java.lang.reflect.Method testMethod)
Create a newMethodSourceusing the suppliedmethod.- Parameters:
testMethod- the Java method; must not benull- See Also:
from(Class, Method)
-
from
@API(status=STABLE, since="1.3") public static MethodSource from(java.lang.Class<?> testClass, java.lang.reflect.Method testMethod)Create a newMethodSourceusing the suppliedclassandmethod.This method should be used in favor of
from(Method)if the test method is inherited from a superclass or present as an interfacedefaultmethod.- Parameters:
testClass- the Java class; must not benulltestMethod- the Java method; must not benull- Since:
- 1.3
-
getClassName
public java.lang.String getClassName()
Get the class name of this source.
-
getMethodName
public final java.lang.String getMethodName()
Get the method name of this source.
-
getMethodParameterTypes
public final java.lang.String getMethodParameterTypes()
Get the method parameter types of this source.
-
getJavaClass
@API(status=STABLE, since="1.7") public final java.lang.Class<?> getJavaClass()Get the Java class of this source.If the
Classwas not provided, but only the name, this method attempts to lazily load theClassbased on its name and throws aPreconditionViolationExceptionif the class cannot be loaded.- Since:
- 1.7
- See Also:
getClassName()
-
getJavaMethod
@API(status=STABLE, since="1.7") public final java.lang.reflect.Method getJavaMethod()Get the Java method of this source.If the
Methodwas not provided, but only the name, this method attempts to lazily load theMethodbased on its name and throws aPreconditionViolationExceptionif the method cannot be loaded.- Since:
- 1.7
- See Also:
getMethodName()
-
lazyLoadJavaClass
private void lazyLoadJavaClass()
-
lazyLoadJavaMethod
private void lazyLoadJavaMethod()
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-