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

liuxiaocs7 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 0f2d6f96cf4 HBASE-30191 Upgrade hbase-testing-util to use junit5 
(#8305)
0f2d6f96cf4 is described below

commit 0f2d6f96cf4e69280295fff605a39b5739a15ee5
Author: Xiao Liu <[email protected]>
AuthorDate: Wed Jun 3 14:42:32 2026 +0800

    HBASE-30191 Upgrade hbase-testing-util to use junit5 (#8305)
    
    Signed-off-by: Duo Zhang <[email protected]>
    
    (cherry picked from commit 035192f727155fd6b3b05affd7da0acabd65acab)
    (cherry picked from commit f20203e410d23d36cb7c22904bcdfec20f1e8686)
---
 hbase-testing-util/pom.xml                         | 15 +++++++++
 .../hadoop/hbase/TestHBaseTestingUtilSpinup.java   | 28 ++++++----------
 .../hbase/testing/TestTestingHBaseCluster.java     | 37 ++++++++++------------
 .../testing/TestTestingHBaseClusterImplForCPs.java | 27 +++++++---------
 ...TestTestingHBaseClusterReplicationShareDfs.java | 13 +++-----
 .../TestTestingHBaseClusterReplicationShareZk.java | 13 +++-----
 ...stTestingHBaseClusterReplicationShareZkDfs.java | 13 +++-----
 ...tTestingHBaseClusterReplicationTwoClusters.java | 11 ++-----
 .../TestingHBaseClusterReplicationTestBase.java    | 12 +++----
 9 files changed, 73 insertions(+), 96 deletions(-)

diff --git a/hbase-testing-util/pom.xml b/hbase-testing-util/pom.xml
index 9eee689406a..cac453e8b8e 100644
--- a/hbase-testing-util/pom.xml
+++ b/hbase-testing-util/pom.xml
@@ -133,6 +133,21 @@
       <artifactId>mockito-core</artifactId>
       <scope>compile</scope>
     </dependency>
+    <dependency>
+      <groupId>org.junit.jupiter</groupId>
+      <artifactId>junit-jupiter-api</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.junit.jupiter</groupId>
+      <artifactId>junit-jupiter-engine</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.junit.jupiter</groupId>
+      <artifactId>junit-jupiter-params</artifactId>
+      <scope>test</scope>
+    </dependency>
     <dependency>
       <groupId>com.github.stephenc.findbugs</groupId>
       <artifactId>findbugs-annotations</artifactId>
diff --git 
a/hbase-testing-util/src/test/java/org/apache/hadoop/hbase/TestHBaseTestingUtilSpinup.java
 
b/hbase-testing-util/src/test/java/org/apache/hadoop/hbase/TestHBaseTestingUtilSpinup.java
index bb850db1aa8..63c23919b95 100644
--- 
a/hbase-testing-util/src/test/java/org/apache/hadoop/hbase/TestHBaseTestingUtilSpinup.java
+++ 
b/hbase-testing-util/src/test/java/org/apache/hadoop/hbase/TestHBaseTestingUtilSpinup.java
@@ -17,33 +17,26 @@
  */
 package org.apache.hadoop.hbase;
 
-import static org.junit.Assert.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertFalse;
 
 import java.util.List;
 import org.apache.hadoop.hbase.testclassification.MediumTests;
 import org.apache.hadoop.hbase.testclassification.MiscTests;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
 
 /**
  * Make sure we can spin up a HBTU without a hbase-site.xml
  */
-@Category({ MiscTests.class, MediumTests.class })
+@Tag(MiscTests.TAG)
+@Tag(MediumTests.TAG)
 public class TestHBaseTestingUtilSpinup {
 
-  @ClassRule
-  public static final HBaseClassTestRule CLASS_RULE =
-    HBaseClassTestRule.forClass(TestHBaseTestingUtilSpinup.class);
-
-  private static final Logger LOG = 
LoggerFactory.getLogger(TestHBaseTestingUtilSpinup.class);
   private final static HBaseTestingUtility UTIL = new HBaseTestingUtility();
 
-  @BeforeClass
+  @BeforeAll
   public static void beforeClass() throws Exception {
     UTIL.startMiniCluster();
     if (!UTIL.getHBaseCluster().waitForActiveAndReadyMaster(30000)) {
@@ -51,7 +44,7 @@ public class TestHBaseTestingUtilSpinup {
     }
   }
 
-  @AfterClass
+  @AfterAll
   public static void afterClass() throws Exception {
     UTIL.shutdownMiniCluster();
   }
@@ -59,7 +52,6 @@ public class TestHBaseTestingUtilSpinup {
   @Test
   public void testGetMetaTableRows() throws Exception {
     List<byte[]> results = UTIL.getMetaTableRows();
-    assertFalse("results should have some entries and is empty.", 
results.isEmpty());
+    assertFalse(results.isEmpty(), "results should have some entries and is 
empty.");
   }
-
 }
diff --git 
a/hbase-testing-util/src/test/java/org/apache/hadoop/hbase/testing/TestTestingHBaseCluster.java
 
b/hbase-testing-util/src/test/java/org/apache/hadoop/hbase/testing/TestTestingHBaseCluster.java
index 874e7562a23..e9ead60befa 100644
--- 
a/hbase-testing-util/src/test/java/org/apache/hadoop/hbase/testing/TestTestingHBaseCluster.java
+++ 
b/hbase-testing-util/src/test/java/org/apache/hadoop/hbase/testing/TestTestingHBaseCluster.java
@@ -17,13 +17,12 @@
  */
 package org.apache.hadoop.hbase.testing;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertThrows;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.util.Collection;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
 import org.apache.hadoop.hbase.ServerName;
 import org.apache.hadoop.hbase.Waiter;
 import org.apache.hadoop.hbase.client.Admin;
@@ -33,44 +32,40 @@ import 
org.apache.hadoop.hbase.testclassification.LargeTests;
 import org.apache.hadoop.hbase.testclassification.MiscTests;
 import org.apache.hadoop.hbase.util.DNS;
 import org.apache.hadoop.hbase.util.DNS.ServerType;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
 
 import org.apache.hbase.thirdparty.com.google.common.collect.Iterables;
 import org.apache.hbase.thirdparty.com.google.common.io.Closeables;
 
-@Category({ MiscTests.class, LargeTests.class })
+@Tag(MiscTests.TAG)
+@Tag(LargeTests.TAG)
 public class TestTestingHBaseCluster {
 
-  @ClassRule
-  public static final HBaseClassTestRule CLASS_RULE =
-    HBaseClassTestRule.forClass(TestTestingHBaseCluster.class);
-
   private static TestingHBaseCluster CLUSTER;
 
   private Connection conn;
 
   private Admin admin;
 
-  @BeforeClass
+  @BeforeAll
   public static void setUpBeforeClass() throws Exception {
     CLUSTER = 
TestingHBaseCluster.create(TestingHBaseClusterOption.builder().numMasters(2)
       .numRegionServers(3).numDataNodes(3).build());
   }
 
-  @AfterClass
+  @AfterAll
   public static void tearDownAfterClass() throws Exception {
     if (CLUSTER.isClusterRunning()) {
       CLUSTER.stop();
     }
   }
 
-  @Before
+  @BeforeEach
   public void setUp() throws Exception {
     if (!CLUSTER.isClusterRunning()) {
       CLUSTER.start();
@@ -82,7 +77,7 @@ public class TestTestingHBaseCluster {
     admin = conn.getAdmin();
   }
 
-  @After
+  @AfterEach
   public void tearDown() throws Exception {
     Closeables.close(admin, true);
     Closeables.close(conn, true);
diff --git 
a/hbase-testing-util/src/test/java/org/apache/hadoop/hbase/testing/TestTestingHBaseClusterImplForCPs.java
 
b/hbase-testing-util/src/test/java/org/apache/hadoop/hbase/testing/TestTestingHBaseClusterImplForCPs.java
index 4454dcbaa20..ef9b5c0775e 100644
--- 
a/hbase-testing-util/src/test/java/org/apache/hadoop/hbase/testing/TestTestingHBaseClusterImplForCPs.java
+++ 
b/hbase-testing-util/src/test/java/org/apache/hadoop/hbase/testing/TestTestingHBaseClusterImplForCPs.java
@@ -17,13 +17,12 @@
  */
 package org.apache.hadoop.hbase.testing;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertSame;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertSame;
 
 import java.io.IOException;
 import java.util.List;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
 import org.apache.hadoop.hbase.ServerName;
 import org.apache.hadoop.hbase.TableName;
 import org.apache.hadoop.hbase.client.Admin;
@@ -39,21 +38,17 @@ import org.apache.hadoop.hbase.regionserver.Region;
 import org.apache.hadoop.hbase.testclassification.LargeTests;
 import org.apache.hadoop.hbase.testclassification.MiscTests;
 import org.apache.hadoop.hbase.util.Bytes;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
 
 import org.apache.hbase.thirdparty.com.google.common.io.Closeables;
 
-@Category({ MiscTests.class, LargeTests.class })
+@Tag(MiscTests.TAG)
+@Tag(LargeTests.TAG)
 public class TestTestingHBaseClusterImplForCPs {
 
-  @ClassRule
-  public static final HBaseClassTestRule CLASS_RULE =
-    HBaseClassTestRule.forClass(TestTestingHBaseClusterImplForCPs.class);
-
   private static TestingHBaseCluster CLUSTER;
 
   private static TableName NAME = TableName.valueOf("test");
@@ -64,7 +59,7 @@ public class TestTestingHBaseClusterImplForCPs {
 
   private static Admin ADMIN;
 
-  @BeforeClass
+  @BeforeAll
   public static void setUpBeforeClass() throws Exception {
     CLUSTER = 
TestingHBaseCluster.create(TestingHBaseClusterOption.builder().numMasters(2)
       .numRegionServers(3).numDataNodes(3).build());
@@ -76,7 +71,7 @@ public class TestTestingHBaseClusterImplForCPs {
     ADMIN.balancerSwitch(false, true);
   }
 
-  @AfterClass
+  @AfterAll
   public static void tearDownAfterClass() throws Exception {
     Closeables.close(ADMIN, true);
     Closeables.close(CONN, true);
diff --git 
a/hbase-testing-util/src/test/java/org/apache/hadoop/hbase/testing/TestTestingHBaseClusterReplicationShareDfs.java
 
b/hbase-testing-util/src/test/java/org/apache/hadoop/hbase/testing/TestTestingHBaseClusterReplicationShareDfs.java
index 61a711a6916..80d6d7bed68 100644
--- 
a/hbase-testing-util/src/test/java/org/apache/hadoop/hbase/testing/TestTestingHBaseClusterReplicationShareDfs.java
+++ 
b/hbase-testing-util/src/test/java/org/apache/hadoop/hbase/testing/TestTestingHBaseClusterReplicationShareDfs.java
@@ -17,24 +17,19 @@
  */
 package org.apache.hadoop.hbase.testing;
 
-import static org.junit.Assert.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
 
-import org.apache.hadoop.hbase.HBaseClassTestRule;
 import org.apache.hadoop.hbase.HBaseTestingUtility;
 import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.testclassification.LargeTests;
 import org.apache.hadoop.hbase.testclassification.MiscTests;
-import org.junit.ClassRule;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.Tag;
 
-@Category({ MiscTests.class, LargeTests.class })
+@Tag(MiscTests.TAG)
+@Tag(LargeTests.TAG)
 public class TestTestingHBaseClusterReplicationShareDfs
   extends TestingHBaseClusterReplicationTestBase {
 
-  @ClassRule
-  public static final HBaseClassTestRule CLASS_RULE =
-    
HBaseClassTestRule.forClass(TestTestingHBaseClusterReplicationShareDfs.class);
-
   private HBaseTestingUtility util = new HBaseTestingUtility();
 
   @Override
diff --git 
a/hbase-testing-util/src/test/java/org/apache/hadoop/hbase/testing/TestTestingHBaseClusterReplicationShareZk.java
 
b/hbase-testing-util/src/test/java/org/apache/hadoop/hbase/testing/TestTestingHBaseClusterReplicationShareZk.java
index f12374bf688..e1302864d08 100644
--- 
a/hbase-testing-util/src/test/java/org/apache/hadoop/hbase/testing/TestTestingHBaseClusterReplicationShareZk.java
+++ 
b/hbase-testing-util/src/test/java/org/apache/hadoop/hbase/testing/TestTestingHBaseClusterReplicationShareZk.java
@@ -17,24 +17,19 @@
  */
 package org.apache.hadoop.hbase.testing;
 
-import static org.junit.Assert.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
 
-import org.apache.hadoop.hbase.HBaseClassTestRule;
 import org.apache.hadoop.hbase.HBaseTestingUtility;
 import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.testclassification.LargeTests;
 import org.apache.hadoop.hbase.testclassification.MiscTests;
-import org.junit.ClassRule;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.Tag;
 
-@Category({ MiscTests.class, LargeTests.class })
+@Tag(MiscTests.TAG)
+@Tag(LargeTests.TAG)
 public class TestTestingHBaseClusterReplicationShareZk
   extends TestingHBaseClusterReplicationTestBase {
 
-  @ClassRule
-  public static final HBaseClassTestRule CLASS_RULE =
-    
HBaseClassTestRule.forClass(TestTestingHBaseClusterReplicationShareZk.class);
-
   private HBaseTestingUtility util = new HBaseTestingUtility();
 
   @Override
diff --git 
a/hbase-testing-util/src/test/java/org/apache/hadoop/hbase/testing/TestTestingHBaseClusterReplicationShareZkDfs.java
 
b/hbase-testing-util/src/test/java/org/apache/hadoop/hbase/testing/TestTestingHBaseClusterReplicationShareZkDfs.java
index 8492e5894a4..554dee0dbe3 100644
--- 
a/hbase-testing-util/src/test/java/org/apache/hadoop/hbase/testing/TestTestingHBaseClusterReplicationShareZkDfs.java
+++ 
b/hbase-testing-util/src/test/java/org/apache/hadoop/hbase/testing/TestTestingHBaseClusterReplicationShareZkDfs.java
@@ -17,24 +17,19 @@
  */
 package org.apache.hadoop.hbase.testing;
 
-import static org.junit.Assert.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
 
-import org.apache.hadoop.hbase.HBaseClassTestRule;
 import org.apache.hadoop.hbase.HBaseTestingUtility;
 import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.testclassification.LargeTests;
 import org.apache.hadoop.hbase.testclassification.MiscTests;
-import org.junit.ClassRule;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.Tag;
 
-@Category({ MiscTests.class, LargeTests.class })
+@Tag(MiscTests.TAG)
+@Tag(LargeTests.TAG)
 public class TestTestingHBaseClusterReplicationShareZkDfs
   extends TestingHBaseClusterReplicationTestBase {
 
-  @ClassRule
-  public static final HBaseClassTestRule CLASS_RULE =
-    
HBaseClassTestRule.forClass(TestTestingHBaseClusterReplicationShareZkDfs.class);
-
   private HBaseTestingUtility util = new HBaseTestingUtility();
 
   @Override
diff --git 
a/hbase-testing-util/src/test/java/org/apache/hadoop/hbase/testing/TestTestingHBaseClusterReplicationTwoClusters.java
 
b/hbase-testing-util/src/test/java/org/apache/hadoop/hbase/testing/TestTestingHBaseClusterReplicationTwoClusters.java
index 4c57edd095c..83d825acc48 100644
--- 
a/hbase-testing-util/src/test/java/org/apache/hadoop/hbase/testing/TestTestingHBaseClusterReplicationTwoClusters.java
+++ 
b/hbase-testing-util/src/test/java/org/apache/hadoop/hbase/testing/TestTestingHBaseClusterReplicationTwoClusters.java
@@ -17,20 +17,15 @@
  */
 package org.apache.hadoop.hbase.testing;
 
-import org.apache.hadoop.hbase.HBaseClassTestRule;
 import org.apache.hadoop.hbase.testclassification.LargeTests;
 import org.apache.hadoop.hbase.testclassification.MiscTests;
-import org.junit.ClassRule;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.Tag;
 
-@Category({ MiscTests.class, LargeTests.class })
+@Tag(MiscTests.TAG)
+@Tag(LargeTests.TAG)
 public class TestTestingHBaseClusterReplicationTwoClusters
   extends TestingHBaseClusterReplicationTestBase {
 
-  @ClassRule
-  public static final HBaseClassTestRule CLASS_RULE =
-    
HBaseClassTestRule.forClass(TestTestingHBaseClusterReplicationTwoClusters.class);
-
   @Override
   protected void startClusters() throws Exception {
     sourceCluster = 
TestingHBaseCluster.create(TestingHBaseClusterOption.builder().build());
diff --git 
a/hbase-testing-util/src/test/java/org/apache/hadoop/hbase/testing/TestingHBaseClusterReplicationTestBase.java
 
b/hbase-testing-util/src/test/java/org/apache/hadoop/hbase/testing/TestingHBaseClusterReplicationTestBase.java
index 445c35e3c36..47c9634a1e4 100644
--- 
a/hbase-testing-util/src/test/java/org/apache/hadoop/hbase/testing/TestingHBaseClusterReplicationTestBase.java
+++ 
b/hbase-testing-util/src/test/java/org/apache/hadoop/hbase/testing/TestingHBaseClusterReplicationTestBase.java
@@ -17,7 +17,7 @@
  */
 package org.apache.hadoop.hbase.testing;
 
-import static org.junit.Assert.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
 
 import java.io.IOException;
 import org.apache.hadoop.hbase.HConstants;
@@ -35,9 +35,9 @@ import org.apache.hadoop.hbase.client.TableDescriptorBuilder;
 import org.apache.hadoop.hbase.replication.ReplicationPeerConfig;
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.hadoop.hbase.zookeeper.ZKConfig;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 import org.apache.hbase.thirdparty.com.google.common.io.Closeables;
 
@@ -64,7 +64,7 @@ public abstract class TestingHBaseClusterReplicationTestBase {
     return ZKConfig.getZooKeeperClusterKey(peerCluster.getConf());
   }
 
-  @Before
+  @BeforeEach
   public void setUp() throws Exception {
     startClusters();
     sourceConn = ConnectionFactory.createConnection(sourceCluster.getConf());
@@ -82,7 +82,7 @@ public abstract class TestingHBaseClusterReplicationTestBase {
     }
   }
 
-  @After
+  @AfterEach
   public void tearDown() throws Exception {
     Closeables.close(sourceConn, true);
     Closeables.close(peerConn, true);

Reply via email to