Copilot commented on code in PR #8031:
URL: https://github.com/apache/hbase/pull/8031#discussion_r3055399732


##########
hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterRegionMutation2.java:
##########
@@ -36,44 +32,34 @@
 import org.apache.hadoop.hbase.testclassification.LargeTests;
 import org.apache.hadoop.hbase.testclassification.MasterTests;
 import org.apache.hadoop.hbase.wal.WAL;
-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.BeforeEach;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
 
 /**
  * MasterRegion related test that ensures the operations continue even when 
Procedure state update
  * encounters non-retriable IO errors.
  */
-@Category({ MasterTests.class, LargeTests.class })
+@Tag(MasterTests.TAG)
+@Tag(LargeTests.TAG)
 public class TestMasterRegionMutation2 extends TestMasterRegionMutation1 {
 
-  @ClassRule
-  public static final HBaseClassTestRule CLASS_RULE =
-    HBaseClassTestRule.forClass(TestMasterRegionMutation2.class);
-
-  @BeforeClass
-  public static void setUpBeforeClass() throws Exception {
-    TEST_UTIL.getConfiguration().setClass(HConstants.REGION_IMPL, 
TestRegion.class, HRegion.class);
-    StartTestingClusterOption.Builder builder = 
StartTestingClusterOption.builder();
-    // 2 masters are expected to be aborted with this test
-    builder.numMasters(3).numRegionServers(3);
-    TEST_UTIL.startMiniCluster(builder.build());
-    SingleProcessHBaseCluster cluster = TEST_UTIL.getHBaseCluster();
-    rs0 = cluster.getRegionServer(0).getServerName();
-    TEST_UTIL.getAdmin().balancerSwitch(false, true);
+  static {
+    numMasters = 3;
+    regionImplClass = TestRegion.class;
   }
 
-  @AfterClass
-  public static void tearDownAfterClass() throws Exception {
-    TEST_UTIL.shutdownMiniCluster();
+  @BeforeEach
+  public void setUp(TestInfo testInfo) throws Exception {
+    super.setUp(testInfo);
   }
 
-  @Before
-  public void setUp() throws Exception {
-    super.setUp();
+  @AfterAll
+  public static void tearDownAfterClass() {
+    numMasters = 2;
+    regionImplClass = TestMasterRegionMutation1.TestRegion.class;
   }

Review Comment:
   The `@AfterAll` method here has the same signature/name as the superclass's 
`@AfterAll` tearDownAfterClass, which will hide/override it in JUnit 5 
lifecycle discovery. That prevents the superclass teardown from running (so the 
mini cluster started in the inherited `@BeforeAll` may never be shut down for 
this test class). Rename this method (so the superclass `@AfterAll` still 
executes) or perform the cluster shutdown here as well.



##########
hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestSplitRegionWhileRSCrash.java:
##########
@@ -17,8 +17,9 @@
  */
 package org.apache.hadoop.hbase.master;
 
+import static org.junit.jupiter.api.Assertions.*;
+

Review Comment:
   Static wildcard import from org.junit.jupiter.api.Assertions will violate 
the project's Checkstyle AvoidStarImport rule. Replace it with explicit static 
imports for the assertion methods actually used in this test (and drop the 
wildcard).



##########
hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestSplitLogManager.java:
##########
@@ -30,9 +30,10 @@
 import static 
org.apache.hadoop.hbase.SplitLogCounters.tot_mgr_resubmit_threshold_reached;
 import static 
org.apache.hadoop.hbase.SplitLogCounters.tot_mgr_resubmit_unassigned;
 import static org.apache.hadoop.hbase.SplitLogCounters.tot_mgr_task_deleted;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;

Review Comment:
   Static wildcard import from org.junit.jupiter.api.Assertions will violate 
the project's Checkstyle AvoidStarImport rule. Replace it with explicit static 
imports for the assertion methods actually used here. Also, keeping both the 
wildcard and explicit imports is redundant.



##########
hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterAbortAndRSGotKilled.java:
##########
@@ -17,10 +17,11 @@
  */
 package org.apache.hadoop.hbase.master;
 
+import static org.junit.jupiter.api.Assertions.*;
+

Review Comment:
   Static wildcard import from org.junit.jupiter.api.Assertions will violate 
the project's Checkstyle AvoidStarImport rule. Replace it with explicit static 
imports for the assertion methods actually used in this test.
   ```suggestion
   
   ```



##########
hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestRegionPlansWithThrottle.java:
##########
@@ -17,9 +17,10 @@
  */
 package org.apache.hadoop.hbase.master;
 
+import static org.junit.jupiter.api.Assertions.*;
+

Review Comment:
   Static wildcard import from org.junit.jupiter.api.Assertions will violate 
the project's Checkstyle AvoidStarImport rule. Replace it with explicit static 
imports for the assertion methods actually used in this test.



##########
hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestUnknownServers.java:
##########
@@ -17,33 +17,29 @@
  */
 package org.apache.hadoop.hbase.master;
 
+import static org.junit.jupiter.api.Assertions.*;
+

Review Comment:
   Static wildcard import from org.junit.jupiter.api.Assertions will violate 
the project's Checkstyle AvoidStarImport rule. Replace it with explicit static 
imports for the assertion methods actually used in this test.



##########
hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestHMasterCommandLine.java:
##########
@@ -17,23 +17,18 @@
  */
 package org.apache.hadoop.hbase.master;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;

Review Comment:
   Static wildcard import from org.junit.jupiter.api.Assertions will violate 
the project's Checkstyle AvoidStarImport rule. Replace it with explicit static 
imports for the assertion methods actually used in this test.
   ```suggestion
   import static org.junit.jupiter.api.Assertions.assertEquals;
   ```



##########
hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterTransitions.java:
##########
@@ -17,9 +17,10 @@
  */
 package org.apache.hadoop.hbase.master;
 
+import static org.junit.jupiter.api.Assertions.*;
+

Review Comment:
   Static wildcard import from org.junit.jupiter.api.Assertions will violate 
the project's Checkstyle AvoidStarImport rule. Replace it with explicit static 
imports for the assertion methods actually used in this test.



##########
hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestClusterStatusPublisher.java:
##########
@@ -17,31 +17,27 @@
  */
 package org.apache.hadoop.hbase.master;
 
+import static org.junit.jupiter.api.Assertions.*;

Review Comment:
   Static wildcard import from org.junit.jupiter.api.Assertions will violate 
the project's Checkstyle AvoidStarImport rule. Replace it with explicit static 
imports for the assertion methods actually used in this test.
   ```suggestion
   import static org.junit.jupiter.api.Assertions.assertTrue;
   ```



##########
hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterNoCluster.java:
##########
@@ -18,11 +18,11 @@
 package org.apache.hadoop.hbase.master;
 
 import static org.apache.hadoop.hbase.HConstants.ZOOKEEPER_QUORUM;
+import static org.junit.jupiter.api.Assertions.*;

Review Comment:
   Static wildcard import from org.junit.jupiter.api.Assertions will violate 
the project's Checkstyle AvoidStarImport rule. Replace it with explicit static 
imports for the assertion methods actually used in this file (and drop the 
wildcard).



##########
hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestRecreateCluster.java:
##########
@@ -43,42 +42,40 @@
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.hadoop.hbase.util.CommonFSUtils;
 import org.apache.hadoop.hbase.zookeeper.ZKUtil;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.rules.TestName;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
 
 /**
  * Test reuse storefiles within data directory when cluster failover with a 
set of new region
  * servers with different hostnames with or without WALs and Zookeeper ZNodes, 
the master and
  * cluster should fail respectively if there is any situation considered as 
not supported.
  */
-@Category({ LargeTests.class })
+@Tag(LargeTests.TAG)
 public class TestRecreateCluster {
-  @ClassRule
-  public static final HBaseClassTestRule CLASS_RULE =
-    HBaseClassTestRule.forClass(TestRecreateCluster.class);
+  private String testMethodName;
 
-  @Rule
-  public TestName name = new TestName();
+  @BeforeEach
+  public void setTestMethod(TestInfo testInfo) {
+    testMethodName = testInfo.getTestMethod().get().getName();
+  }

Review Comment:
   The new testMethodName field is assigned in `@BeforeEach` but never used 
anywhere in this class. Please remove the unused field and setTestMethod to 
avoid dead code (and potential style checks for unused members).



##########
hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterNoCluster.java:
##########
@@ -54,21 +52,21 @@
  * cluster context. TODO: Speed up the zk connection by Master. It pauses 5 
seconds establishing
  * session.
  */
-@Category({ MasterTests.class, MediumTests.class })
+@Tag(MasterTests.TAG)
+@Tag(MediumTests.TAG)
 public class TestMasterNoCluster {
 
-  @ClassRule
-  public static final HBaseClassTestRule CLASS_RULE =
-    HBaseClassTestRule.forClass(TestMasterNoCluster.class);
-
   private static final Logger LOG = 
LoggerFactory.getLogger(TestMasterNoCluster.class);
 
   private static final HBaseTestingUtil TESTUTIL = new HBaseTestingUtil();
+  private String testMethodName;
 
-  @Rule
-  public TestName name = new TestName();
+  @BeforeEach
+  public void setTestMethod(TestInfo testInfo) {
+    testMethodName = testInfo.getTestMethod().get().getName();
+  }

Review Comment:
   The new testMethodName field is assigned in `@BeforeEach` but never used 
anywhere in this test class. Please remove the field and the setTestMethod 
method to avoid dead code (and potential style checks for unused members).



##########
hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestRegionState.java:
##########
@@ -17,30 +17,28 @@
  */
 package org.apache.hadoop.hbase.master;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
-import org.apache.hadoop.hbase.HBaseClassTestRule;
 import org.apache.hadoop.hbase.TableName;
 import org.apache.hadoop.hbase.client.RegionInfoBuilder;
 import org.apache.hadoop.hbase.testclassification.MasterTests;
 import org.apache.hadoop.hbase.testclassification.SmallTests;
-import org.junit.ClassRule;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.rules.TestName;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
 
 import org.apache.hadoop.hbase.shaded.protobuf.generated.ClusterStatusProtos;
 
-@Category({ MasterTests.class, SmallTests.class })
+@Tag(MasterTests.TAG)
+@Tag(SmallTests.TAG)
 public class TestRegionState {
+  private String testMethodName;
 
-  @ClassRule
-  public static final HBaseClassTestRule CLASS_RULE =
-    HBaseClassTestRule.forClass(TestRegionState.class);
-
-  @Rule
-  public TestName name = new TestName();
+  @BeforeEach
+  public void setTestMethod(TestInfo testInfo) {
+    testMethodName = testInfo.getTestMethod().get().getName();
+  }

Review Comment:
   The new testMethodName field is assigned in `@BeforeEach` but never used 
anywhere in this class. Please remove the unused field and the setTestMethod 
method to avoid dead code (and potential style checks for unused members).



##########
hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMergeTableRegionsWhileRSCrash.java:
##########
@@ -17,9 +17,10 @@
  */
 package org.apache.hadoop.hbase.master;
 
+import static org.junit.jupiter.api.Assertions.*;
+

Review Comment:
   Static wildcard import from org.junit.jupiter.api.Assertions will violate 
the project's Checkstyle AvoidStarImport rule. Replace it with explicit static 
imports for the assertion methods actually used in this test.



##########
hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterChoreScheduled.java:
##########
@@ -17,9 +17,10 @@
  */
 package org.apache.hadoop.hbase.master;
 
+import static org.junit.jupiter.api.Assertions.*;

Review Comment:
   Static wildcard import from org.junit.jupiter.api.Assertions will violate 
the project's Checkstyle AvoidStarImport rule. Replace it with explicit static 
imports for the assertion methods actually used in this test.
   ```suggestion
   import static org.junit.jupiter.api.Assertions.assertTrue;
   ```



##########
hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestListTablesByState.java:
##########
@@ -17,7 +17,8 @@
  */
 package org.apache.hadoop.hbase.master;
 
-import org.apache.hadoop.hbase.HBaseClassTestRule;
+import static org.junit.jupiter.api.Assertions.*;

Review Comment:
   Static wildcard import from org.junit.jupiter.api.Assertions will violate 
the project's Checkstyle AvoidStarImport rule. Replace it with explicit static 
imports for the assertion methods actually used in this test.
   ```suggestion
   import static org.junit.jupiter.api.Assertions.assertEquals;
   ```



##########
hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestDeadServer.java:
##########
@@ -17,13 +17,13 @@
  */
 package org.apache.hadoop.hbase.master;
 
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;

Review Comment:
   Static wildcard import from org.junit.jupiter.api.Assertions will violate 
the project's Checkstyle AvoidStarImport rule. Replace it with explicit static 
imports for the assertion methods actually used here, and drop the wildcard + 
duplicate explicit imports.
   ```suggestion
   
   ```



##########
hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterFileSystemWithStoreFileTracking.java:
##########
@@ -19,45 +19,43 @@
 
 import static 
org.apache.hadoop.hbase.regionserver.storefiletracker.StoreFileTrackerFactory.TRACKER_IMPL;
 import static 
org.apache.hadoop.hbase.regionserver.storefiletracker.StoreFileTrackerFactory.Trackers.FILE;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
-import org.apache.hadoop.hbase.HBaseClassTestRule;
 import org.apache.hadoop.hbase.HBaseTestingUtil;
 import org.apache.hadoop.hbase.TableName;
 import org.apache.hadoop.hbase.client.TableDescriptor;
 import org.apache.hadoop.hbase.testclassification.MasterTests;
 import org.apache.hadoop.hbase.testclassification.MediumTests;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.rules.TestName;
+import org.junit.jupiter.api.AfterAll;
+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.junit.jupiter.api.TestInfo;
 
 /**
  * Test the master filesystem in a local cluster with Store File Tracking 
explicitly set in global
  * config
  */
-@Category({ MasterTests.class, MediumTests.class })
+@Tag(MasterTests.TAG)
+@Tag(MediumTests.TAG)
 public class TestMasterFileSystemWithStoreFileTracking {
+  private String testMethodName;
 
-  @ClassRule
-  public static final HBaseClassTestRule CLASS_RULE =
-    
HBaseClassTestRule.forClass(TestMasterFileSystemWithStoreFileTracking.class);
-
-  @Rule
-  public TestName name = new TestName();
+  @BeforeEach
+  public void setTestMethod(TestInfo testInfo) {
+    testMethodName = testInfo.getTestMethod().get().getName();
+  }

Review Comment:
   The new testMethodName field (and `@BeforeEach` setter) is unused in this 
test. Please remove them to avoid dead code (and potential style checks for 
unused members).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to