|
|
|
|
@ -53,8 +53,7 @@ import org.springframework.util.StringUtils;
@@ -53,8 +53,7 @@ import org.springframework.util.StringUtils;
|
|
|
|
|
class TestBeanOverrideProcessor implements BeanOverrideProcessor { |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Find a test bean factory {@link Method} in the given {@link Class} or one |
|
|
|
|
* of its parent classes. |
|
|
|
|
* Find a test bean factory {@link Method} for the given {@link Class}. |
|
|
|
|
* <p>Delegates to {@link #findTestBeanFactoryMethod(Class, Class, List)}. |
|
|
|
|
*/ |
|
|
|
|
static Method findTestBeanFactoryMethod(Class<?> clazz, Class<?> methodReturnType, String... methodNames) { |
|
|
|
|
@ -62,19 +61,21 @@ class TestBeanOverrideProcessor implements BeanOverrideProcessor {
@@ -62,19 +61,21 @@ class TestBeanOverrideProcessor implements BeanOverrideProcessor {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Find a test bean factory {@link Method} in the given {@link Class} or one |
|
|
|
|
* of its parent classes, which meets the following criteria. |
|
|
|
|
* Find a test bean factory {@link Method} for the given {@link Class}, which |
|
|
|
|
* meets the following criteria. |
|
|
|
|
* <ul> |
|
|
|
|
* <li>The method is static.</li> |
|
|
|
|
* <li>The method does not accept any arguments.</li> |
|
|
|
|
* <li>The method's return type matches the supplied {@code methodReturnType}.</li> |
|
|
|
|
* <li>The method's name is one of the supplied {@code methodNames}.</li> |
|
|
|
|
* </ul> |
|
|
|
|
* <p>If the test class inherits from another class, the class hierarchy is |
|
|
|
|
* searched for factory methods. Matching factory methods are prioritized |
|
|
|
|
* from closest to farthest from the test class in the class hierarchy, |
|
|
|
|
* provided they have the same name. However, if multiple methods are found |
|
|
|
|
* that match distinct candidate names, an exception is thrown. |
|
|
|
|
* <p>This method traverses up the type hierarchy of the given class in search |
|
|
|
|
* of the factory method, beginning with the class itself and then searching |
|
|
|
|
* implemented interfaces and superclasses. If a factory method is not found |
|
|
|
|
* in the type hierarchy, this method will also search on the enclosing class
|
|
|
|
|
* if the class is a nested class. |
|
|
|
|
* <p>If multiple factory methods are found that match the search criteria, |
|
|
|
|
* an exception is thrown. |
|
|
|
|
* @param clazz the class in which to search for the factory method |
|
|
|
|
* @param methodReturnType the return type for the factory method |
|
|
|
|
* @param methodNames a set of supported names for the factory method |
|
|
|
|
|