From bbfecd7f7261298e845eebb9a7a4ae5a739f562b Mon Sep 17 00:00:00 2001 From: liuxiaocs7 Date: Mon, 2 Mar 2026 18:07:47 +0800 Subject: [PATCH] HBASE-29927 Upgrade hbase-external-blockcache to use junit5 --- hbase-external-blockcache/pom.xml | 5 ---- .../io/hfile/TestMemcachedBlockCache.java | 23 ++++++++----------- .../hadoop/hbase/io/hfile/CacheTestUtils.java | 12 +++++----- 3 files changed, 15 insertions(+), 25 deletions(-) diff --git a/hbase-external-blockcache/pom.xml b/hbase-external-blockcache/pom.xml index d1f189e187a5..658f2eb05f2e 100644 --- a/hbase-external-blockcache/pom.xml +++ b/hbase-external-blockcache/pom.xml @@ -116,11 +116,6 @@ junit-jupiter-params test - - org.junit.vintage - junit-vintage-engine - test - diff --git a/hbase-external-blockcache/src/test/java/org/apache/hadoop/hbase/io/hfile/TestMemcachedBlockCache.java b/hbase-external-blockcache/src/test/java/org/apache/hadoop/hbase/io/hfile/TestMemcachedBlockCache.java index 60370f5208b1..095b8b345f53 100644 --- a/hbase-external-blockcache/src/test/java/org/apache/hadoop/hbase/io/hfile/TestMemcachedBlockCache.java +++ b/hbase-external-blockcache/src/test/java/org/apache/hadoop/hbase/io/hfile/TestMemcachedBlockCache.java @@ -17,9 +17,9 @@ */ package org.apache.hadoop.hbase.io.hfile; -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.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyString; @@ -44,29 +44,24 @@ import net.spy.memcached.ops.OperationStatus; import net.spy.memcached.transcoders.Transcoder; import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.Waiter; import org.apache.hadoop.hbase.io.hfile.CacheTestUtils.HFileBlockPair; import org.apache.hadoop.hbase.testclassification.IOTests; import org.apache.hadoop.hbase.testclassification.SmallTests; -import org.junit.Before; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category({ IOTests.class, SmallTests.class }) +@Tag(IOTests.TAG) +@Tag(SmallTests.TAG) public class TestMemcachedBlockCache { - @ClassRule - public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestMemcachedBlockCache.class); - private MemcachedBlockCache cache; private ConcurrentMap backingMap; - @Before + @BeforeEach public void setup() throws Exception { int port = ThreadLocalRandom.current().nextInt(1024, 65536); Configuration conf = new Configuration(); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/CacheTestUtils.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/CacheTestUtils.java index 501a0347026e..98729ff895f2 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/CacheTestUtils.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/CacheTestUtils.java @@ -17,12 +17,12 @@ */ package org.apache.hadoop.hbase.io.hfile; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; import java.io.IOException; import java.nio.ByteBuffer;