This is an automated email from the ASF dual-hosted git repository. anmolnar pushed a commit to branch HBASE-29164 in repository https://gitbox.apache.org/repos/asf/hbase.git
commit 5cda9c091e17ceb86c80d1b88103e5ef2374252d Author: Kevin Geiszler <[email protected]> AuthorDate: Mon Jul 13 16:57:35 2026 -0400 Update JUnit 4 usages to JUnit 5 Change-Id: I028f40ed905a6241b2ed5f8b5c84f1ce9f39a6b3 --- .../hbase/backup/IntegrationTestBackupRestore.java | 10 +++---- .../backup/IntegrationTestBackupRestoreBase.java | 35 +++++++++++----------- .../IntegrationTestContinuousBackupRestore.java | 10 +++---- 3 files changed, 27 insertions(+), 28 deletions(-) diff --git a/hbase-it/src/test/java/org/apache/hadoop/hbase/backup/IntegrationTestBackupRestore.java b/hbase-it/src/test/java/org/apache/hadoop/hbase/backup/IntegrationTestBackupRestore.java index 99fbcb21a2b..d03863c3589 100644 --- a/hbase-it/src/test/java/org/apache/hadoop/hbase/backup/IntegrationTestBackupRestore.java +++ b/hbase-it/src/test/java/org/apache/hadoop/hbase/backup/IntegrationTestBackupRestore.java @@ -25,9 +25,9 @@ import org.apache.hadoop.hbase.IntegrationTestingUtility; import org.apache.hadoop.hbase.backup.impl.BackupManager; import org.apache.hadoop.hbase.testclassification.IntegrationTests; import org.apache.hadoop.util.ToolRunner; -import org.junit.Before; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -37,13 +37,13 @@ import org.slf4j.LoggerFactory; * @see <a href="https://issues.apache.org/jira/browse/HBASE-7912">HBASE-7912</a> * @see <a href="https://issues.apache.org/jira/browse/HBASE-14123">HBASE-14123</a> */ -@Category(IntegrationTests.class) +@Tag(IntegrationTests.TAG) public class IntegrationTestBackupRestore extends IntegrationTestBackupRestoreBase { private static final String CLASS_NAME = IntegrationTestBackupRestore.class.getSimpleName(); protected static final Logger LOG = LoggerFactory.getLogger(IntegrationTestBackupRestore.class); @Override - @Before + @BeforeEach public void setUp() throws Exception { util = new IntegrationTestingUtility(); conf = util.getConfiguration(); diff --git a/hbase-it/src/test/java/org/apache/hadoop/hbase/backup/IntegrationTestBackupRestoreBase.java b/hbase-it/src/test/java/org/apache/hadoop/hbase/backup/IntegrationTestBackupRestoreBase.java index 56349fe055a..abbf08860e4 100644 --- a/hbase-it/src/test/java/org/apache/hadoop/hbase/backup/IntegrationTestBackupRestoreBase.java +++ b/hbase-it/src/test/java/org/apache/hadoop/hbase/backup/IntegrationTestBackupRestoreBase.java @@ -19,10 +19,10 @@ package org.apache.hadoop.hbase.backup; import static org.apache.hadoop.hbase.IntegrationTestingUtility.createPreSplitLoadTestTable; import static org.apache.hadoop.hbase.backup.BackupRestoreConstants.CONF_CONTINUOUS_BACKUP_WAL_DIR; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; import java.io.IOException; import java.nio.charset.Charset; @@ -57,8 +57,8 @@ import org.apache.hadoop.hbase.client.Table; import org.apache.hadoop.hbase.client.TableDescriptor; import org.apache.hadoop.hbase.client.TableDescriptorBuilder; import org.apache.hadoop.hbase.util.EnvironmentEdgeManager; -import org.junit.After; -import org.junit.Assert; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -143,7 +143,7 @@ public abstract class IntegrationTestBackupRestoreBase extends IntegrationTestBa } } - @After + @AfterEach public void tearDown() throws IOException { LOG.info("Cleaning up after test."); if (util.isDistributedCluster()) { @@ -333,7 +333,7 @@ public abstract class IntegrationTestBackupRestoreBase extends IntegrationTestBa restore(createRestoreRequest(backupRootDir, incrementalBackupId, false, tablesToRestoreFrom, null, true), client); Table hTable = conn.getTable(tableName); - Assert.assertEquals(rowsInIteration * (numIterations + 1), + Assertions.assertEquals(rowsInIteration * (numIterations + 1), HBaseTestingUtil.countRows(hTable)); hTable.close(); @@ -427,9 +427,8 @@ public abstract class IntegrationTestBackupRestoreBase extends IntegrationTestBa private Path verifyWALsDirectoryExists() throws IOException { String backupWALDir = conf.get(CONF_CONTINUOUS_BACKUP_WAL_DIR); Path backupWALs = new Path(backupWALDir, "WALs"); - assertTrue( - "There should be a WALs directory inside of the backup WAL directory at: " + backupWALDir, - fs.exists(backupWALs)); + assertTrue(fs.exists(backupWALs), + "There should be a WALs directory inside of the backup WAL directory at: " + backupWALDir); return backupWALs; } @@ -450,8 +449,8 @@ public abstract class IntegrationTestBackupRestoreBase extends IntegrationTestBa int waitTimeSec = 30; while (true) { try { - assertTrue("A backup WALs subdirectory with today's date should exist: " + walPartitionDir, - fs.exists(walPartitionDir)); + assertTrue(fs.exists(walPartitionDir), + "A backup WALs subdirectory with today's date should exist: " + walPartitionDir); // The directory exists - stop waiting break; } catch (AssertionError e) { @@ -574,7 +573,7 @@ public abstract class IntegrationTestBackupRestoreBase extends IntegrationTestBa createRestoreRequest(backupRootDir, backupId, false, tablesRestoreIncMultiple, null, true), client); Table hTable = conn.getTable(table); - Assert.assertEquals(expectedRows, HBaseTestingUtil.countRows(hTable)); + Assertions.assertEquals(expectedRows, HBaseTestingUtil.countRows(hTable)); hTable.close(); } @@ -684,13 +683,13 @@ public abstract class IntegrationTestBackupRestoreBase extends IntegrationTestBa } private void verifyBackupExists(String backupId) throws IOException { - assertTrue("Backup " + backupId + " should exist inside of " + backupRootDir, - fs.exists(new Path(backupRootDir, backupId))); + assertTrue(fs.exists(new Path(backupRootDir, backupId)), + "Backup " + backupId + " should exist inside of " + backupRootDir); } private void verifyBackupDoesNotExist(String backupId) throws IOException { - assertFalse("Backup " + backupId + " should not exist inside of " + backupRootDir, - fs.exists(new Path(backupRootDir, backupId))); + assertFalse(fs.exists(new Path(backupRootDir, backupId)), + "Backup " + backupId + " should not exist inside of " + backupRootDir); } @Override diff --git a/hbase-it/src/test/java/org/apache/hadoop/hbase/backup/IntegrationTestContinuousBackupRestore.java b/hbase-it/src/test/java/org/apache/hadoop/hbase/backup/IntegrationTestContinuousBackupRestore.java index 61ce3eea2b1..2b7f86adcc2 100644 --- a/hbase-it/src/test/java/org/apache/hadoop/hbase/backup/IntegrationTestContinuousBackupRestore.java +++ b/hbase-it/src/test/java/org/apache/hadoop/hbase/backup/IntegrationTestContinuousBackupRestore.java @@ -32,9 +32,9 @@ import org.apache.hadoop.hbase.IntegrationTestingUtility; import org.apache.hadoop.hbase.backup.impl.BackupManager; import org.apache.hadoop.hbase.testclassification.IntegrationTests; import org.apache.hadoop.util.ToolRunner; -import org.junit.Before; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -44,7 +44,7 @@ import org.slf4j.LoggerFactory; * verify data. * @see <a href="https://issues.apache.org/jira/browse/HBASE-28957">HBASE-28957</a> */ -@Category(IntegrationTests.class) +@Tag(IntegrationTests.TAG) public class IntegrationTestContinuousBackupRestore extends IntegrationTestBackupRestoreBase { private static final String CLASS_NAME = IntegrationTestContinuousBackupRestore.class.getSimpleName(); @@ -52,7 +52,7 @@ public class IntegrationTestContinuousBackupRestore extends IntegrationTestBacku LoggerFactory.getLogger(IntegrationTestContinuousBackupRestore.class); @Override - @Before + @BeforeEach public void setUp() throws Exception { util = new IntegrationTestingUtility(); conf = util.getConfiguration();
