You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by zh...@apache.org on 2026/10/15 03:44:10 UTC

(hbase) branch branch-2.6 updated: HBASE-30452 Exclude JUnit libraries from shaded testing util (#8769)

This is an automated email from the ASF dual-hosted git repository.

Apache9 pushed a commit to branch branch-2.6
in repository https://gitbox.apache.org/repos/asf/hbase.git


The following commit(s) were added to refs/heads/branch-2.6 by this push:
     new 98824f154bb HBASE-30452 Exclude JUnit libraries from shaded testing util (#8769)
98824f154bb is described below

commit 98824f154bbb0d48ec8b6a55bec7ef5e312239e4
Author: Ma Zhengxuan <49...@users.noreply.github.com>
AuthorDate: Thu Oct 15 10:20:53 2026 +0800

    HBASE-30452 Exclude JUnit libraries from shaded testing util (#8769)
    
    Signed-off-by: Duo Zhang <zh...@apache.org>
    Signed-off-by: Xiao Liu <li...@apache.org>
    (cherry picked from commit 7e946dfa404b88df71f5044663029af4c1c388d0)
---
 .../shaded/TestShadedTestingUtilJarContents.java   | 54 ++++++++++++++++++++++
 hbase-shaded/hbase-shaded-testing-util/pom.xml     |  6 +++
 2 files changed, 60 insertions(+)

diff --git a/hbase-shaded/hbase-shaded-testing-util-tester/src/test/java/org/apache/hbase/shaded/TestShadedTestingUtilJarContents.java b/hbase-shaded/hbase-shaded-testing-util-tester/src/test/java/org/apache/hbase/shaded/TestShadedTestingUtilJarContents.java
new file mode 100644
index 00000000000..b7279d2c62f
--- /dev/null
+++ b/hbase-shaded/hbase-shaded-testing-util-tester/src/test/java/org/apache/hbase/shaded/TestShadedTestingUtilJarContents.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hbase.shaded;
+
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
+import java.io.File;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import org.apache.hadoop.hbase.HBaseTestingUtility;
+import org.apache.hadoop.hbase.testclassification.ClientTests;
+import org.apache.hadoop.hbase.testclassification.SmallTests;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+
+@Tag(ClientTests.TAG)
+@Tag(SmallTests.TAG)
+public class TestShadedTestingUtilJarContents {
+
+  @Test
+  public void testNoBundledJUnitLibraries() throws Exception {
+    File path = new File(
+      HBaseTestingUtility.class.getProtectionDomain().getCodeSource().getLocation().toURI());
+    try (JarFile jar = new JarFile(path)) {
+      JarEntry unexpectedEntry = jar.stream().filter(entry -> {
+        String name = entry.getName();
+        return name.startsWith("META-INF/services/org.junit.platform.") || name.endsWith(".class")
+          && (name.startsWith("org/junit/") && !name.equals("org/junit/Assert.class")
+            || name.startsWith("org/opentest4j/") || name.startsWith("org/apiguardian/")
+            || name.matches("META-INF/versions/[0-9]+/org/junit/.*"));
+      }).findFirst().orElse(null);
+      assertNull(unexpectedEntry, () -> "Unexpected bundled entry: " + unexpectedEntry);
+      // HBase's JUnit 4 shim is needed by bundled Hadoop test utilities.
+      assertNotNull(jar.getEntry("org/junit/Assert.class"));
+      assertNotNull(jar.getEntry("META-INF/services/org.junit.jupiter.api.extension.Extension"));
+    }
+  }
+}
diff --git a/hbase-shaded/hbase-shaded-testing-util/pom.xml b/hbase-shaded/hbase-shaded-testing-util/pom.xml
index bb7c919dabe..e3102b67fd5 100644
--- a/hbase-shaded/hbase-shaded-testing-util/pom.xml
+++ b/hbase-shaded/hbase-shaded-testing-util/pom.xml
@@ -138,6 +138,12 @@
                   <exclude>org.javassist:*</exclude>
                   <exclude>io.opentelemetry:*</exclude>
                   <exclude>io.opentelemetry.semconv:*</exclude>
+                  <!-- The test runner must provide a consistent JUnit version. -->
+                  <exclude>junit:junit</exclude>
+                  <exclude>org.junit.jupiter:*</exclude>
+                  <exclude>org.junit.platform:*</exclude>
+                  <exclude>org.opentest4j:opentest4j</exclude>
+                  <exclude>org.apiguardian:apiguardian-api</exclude>
                 </excludes>
               </artifactSet>
             </configuration>