This is an automated email from the ASF dual-hosted git repository.
liuxiaocs pushed a commit to branch branch-2.5
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/branch-2.5 by this push:
new c3c836f11b4 HBASE-29996 Backport the
HBaseParameterizedTemplateProvider changes in HBASE-29966 to branch-2.5 (#7935)
c3c836f11b4 is described below
commit c3c836f11b4e067d80fc238c76bb12ac39a50503
Author: Xiao Liu <[email protected]>
AuthorDate: Sat Mar 14 02:21:07 2026 +0800
HBASE-29996 Backport the HBaseParameterizedTemplateProvider changes in
HBASE-29966 to branch-2.5 (#7935)
Signed-off-by: Duo Zhang <[email protected]>
---
.../hbase/HBaseParameterizedTemplateProvider.java | 33 ++++++++++++++++------
1 file changed, 25 insertions(+), 8 deletions(-)
diff --git
a/hbase-common/src/test/java/org/apache/hadoop/hbase/HBaseParameterizedTemplateProvider.java
b/hbase-common/src/test/java/org/apache/hadoop/hbase/HBaseParameterizedTemplateProvider.java
index 90ec0d0d1a6..01632233f31 100644
---
a/hbase-common/src/test/java/org/apache/hadoop/hbase/HBaseParameterizedTemplateProvider.java
+++
b/hbase-common/src/test/java/org/apache/hadoop/hbase/HBaseParameterizedTemplateProvider.java
@@ -27,6 +27,8 @@ import org.junit.jupiter.api.extension.ExtensionContext;
import org.junit.jupiter.api.extension.TestTemplateInvocationContext;
import org.junit.jupiter.api.extension.TestTemplateInvocationContextProvider;
import org.junit.jupiter.params.provider.Arguments;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* The entry point class for supporting JUnit4 like Parameterized test, where
we can use constructor
@@ -48,6 +50,9 @@ import org.junit.jupiter.params.provider.Arguments;
@InterfaceAudience.Private
public class HBaseParameterizedTemplateProvider implements
TestTemplateInvocationContextProvider {
+ private static final Logger LOG =
+ LoggerFactory.getLogger(HBaseParameterizedTemplateProvider.class);
+
private static final String PARAMETERS_METHOD_NAME = "parameters";
@Override
@@ -56,19 +61,31 @@ public class HBaseParameterizedTemplateProvider implements
TestTemplateInvocatio
.map(c ->
c.isAnnotationPresent(HBaseParameterizedTestTemplate.class)).orElse(false);
}
+ private Method findParametersMethod(final Class<?> testClass) {
+ Class<?> clazz = testClass;
+ for (;;) {
+ try {
+ return clazz.getDeclaredMethod(PARAMETERS_METHOD_NAME);
+ } catch (NoSuchMethodException e) {
+ Class<?> parentClass = clazz.getSuperclass();
+ LOG.debug("Can not find method {} in class {}, try its parent class
{}",
+ PARAMETERS_METHOD_NAME, clazz, parentClass);
+ if (parentClass == null) {
+ throw new ExtensionConfigurationException("Can not find a static "
+ + PARAMETERS_METHOD_NAME + " method in class " + testClass + "or
its super classes");
+ }
+ clazz = parentClass;
+ }
+ }
+
+ }
+
@Override
public Stream<TestTemplateInvocationContext>
provideTestTemplateInvocationContexts(ExtensionContext context) {
Class<?> testClass = context.getRequiredTestClass();
// get parameters
- Method method;
- try {
- method = testClass.getDeclaredMethod(PARAMETERS_METHOD_NAME);
- } catch (NoSuchMethodException e) {
- throw new ExtensionConfigurationException(
- "Test class must declare static " + PARAMETERS_METHOD_NAME + "
method");
- }
-
+ Method method = findParametersMethod(testClass);
if (!Modifier.isStatic(method.getModifiers())) {
throw new ExtensionConfigurationException(PARAMETERS_METHOD_NAME + "
method must be static");
}