diff --git a/hbase-common/pom.xml b/hbase-common/pom.xml
index 9a30ae406d09..ea58c0327c78 100644
--- a/hbase-common/pom.xml
+++ b/hbase-common/pom.xml
@@ -156,6 +156,11 @@
mockito-inline
test
+
+ org.mockito
+ mockito-junit-jupiter
+ test
+
org.slf4j
jcl-over-slf4j
diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/TestByteBufferKeyValue.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/TestByteBufferKeyValue.java
index dcf7d9e52569..c2db9716fdad 100644
--- a/hbase-common/src/test/java/org/apache/hadoop/hbase/TestByteBufferKeyValue.java
+++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/TestByteBufferKeyValue.java
@@ -17,9 +17,9 @@
*/
package org.apache.hadoop.hbase;
-import static junit.framework.TestCase.assertTrue;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
+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 java.nio.ByteBuffer;
import java.util.ArrayList;
@@ -29,17 +29,14 @@
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.hbase.util.ByteBufferUtils;
import org.apache.hadoop.hbase.util.Bytes;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
-@Category({ MiscTests.class, SmallTests.class })
+@org.junit.jupiter.api.Tag(MiscTests.TAG)
+@org.junit.jupiter.api.Tag(SmallTests.TAG)
+@ExtendWith(HBaseJupiterExtension.class)
public class TestByteBufferKeyValue {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestByteBufferKeyValue.class);
-
private static final String QUAL2 = "qual2";
private static final String FAM2 = "fam2";
private static final String QUAL1 = "qual1";
diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/TestCellBuilder.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/TestCellBuilder.java
index 7860b62dfa70..0b90ba1decfe 100644
--- a/hbase-common/src/test/java/org/apache/hadoop/hbase/TestCellBuilder.java
+++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/TestCellBuilder.java
@@ -17,21 +17,19 @@
*/
package org.apache.hadoop.hbase;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import org.apache.hadoop.hbase.testclassification.MiscTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
-@Category({ MiscTests.class, SmallTests.class })
+@Tag(MiscTests.TAG)
+@Tag(SmallTests.TAG)
+@ExtendWith(HBaseJupiterExtension.class)
public class TestCellBuilder {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestCellBuilder.class);
-
private static final byte OLD_DATA = 87;
private static final byte NEW_DATA = 100;
diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/TestCellComparator.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/TestCellComparator.java
index 553b39311369..1de240d1f1ce 100644
--- a/hbase-common/src/test/java/org/apache/hadoop/hbase/TestCellComparator.java
+++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/TestCellComparator.java
@@ -17,8 +17,8 @@
*/
package org.apache.hadoop.hbase;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.nio.ByteBuffer;
import java.util.Collections;
@@ -28,17 +28,15 @@
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
-@Category({ MiscTests.class, SmallTests.class })
+@Tag(MiscTests.TAG)
+@Tag(SmallTests.TAG)
+@ExtendWith(HBaseJupiterExtension.class)
public class TestCellComparator {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestCellComparator.class);
-
private CellComparator comparator = CellComparator.getInstance();
private CellComparator innerStoreComparator = InnerStoreCellComparator.INNER_STORE_COMPARATOR;
@@ -265,7 +263,8 @@ public void testBinaryKeys() throws Exception {
Collections.addAll(set, keys);
count = 0;
for (Cell k : set) {
- assertTrue("count=" + count + ", " + k.toString(), count++ == k.getTimestamp());
+ int currentCount = count++;
+ assertTrue(currentCount == k.getTimestamp(), "count=" + currentCount + ", " + k.toString());
}
}
}
diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/TestCellUtil.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/TestCellUtil.java
index 3ff63ef6ff65..fbea47242481 100644
--- a/hbase-common/src/test/java/org/apache/hadoop/hbase/TestCellUtil.java
+++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/TestCellUtil.java
@@ -17,10 +17,10 @@
*/
package org.apache.hadoop.hbase;
-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.math.BigDecimal;
@@ -32,17 +32,15 @@
import org.apache.hadoop.hbase.testclassification.MiscTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.hbase.util.Bytes;
-import org.junit.Assert;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mockito;
-@Category({ MiscTests.class, SmallTests.class })
+@Tag(MiscTests.TAG)
+@Tag(SmallTests.TAG)
+@ExtendWith(HBaseJupiterExtension.class)
public class TestCellUtil {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestCellUtil.class);
/**
* CellScannable used in test. Returns a {@link TestCellScanner}
@@ -269,7 +267,7 @@ private void consume(final CellScanner scanner, final int expected) throws IOExc
while (scanner.advance()) {
count++;
}
- Assert.assertEquals(expected, count);
+ assertEquals(expected, count);
}
@Test
@@ -281,43 +279,43 @@ public void testOverlappingKeys() {
byte[] d = Bytes.toBytes("d");
// overlaps
- Assert.assertTrue(PrivateCellUtil.overlappingKeys(a, b, a, b));
- Assert.assertTrue(PrivateCellUtil.overlappingKeys(a, c, a, b));
- Assert.assertTrue(PrivateCellUtil.overlappingKeys(a, b, a, c));
- Assert.assertTrue(PrivateCellUtil.overlappingKeys(b, c, a, c));
- Assert.assertTrue(PrivateCellUtil.overlappingKeys(a, c, b, c));
- Assert.assertTrue(PrivateCellUtil.overlappingKeys(a, d, b, c));
- Assert.assertTrue(PrivateCellUtil.overlappingKeys(b, c, a, d));
+ assertTrue(PrivateCellUtil.overlappingKeys(a, b, a, b));
+ assertTrue(PrivateCellUtil.overlappingKeys(a, c, a, b));
+ assertTrue(PrivateCellUtil.overlappingKeys(a, b, a, c));
+ assertTrue(PrivateCellUtil.overlappingKeys(b, c, a, c));
+ assertTrue(PrivateCellUtil.overlappingKeys(a, c, b, c));
+ assertTrue(PrivateCellUtil.overlappingKeys(a, d, b, c));
+ assertTrue(PrivateCellUtil.overlappingKeys(b, c, a, d));
- Assert.assertTrue(PrivateCellUtil.overlappingKeys(empty, b, a, b));
- Assert.assertTrue(PrivateCellUtil.overlappingKeys(empty, b, a, c));
+ assertTrue(PrivateCellUtil.overlappingKeys(empty, b, a, b));
+ assertTrue(PrivateCellUtil.overlappingKeys(empty, b, a, c));
- Assert.assertTrue(PrivateCellUtil.overlappingKeys(a, b, empty, b));
- Assert.assertTrue(PrivateCellUtil.overlappingKeys(a, b, empty, c));
+ assertTrue(PrivateCellUtil.overlappingKeys(a, b, empty, b));
+ assertTrue(PrivateCellUtil.overlappingKeys(a, b, empty, c));
- Assert.assertTrue(PrivateCellUtil.overlappingKeys(a, empty, a, b));
- Assert.assertTrue(PrivateCellUtil.overlappingKeys(a, empty, a, c));
+ assertTrue(PrivateCellUtil.overlappingKeys(a, empty, a, b));
+ assertTrue(PrivateCellUtil.overlappingKeys(a, empty, a, c));
- Assert.assertTrue(PrivateCellUtil.overlappingKeys(a, b, empty, empty));
- Assert.assertTrue(PrivateCellUtil.overlappingKeys(empty, empty, a, b));
+ assertTrue(PrivateCellUtil.overlappingKeys(a, b, empty, empty));
+ assertTrue(PrivateCellUtil.overlappingKeys(empty, empty, a, b));
// non overlaps
- Assert.assertFalse(PrivateCellUtil.overlappingKeys(a, b, c, d));
- Assert.assertFalse(PrivateCellUtil.overlappingKeys(c, d, a, b));
-
- Assert.assertFalse(PrivateCellUtil.overlappingKeys(b, c, c, d));
- Assert.assertFalse(PrivateCellUtil.overlappingKeys(b, c, c, empty));
- Assert.assertFalse(PrivateCellUtil.overlappingKeys(b, c, d, empty));
- Assert.assertFalse(PrivateCellUtil.overlappingKeys(c, d, b, c));
- Assert.assertFalse(PrivateCellUtil.overlappingKeys(c, empty, b, c));
- Assert.assertFalse(PrivateCellUtil.overlappingKeys(d, empty, b, c));
-
- Assert.assertFalse(PrivateCellUtil.overlappingKeys(b, c, a, b));
- Assert.assertFalse(PrivateCellUtil.overlappingKeys(b, c, empty, b));
- Assert.assertFalse(PrivateCellUtil.overlappingKeys(b, c, empty, a));
- Assert.assertFalse(PrivateCellUtil.overlappingKeys(a, b, b, c));
- Assert.assertFalse(PrivateCellUtil.overlappingKeys(empty, b, b, c));
- Assert.assertFalse(PrivateCellUtil.overlappingKeys(empty, a, b, c));
+ assertFalse(PrivateCellUtil.overlappingKeys(a, b, c, d));
+ assertFalse(PrivateCellUtil.overlappingKeys(c, d, a, b));
+
+ assertFalse(PrivateCellUtil.overlappingKeys(b, c, c, d));
+ assertFalse(PrivateCellUtil.overlappingKeys(b, c, c, empty));
+ assertFalse(PrivateCellUtil.overlappingKeys(b, c, d, empty));
+ assertFalse(PrivateCellUtil.overlappingKeys(c, d, b, c));
+ assertFalse(PrivateCellUtil.overlappingKeys(c, empty, b, c));
+ assertFalse(PrivateCellUtil.overlappingKeys(d, empty, b, c));
+
+ assertFalse(PrivateCellUtil.overlappingKeys(b, c, a, b));
+ assertFalse(PrivateCellUtil.overlappingKeys(b, c, empty, b));
+ assertFalse(PrivateCellUtil.overlappingKeys(b, c, empty, a));
+ assertFalse(PrivateCellUtil.overlappingKeys(a, b, b, c));
+ assertFalse(PrivateCellUtil.overlappingKeys(empty, b, b, c));
+ assertFalse(PrivateCellUtil.overlappingKeys(empty, a, b, c));
}
@Test
@@ -325,32 +323,32 @@ public void testFindCommonPrefixInFlatKey() {
// The whole key matching case
KeyValue kv1 =
new KeyValue(Bytes.toBytes("r1"), Bytes.toBytes("f1"), Bytes.toBytes("q1"), null);
- Assert.assertEquals(kv1.getKeyLength(),
+ assertEquals(kv1.getKeyLength(),
PrivateCellUtil.findCommonPrefixInFlatKey(kv1, kv1, true, true));
- Assert.assertEquals(kv1.getKeyLength(),
+ assertEquals(kv1.getKeyLength(),
PrivateCellUtil.findCommonPrefixInFlatKey(kv1, kv1, false, true));
- Assert.assertEquals(kv1.getKeyLength() - KeyValue.TIMESTAMP_TYPE_SIZE,
+ assertEquals(kv1.getKeyLength() - KeyValue.TIMESTAMP_TYPE_SIZE,
PrivateCellUtil.findCommonPrefixInFlatKey(kv1, kv1, true, false));
// The rk length itself mismatch
KeyValue kv2 =
new KeyValue(Bytes.toBytes("r12"), Bytes.toBytes("f1"), Bytes.toBytes("q1"), null);
- Assert.assertEquals(1, PrivateCellUtil.findCommonPrefixInFlatKey(kv1, kv2, true, true));
+ assertEquals(1, PrivateCellUtil.findCommonPrefixInFlatKey(kv1, kv2, true, true));
// part of rk is same
KeyValue kv3 =
new KeyValue(Bytes.toBytes("r14"), Bytes.toBytes("f1"), Bytes.toBytes("q1"), null);
- Assert.assertEquals(KeyValue.ROW_LENGTH_SIZE + Bytes.toBytes("r1").length,
+ assertEquals(KeyValue.ROW_LENGTH_SIZE + Bytes.toBytes("r1").length,
PrivateCellUtil.findCommonPrefixInFlatKey(kv2, kv3, true, true));
// entire rk is same but different cf name
KeyValue kv4 =
new KeyValue(Bytes.toBytes("r14"), Bytes.toBytes("f2"), Bytes.toBytes("q1"), null);
- Assert.assertEquals(
+ assertEquals(
KeyValue.ROW_LENGTH_SIZE + kv3.getRowLength() + KeyValue.FAMILY_LENGTH_SIZE
+ Bytes.toBytes("f").length,
PrivateCellUtil.findCommonPrefixInFlatKey(kv3, kv4, false, true));
// rk and family are same and part of qualifier
KeyValue kv5 =
new KeyValue(Bytes.toBytes("r14"), Bytes.toBytes("f2"), Bytes.toBytes("q123"), null);
- Assert.assertEquals(
+ assertEquals(
KeyValue.ROW_LENGTH_SIZE + kv3.getRowLength() + KeyValue.FAMILY_LENGTH_SIZE
+ kv4.getFamilyLength() + kv4.getQualifierLength(),
PrivateCellUtil.findCommonPrefixInFlatKey(kv4, kv5, true, true));
@@ -358,18 +356,18 @@ public void testFindCommonPrefixInFlatKey() {
KeyValue kv6 = new KeyValue(Bytes.toBytes("rk"), 1234L);
KeyValue kv7 = new KeyValue(Bytes.toBytes("rk"), 1235L);
// only last byte out of 8 ts bytes in ts part differs
- Assert.assertEquals(
+ assertEquals(
KeyValue.ROW_LENGTH_SIZE + kv6.getRowLength() + KeyValue.FAMILY_LENGTH_SIZE
+ kv6.getFamilyLength() + kv6.getQualifierLength() + 7,
PrivateCellUtil.findCommonPrefixInFlatKey(kv6, kv7, true, true));
// rk, cf, q and ts are same. Only type differs
KeyValue kv8 = new KeyValue(Bytes.toBytes("rk"), 1234L, KeyValue.Type.Delete);
- Assert.assertEquals(
+ assertEquals(
KeyValue.ROW_LENGTH_SIZE + kv6.getRowLength() + KeyValue.FAMILY_LENGTH_SIZE
+ kv6.getFamilyLength() + kv6.getQualifierLength() + KeyValue.TIMESTAMP_SIZE,
PrivateCellUtil.findCommonPrefixInFlatKey(kv6, kv8, true, true));
// With out TS_TYPE check
- Assert.assertEquals(
+ assertEquals(
KeyValue.ROW_LENGTH_SIZE + kv6.getRowLength() + KeyValue.FAMILY_LENGTH_SIZE
+ kv6.getFamilyLength() + kv6.getQualifierLength(),
PrivateCellUtil.findCommonPrefixInFlatKey(kv6, kv8, true, false));
@@ -423,10 +421,10 @@ public void testToString1() {
System.out.println("nonVerbose=" + nonVerbose);
System.out.println("verbose=" + verbose);
- Assert.assertEquals(String.format("%s/%s:%s/%d/%s/vlen=%s/seqid=%s", row, family, qualifier,
- timestamp, type.toString(), Bytes.toBytes(value).length, seqId), nonVerbose);
+ assertEquals(String.format("%s/%s:%s/%d/%s/vlen=%s/seqid=%s", row, family, qualifier, timestamp,
+ type.toString(), Bytes.toBytes(value).length, seqId), nonVerbose);
- Assert.assertEquals(String.format("%s/%s:%s/%d/%s/vlen=%s/seqid=%s/%s", row, family, qualifier,
+ assertEquals(String.format("%s/%s:%s/%d/%s/vlen=%s/seqid=%s/%s", row, family, qualifier,
timestamp, type.toString(), Bytes.toBytes(value).length, seqId, value), verbose);
// TODO: test with tags
diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/TestChoreService.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/TestChoreService.java
index 8828ac7bd1b5..685c00dd0422 100644
--- a/hbase-common/src/test/java/org/apache/hadoop/hbase/TestChoreService.java
+++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/TestChoreService.java
@@ -17,9 +17,9 @@
*/
package org.apache.hadoop.hbase;
-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.Mockito.atLeastOnce;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
@@ -30,40 +30,37 @@
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.testclassification.MiscTests;
import org.apache.hadoop.hbase.util.Threads;
-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;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-@Category({ MiscTests.class, MediumTests.class })
+@Tag(MiscTests.TAG)
+@Tag(MediumTests.TAG)
+@ExtendWith(HBaseJupiterExtension.class)
public class TestChoreService {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestChoreService.class);
-
private static final Logger LOG = LoggerFactory.getLogger(TestChoreService.class);
private static final Configuration CONF = HBaseConfiguration.create();
- @Rule
- public TestName name = new TestName();
-
private int initialCorePoolSize = 3;
private ChoreService service;
- @Before
- public void setUp() {
- service = new ChoreService(name.getMethodName(), initialCorePoolSize, false);
+ private String testName;
+
+ @BeforeEach
+ public void setUp(TestInfo testInfo) {
+ testName = testInfo.getTestMethod().get().getName();
+ service = new ChoreService(testName, initialCorePoolSize, false);
}
- @After
+ @AfterEach
public void tearDown() {
shutdownService(service);
}
@@ -286,10 +283,10 @@ protected void chore() {
}
};
- assertEquals("Name construction failed", NAME, chore1.getName());
- assertEquals("Period construction failed", PERIOD, chore1.getPeriod());
- assertEquals("Initial Delay construction failed", VALID_DELAY, chore1.getInitialDelay());
- assertEquals("TimeUnit construction failed", UNIT, chore1.getTimeUnit());
+ assertEquals(NAME, chore1.getName(), "Name construction failed");
+ assertEquals(PERIOD, chore1.getPeriod(), "Period construction failed");
+ assertEquals(VALID_DELAY, chore1.getInitialDelay(), "Initial Delay construction failed");
+ assertEquals(UNIT, chore1.getTimeUnit(), "TimeUnit construction failed");
ScheduledChore invalidDelayChore =
new ScheduledChore(NAME, new SampleStopper(), PERIOD, INVALID_DELAY, UNIT) {
@@ -299,8 +296,8 @@ protected void chore() {
}
};
- assertEquals("Initial Delay should be set to 0 when invalid", 0,
- invalidDelayChore.getInitialDelay());
+ assertEquals(0, invalidDelayChore.getInitialDelay(),
+ "Initial Delay should be set to 0 when invalid");
}
@Test
@@ -340,10 +337,10 @@ public void testFrequencyOfChores() throws InterruptedException {
service.scheduleChore(chore);
Thread.sleep(10 * period + delta);
- assertEquals("10 periods have elapsed.", 11, chore.getCountOfChoreCalls());
+ assertEquals(11, chore.getCountOfChoreCalls(), "10 periods have elapsed.");
Thread.sleep(10 * period + delta);
- assertEquals("20 periods have elapsed.", 21, chore.getCountOfChoreCalls());
+ assertEquals(21, chore.getCountOfChoreCalls(), "20 periods have elapsed.");
}
public void shutdownService(ChoreService service) {
@@ -359,7 +356,7 @@ public void testForceTrigger() throws InterruptedException {
service.scheduleChore(chore);
Thread.sleep(10 * period + delta);
- assertEquals("10 periods have elapsed.", 11, chore.getCountOfChoreCalls());
+ assertEquals(11, chore.getCountOfChoreCalls(), "10 periods have elapsed.");
// Force five runs of the chore to occur, sleeping between triggers to ensure the
// chore has time to run
@@ -374,19 +371,19 @@ public void testForceTrigger() throws InterruptedException {
chore.triggerNow();
Thread.sleep(delta);
- assertEquals("Trigger was called 5 times after 10 periods.", 16, chore.getCountOfChoreCalls());
+ assertEquals(16, chore.getCountOfChoreCalls(), "Trigger was called 5 times after 10 periods.");
Thread.sleep(10 * period + delta);
// Be loosey-goosey. It used to be '26' but it was a big flakey relying on timing.
- assertTrue("Expected at least 16 invocations, instead got " + chore.getCountOfChoreCalls(),
- chore.getCountOfChoreCalls() > 16);
+ assertTrue(chore.getCountOfChoreCalls() > 16,
+ "Expected at least 16 invocations, instead got " + chore.getCountOfChoreCalls());
}
@Test
public void testCorePoolIncrease() throws InterruptedException {
- assertEquals("Setting core pool size gave unexpected results.", initialCorePoolSize,
- service.getCorePoolSize());
+ assertEquals(initialCorePoolSize, service.getCorePoolSize(),
+ "Setting core pool size gave unexpected results.");
final int slowChorePeriod = 100;
SlowChore slowChore1 = new SlowChore("slowChore1", slowChorePeriod);
@@ -398,22 +395,22 @@ public void testCorePoolIncrease() throws InterruptedException {
service.scheduleChore(slowChore3);
Thread.sleep(slowChorePeriod * 10);
- assertEquals("Should not create more pools than scheduled chores", 3,
- service.getCorePoolSize());
+ assertEquals(3, service.getCorePoolSize(),
+ "Should not create more pools than scheduled chores");
SlowChore slowChore4 = new SlowChore("slowChore4", slowChorePeriod);
service.scheduleChore(slowChore4);
Thread.sleep(slowChorePeriod * 10);
- assertEquals("Chores are missing their start time. Should expand core pool size", 4,
- service.getCorePoolSize());
+ assertEquals(4, service.getCorePoolSize(),
+ "Chores are missing their start time. Should expand core pool size");
SlowChore slowChore5 = new SlowChore("slowChore5", slowChorePeriod);
service.scheduleChore(slowChore5);
Thread.sleep(slowChorePeriod * 10);
- assertEquals("Chores are missing their start time. Should expand core pool size", 5,
- service.getCorePoolSize());
+ assertEquals(5, service.getCorePoolSize(),
+ "Chores are missing their start time. Should expand core pool size");
}
@Test
@@ -430,20 +427,20 @@ public void testCorePoolDecrease() throws InterruptedException {
service.scheduleChore(slowChore3);
Thread.sleep(chorePeriod * 10);
- assertEquals("Should not create more pools than scheduled chores",
- service.getNumberOfScheduledChores(), service.getCorePoolSize());
+ assertEquals(service.getNumberOfScheduledChores(), service.getCorePoolSize(),
+ "Should not create more pools than scheduled chores");
SlowChore slowChore4 = new SlowChore("slowChore4", chorePeriod);
service.scheduleChore(slowChore4);
Thread.sleep(chorePeriod * 10);
- assertEquals("Chores are missing their start time. Should expand core pool size",
- service.getNumberOfScheduledChores(), service.getCorePoolSize());
+ assertEquals(service.getNumberOfScheduledChores(), service.getCorePoolSize(),
+ "Chores are missing their start time. Should expand core pool size");
SlowChore slowChore5 = new SlowChore("slowChore5", chorePeriod);
service.scheduleChore(slowChore5);
Thread.sleep(chorePeriod * 10);
- assertEquals("Chores are missing their start time. Should expand core pool size",
- service.getNumberOfScheduledChores(), service.getCorePoolSize());
+ assertEquals(service.getNumberOfScheduledChores(), service.getCorePoolSize(),
+ "Chores are missing their start time. Should expand core pool size");
assertEquals(5, service.getNumberOfChoresMissingStartTime());
// Now we begin to cancel the chores that caused an increase in the core thread pool of the
@@ -496,21 +493,21 @@ public void testNumberOfRunningChores() throws InterruptedException {
service.scheduleChore(dn5);
Thread.sleep(sleepTime);
- assertEquals("Scheduled chore mismatch", 5, service.getNumberOfScheduledChores());
+ assertEquals(5, service.getNumberOfScheduledChores(), "Scheduled chore mismatch");
dn1.cancel();
Thread.sleep(sleepTime);
- assertEquals("Scheduled chore mismatch", 4, service.getNumberOfScheduledChores());
+ assertEquals(4, service.getNumberOfScheduledChores(), "Scheduled chore mismatch");
dn2.cancel();
dn3.cancel();
dn4.cancel();
Thread.sleep(sleepTime);
- assertEquals("Scheduled chore mismatch", 1, service.getNumberOfScheduledChores());
+ assertEquals(1, service.getNumberOfScheduledChores(), "Scheduled chore mismatch");
dn5.cancel();
Thread.sleep(sleepTime);
- assertEquals("Scheduled chore mismatch", 0, service.getNumberOfScheduledChores());
+ assertEquals(0, service.getNumberOfScheduledChores(), "Scheduled chore mismatch");
}
@Test
@@ -596,10 +593,10 @@ public void testMaximumChoreServiceThreads() throws InterruptedException {
}
@Test
- public void testChangingChoreServices() throws InterruptedException {
+ public void testChangingChoreServices(TestInfo testInfo) throws InterruptedException {
final int period = 100;
final int sleepTime = 10;
- ChoreService anotherService = new ChoreService(name.getMethodName() + "_2");
+ ChoreService anotherService = new ChoreService(testInfo.getTestMethod().get().getName() + "_2");
ScheduledChore chore = new DoNothingChore("sample", period);
try {
diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/TestClassFinder.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/TestClassFinder.java
index 043ee3a3049e..7fcd15245547 100644
--- a/hbase-common/src/test/java/org/apache/hadoop/hbase/TestClassFinder.java
+++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/TestClassFinder.java
@@ -19,9 +19,9 @@
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.arrayContainingInAnyOrder;
-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 java.io.File;
import java.io.FileInputStream;
@@ -41,26 +41,22 @@
import javax.tools.ToolProvider;
import org.apache.hadoop.hbase.testclassification.MiscTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
-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.Tag;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-@Category({ MiscTests.class, SmallTests.class })
+@Tag(MiscTests.TAG)
+@Tag(SmallTests.TAG)
+@ExtendWith(HBaseJupiterExtension.class)
public class TestClassFinder {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestClassFinder.class);
private static final Logger LOG = LoggerFactory.getLogger(TestClassFinder.class);
- @Rule
- public TestName name = new TestName();
private static final HBaseCommonTestingUtil testUtil = new HBaseCommonTestingUtil();
private static final String BASEPKG = "tfcpkg";
private static final String PREFIX = "Prefix";
@@ -75,7 +71,7 @@ public class TestClassFinder {
private static CustomClassloader classLoader;
- @BeforeClass
+ @BeforeAll
public static void createTestDir() throws IOException {
basePath = testUtil.getDataTestDir(TestClassFinder.class.getSimpleName()).toString();
if (!basePath.endsWith("/")) {
@@ -92,7 +88,7 @@ public static void createTestDir() throws IOException {
classLoader = new CustomClassloader(new URL[0], ClassLoader.getSystemClassLoader());
}
- @AfterClass
+ @AfterAll
public static void deleteTestDir() {
testUtil.cleanupTestDir(TestClassFinder.class.getSimpleName());
}
@@ -125,10 +121,10 @@ public void testClassFinderHandlesConflicts() throws Exception {
}
@Test
- public void testClassFinderHandlesNestedPackages() throws Exception {
+ public void testClassFinderHandlesNestedPackages(TestInfo testInfo) throws Exception {
final String NESTED = ".nested";
- final String CLASSNAME1 = name.getMethodName() + "1";
- final String CLASSNAME2 = name.getMethodName() + "2";
+ final String CLASSNAME1 = testInfo.getTestMethod().get().getName() + "1";
+ final String CLASSNAME2 = testInfo.getTestMethod().get().getName() + "2";
long counter = testCounter.incrementAndGet();
FileAndPath c1 = compileTestClass(counter, "", "c1");
FileAndPath c2 = compileTestClass(counter, NESTED, CLASSNAME1);
@@ -147,9 +143,9 @@ public void testClassFinderHandlesNestedPackages() throws Exception {
}
@Test
- public void testClassFinderFiltersByNameInJar() throws Exception {
+ public void testClassFinderFiltersByNameInJar(TestInfo testInfo) throws Exception {
final long counter = testCounter.incrementAndGet();
- final String classNamePrefix = name.getMethodName();
+ final String classNamePrefix = testInfo.getTestMethod().get().getName();
LOG.info("Created jar " + createAndLoadJar("", classNamePrefix, counter));
ClassFinder.FileNameFilter notExcNameFilter =
@@ -162,9 +158,9 @@ public void testClassFinderFiltersByNameInJar() throws Exception {
}
@Test
- public void testClassFinderFiltersByClassInJar() throws Exception {
+ public void testClassFinderFiltersByClassInJar(TestInfo testInfo) throws Exception {
final long counter = testCounter.incrementAndGet();
- final String classNamePrefix = name.getMethodName();
+ final String classNamePrefix = testInfo.getTestMethod().get().getName();
LOG.info("Created jar " + createAndLoadJar("", classNamePrefix, counter));
final ClassFinder.ClassFilter notExcClassFilter = c -> !c.getSimpleName().startsWith(PREFIX);
@@ -184,8 +180,8 @@ private static String createAndLoadJar(final String packageNameSuffix,
}
@Test
- public void testClassFinderFiltersByPathInJar() throws Exception {
- final String CLASSNAME = name.getMethodName();
+ public void testClassFinderFiltersByPathInJar(TestInfo testInfo) throws Exception {
+ final String CLASSNAME = testInfo.getTestMethod().get().getName();
long counter = testCounter.incrementAndGet();
FileAndPath c1 = compileTestClass(counter, "", CLASSNAME);
FileAndPath c2 = compileTestClass(counter, "", "c2");
@@ -207,17 +203,17 @@ public void testClassFinderFiltersByPathInJar() throws Exception {
}
@Test
- public void testClassFinderCanFindClassesInDirs() throws Exception {
+ public void testClassFinderCanFindClassesInDirs(TestInfo testInfo) throws Exception {
// Make some classes for us to find. Class naming and packaging is kinda cryptic.
// TODO: Fix.
final long counter = testCounter.incrementAndGet();
- final String classNamePrefix = name.getMethodName();
- String pkgNameSuffix = name.getMethodName();
+ final String classNamePrefix = testInfo.getTestMethod().get().getName();
+ String pkgNameSuffix = testInfo.getTestMethod().get().getName();
LOG.info("Created jar " + createAndLoadJar(pkgNameSuffix, classNamePrefix, counter));
ClassFinder allClassesFinder = new ClassFinder(classLoader);
String pkgName = makePackageName(pkgNameSuffix, counter);
Set> allClasses = allClassesFinder.findClasses(pkgName, false);
- assertTrue("Classes in " + pkgName, allClasses.size() > 0);
+ assertTrue(allClasses.size() > 0, "Classes in " + pkgName);
String classNameToFind = classNamePrefix + counter;
assertTrue(contains(allClasses, classNameToFind));
}
@@ -232,12 +228,12 @@ private static boolean contains(final Set> classes, final String simple
}
@Test
- public void testClassFinderFiltersByNameInDirs() throws Exception {
+ public void testClassFinderFiltersByNameInDirs(TestInfo testInfo) throws Exception {
// Make some classes for us to find. Class naming and packaging is kinda cryptic.
// TODO: Fix.
final long counter = testCounter.incrementAndGet();
- final String classNamePrefix = name.getMethodName();
- String pkgNameSuffix = name.getMethodName();
+ final String classNamePrefix = testInfo.getTestMethod().get().getName();
+ String pkgNameSuffix = testInfo.getTestMethod().get().getName();
LOG.info("Created jar " + createAndLoadJar(pkgNameSuffix, classNamePrefix, counter));
final String classNameToFilterOut = classNamePrefix + counter;
final ClassFinder.FileNameFilter notThisFilter =
@@ -245,7 +241,7 @@ public void testClassFinderFiltersByNameInDirs() throws Exception {
String pkgName = makePackageName(pkgNameSuffix, counter);
ClassFinder allClassesFinder = new ClassFinder(classLoader);
Set> allClasses = allClassesFinder.findClasses(pkgName, false);
- assertTrue("Classes in " + pkgName, allClasses.size() > 0);
+ assertTrue(allClasses.size() > 0, "Classes in " + pkgName);
ClassFinder notThisClassFinder = new ClassFinder(null, notThisFilter, null, classLoader);
Set> notAllClasses = notThisClassFinder.findClasses(pkgName, false);
assertFalse(contains(notAllClasses, classNameToFilterOut));
@@ -253,19 +249,19 @@ public void testClassFinderFiltersByNameInDirs() throws Exception {
}
@Test
- public void testClassFinderFiltersByClassInDirs() throws Exception {
+ public void testClassFinderFiltersByClassInDirs(TestInfo testInfo) throws Exception {
// Make some classes for us to find. Class naming and packaging is kinda cryptic.
// TODO: Fix.
final long counter = testCounter.incrementAndGet();
- final String classNamePrefix = name.getMethodName();
- String pkgNameSuffix = name.getMethodName();
+ final String classNamePrefix = testInfo.getTestMethod().get().getName();
+ String pkgNameSuffix = testInfo.getTestMethod().get().getName();
LOG.info("Created jar " + createAndLoadJar(pkgNameSuffix, classNamePrefix, counter));
final Class> clazz = makeClass(pkgNameSuffix, classNamePrefix, counter);
final ClassFinder.ClassFilter notThisFilter = c -> c != clazz;
String pkgName = makePackageName(pkgNameSuffix, counter);
ClassFinder allClassesFinder = new ClassFinder(classLoader);
Set> allClasses = allClassesFinder.findClasses(pkgName, false);
- assertTrue("Classes in " + pkgName, allClasses.size() > 0);
+ assertTrue(allClasses.size() > 0, "Classes in " + pkgName);
ClassFinder notThisClassFinder = new ClassFinder(null, null, notThisFilter, classLoader);
Set> notAllClasses = notThisClassFinder.findClasses(pkgName, false);
assertFalse(contains(notAllClasses, clazz.getSimpleName()));
diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/TestHBaseConfiguration.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/TestHBaseConfiguration.java
index e959f77a7220..2def5dcb2772 100644
--- a/hbase-common/src/test/java/org/apache/hadoop/hbase/TestHBaseConfiguration.java
+++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/TestHBaseConfiguration.java
@@ -17,9 +17,10 @@
*/
package org.apache.hadoop.hbase;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+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.File;
import java.io.IOException;
@@ -30,27 +31,25 @@
import org.apache.hadoop.hbase.security.User;
import org.apache.hadoop.hbase.testclassification.MiscTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
-import org.junit.AfterClass;
-import org.junit.Assert;
-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.Tag;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.hbase.thirdparty.com.google.common.collect.ImmutableMap;
-@Category({ MiscTests.class, SmallTests.class })
+@Tag(MiscTests.TAG)
+@Tag(SmallTests.TAG)
+@ExtendWith(HBaseJupiterExtension.class)
public class TestHBaseConfiguration {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestHBaseConfiguration.class);
private static final Logger LOG = LoggerFactory.getLogger(TestHBaseConfiguration.class);
private static HBaseCommonTestingUtil UTIL = new HBaseCommonTestingUtil();
- @AfterClass
+ @AfterAll
public static void tearDown() throws IOException {
UTIL.cleanupTestDir();
}
@@ -104,13 +103,13 @@ public void testGetPassword() throws Exception {
public void testSecurityConfCaseInsensitive() {
Configuration conf = HBaseConfiguration.create();
conf.set("hbase.security.authentication", "kerberos");
- Assert.assertTrue(User.isHBaseSecurityEnabled(conf));
+ assertTrue(User.isHBaseSecurityEnabled(conf));
conf.set("hbase.security.authentication", "KERBEROS");
- Assert.assertTrue(User.isHBaseSecurityEnabled(conf));
+ assertTrue(User.isHBaseSecurityEnabled(conf));
conf.set("hbase.security.authentication", "KERBeros");
- Assert.assertTrue(User.isHBaseSecurityEnabled(conf));
+ assertTrue(User.isHBaseSecurityEnabled(conf));
}
@Test
diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/TestHDFSBlocksDistribution.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/TestHDFSBlocksDistribution.java
index 62011f13ffc0..74a0910e5047 100644
--- a/hbase-common/src/test/java/org/apache/hadoop/hbase/TestHDFSBlocksDistribution.java
+++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/TestHDFSBlocksDistribution.java
@@ -17,8 +17,8 @@
*/
package org.apache.hadoop.hbase;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
import java.util.HashMap;
import java.util.Map;
@@ -26,39 +26,37 @@
import org.apache.hadoop.hbase.testclassification.MiscTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.hbase.util.DNS;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
-@Category({ MiscTests.class, SmallTests.class })
+@Tag(MiscTests.TAG)
+@Tag(SmallTests.TAG)
+@ExtendWith(HBaseJupiterExtension.class)
public class TestHDFSBlocksDistribution {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestHDFSBlocksDistribution.class);
-
@Test
public void testAddHostsAndBlockWeight() throws Exception {
HDFSBlocksDistribution distribution = new HDFSBlocksDistribution();
distribution.addHostsAndBlockWeight(null, 100);
- assertEquals("Expecting no hosts weights", 0, distribution.getHostAndWeights().size());
+ assertEquals(0, distribution.getHostAndWeights().size(), "Expecting no hosts weights");
distribution.addHostsAndBlockWeight(new String[0], 100);
- assertEquals("Expecting no hosts weights", 0, distribution.getHostAndWeights().size());
+ assertEquals(0, distribution.getHostAndWeights().size(), "Expecting no hosts weights");
distribution.addHostsAndBlockWeight(new String[] { "test" }, 101);
- assertEquals("Should be one host", 1, distribution.getHostAndWeights().size());
+ assertEquals(1, distribution.getHostAndWeights().size(), "Should be one host");
distribution.addHostsAndBlockWeight(new String[] { "test" }, 202);
- assertEquals("Should be one host", 1, distribution.getHostAndWeights().size());
- assertEquals("test host should have weight 303", 303,
- distribution.getHostAndWeights().get("test").getWeight());
+ assertEquals(1, distribution.getHostAndWeights().size(), "Should be one host");
+ assertEquals(303, distribution.getHostAndWeights().get("test").getWeight(),
+ "test host should have weight 303");
distribution.addHostsAndBlockWeight(new String[] { "testTwo" }, 222);
- assertEquals("Should be two hosts", 2, distribution.getHostAndWeights().size());
- assertEquals("Total weight should be 525", 525, distribution.getUniqueBlocksTotalWeight());
+ assertEquals(2, distribution.getHostAndWeights().size(), "Should be two hosts");
+ assertEquals(525, distribution.getUniqueBlocksTotalWeight(), "Total weight should be 525");
distribution.addHostsAndBlockWeight(new String[] { "test" }, 100,
new StorageType[] { StorageType.SSD });
- assertEquals("test host should have weight 403", 403,
- distribution.getHostAndWeights().get("test").getWeight());
- assertEquals("test host should have weight for ssd 100", 100,
- distribution.getHostAndWeights().get("test").getWeightForSsd());
+ assertEquals(403, distribution.getHostAndWeights().get("test").getWeight(),
+ "test host should have weight 403");
+ assertEquals(100, distribution.getHostAndWeights().get("test").getWeightForSsd(),
+ "test host should have weight for ssd 100");
}
private static final class MockHDFSBlocksDistribution extends HDFSBlocksDistribution {
@@ -75,25 +73,25 @@ public Map getHostAndWeights() {
public void testAdd() throws Exception {
HDFSBlocksDistribution distribution = new HDFSBlocksDistribution();
distribution.add(new MockHDFSBlocksDistribution());
- assertEquals("Expecting no hosts weights", 0, distribution.getHostAndWeights().size());
+ assertEquals(0, distribution.getHostAndWeights().size(), "Expecting no hosts weights");
distribution.addHostsAndBlockWeight(new String[] { "test" }, 10);
- assertEquals("Should be one host", 1, distribution.getHostAndWeights().size());
+ assertEquals(1, distribution.getHostAndWeights().size(), "Should be one host");
distribution.add(new MockHDFSBlocksDistribution());
- assertEquals("Should be one host", 1, distribution.getHostAndWeights().size());
- assertEquals("Total weight should be 10", 10, distribution.getUniqueBlocksTotalWeight());
+ assertEquals(1, distribution.getHostAndWeights().size(), "Should be one host");
+ assertEquals(10, distribution.getUniqueBlocksTotalWeight(), "Total weight should be 10");
}
@Test
public void testLocalHostCompatibility() throws Exception {
String currentHost = DNS.getDefaultHost("default", "default");
HDFSBlocksDistribution distribution = new HDFSBlocksDistribution();
- assertEquals("Locality should be 0.0", 0.0, distribution.getBlockLocalityIndex(currentHost),
- 0.01);
+ assertEquals(0.0, distribution.getBlockLocalityIndex(currentHost), 0.01,
+ "Locality should be 0.0");
distribution.addHostsAndBlockWeight(new String[] { "localhost" }, 10);
- assertEquals("Should be one host", 1, distribution.getHostAndWeights().size());
- assertEquals("Locality should be 0.0", 0.0, distribution.getBlockLocalityIndex("test"), 0.01);
- assertNotEquals("Locality should be 0.0", 0.0, distribution.getBlockLocalityIndex(currentHost),
- 0.01);
+ assertEquals(1, distribution.getHostAndWeights().size(), "Should be one host");
+ assertEquals(0.0, distribution.getBlockLocalityIndex("test"), 0.01, "Locality should be 0.0");
+ assertNotEquals(0.0, distribution.getBlockLocalityIndex(currentHost), 0.01,
+ "Locality should be 0.0");
}
}
diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/TestIndividualBytesFieldCell.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/TestIndividualBytesFieldCell.java
index 0a1cf713fea9..9fe4fc2fb80f 100644
--- a/hbase-common/src/test/java/org/apache/hadoop/hbase/TestIndividualBytesFieldCell.java
+++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/TestIndividualBytesFieldCell.java
@@ -17,9 +17,10 @@
*/
package org.apache.hadoop.hbase;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
import java.nio.ByteBuffer;
@@ -27,22 +28,20 @@
import org.apache.hadoop.hbase.testclassification.MiscTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.hbase.util.Bytes;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-@Category({ MiscTests.class, SmallTests.class })
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+
+@Tag(MiscTests.TAG)
+@Tag(SmallTests.TAG)
+@ExtendWith(HBaseJupiterExtension.class)
public class TestIndividualBytesFieldCell {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestIndividualBytesFieldCell.class);
-
private static IndividualBytesFieldCell ic0 = null;
private static KeyValue kv0 = null;
- @BeforeClass
+ @BeforeAll
public static void testConstructorAndVerify() {
// Immutable inputs
byte[] row = Bytes.toBytes("immutable-row");
@@ -185,46 +184,58 @@ public void testIfExtendedCellImplemented() {
ec.deepClone(); // Do something with ec
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testIllegalRow() {
- new IndividualBytesFieldCell(Bytes.toBytes("row"), 0, 100, HConstants.EMPTY_BYTE_ARRAY, 0, 0,
- HConstants.EMPTY_BYTE_ARRAY, 0, 0, 0L, KeyValue.Type.Put, 0, HConstants.EMPTY_BYTE_ARRAY, 0,
- 0, HConstants.EMPTY_BYTE_ARRAY, 0, 0);
+ assertThrows(IllegalArgumentException.class, () -> {
+ new IndividualBytesFieldCell(Bytes.toBytes("row"), 0, 100, HConstants.EMPTY_BYTE_ARRAY, 0, 0,
+ HConstants.EMPTY_BYTE_ARRAY, 0, 0, 0L, KeyValue.Type.Put, 0, HConstants.EMPTY_BYTE_ARRAY, 0,
+ 0, HConstants.EMPTY_BYTE_ARRAY, 0, 0);
+ });
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testIllegalFamily() {
- new IndividualBytesFieldCell(Bytes.toBytes("row"), 0, 3, Bytes.toBytes("family"), 0, 100,
- HConstants.EMPTY_BYTE_ARRAY, 0, 0, 0L, KeyValue.Type.Put, 0, HConstants.EMPTY_BYTE_ARRAY, 0,
- 0, HConstants.EMPTY_BYTE_ARRAY, 0, 0);
+ assertThrows(IllegalArgumentException.class, () -> {
+ new IndividualBytesFieldCell(Bytes.toBytes("row"), 0, 3, Bytes.toBytes("family"), 0, 100,
+ HConstants.EMPTY_BYTE_ARRAY, 0, 0, 0L, KeyValue.Type.Put, 0, HConstants.EMPTY_BYTE_ARRAY, 0,
+ 0, HConstants.EMPTY_BYTE_ARRAY, 0, 0);
+ });
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testIllegalQualifier() {
- new IndividualBytesFieldCell(Bytes.toBytes("row"), 0, 3, Bytes.toBytes("family"), 0, 6,
- Bytes.toBytes("qualifier"), 0, 100, 0L, KeyValue.Type.Put, 0, HConstants.EMPTY_BYTE_ARRAY, 0,
- 0, HConstants.EMPTY_BYTE_ARRAY, 0, 0);
+ assertThrows(IllegalArgumentException.class, () -> {
+ new IndividualBytesFieldCell(Bytes.toBytes("row"), 0, 3, Bytes.toBytes("family"), 0, 6,
+ Bytes.toBytes("qualifier"), 0, 100, 0L, KeyValue.Type.Put, 0, HConstants.EMPTY_BYTE_ARRAY,
+ 0, 0, HConstants.EMPTY_BYTE_ARRAY, 0, 0);
+ });
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testIllegalTimestamp() {
- new IndividualBytesFieldCell(Bytes.toBytes("row"), 0, 3, Bytes.toBytes("family"), 0, 6,
- Bytes.toBytes("qualifier"), 0, 9, -100, KeyValue.Type.Put, 0, HConstants.EMPTY_BYTE_ARRAY, 0,
- 0, HConstants.EMPTY_BYTE_ARRAY, 0, 0);
+ assertThrows(IllegalArgumentException.class, () -> {
+ new IndividualBytesFieldCell(Bytes.toBytes("row"), 0, 3, Bytes.toBytes("family"), 0, 6,
+ Bytes.toBytes("qualifier"), 0, 9, -100, KeyValue.Type.Put, 0, HConstants.EMPTY_BYTE_ARRAY,
+ 0, 0, HConstants.EMPTY_BYTE_ARRAY, 0, 0);
+ });
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testIllegalValue() {
- new IndividualBytesFieldCell(Bytes.toBytes("row"), 0, 3, Bytes.toBytes("family"), 0, 6,
- Bytes.toBytes("qualifier"), 0, 9, 0L, KeyValue.Type.Put, 0, Bytes.toBytes("value"), 0, 100,
- HConstants.EMPTY_BYTE_ARRAY, 0, 0);
+ assertThrows(IllegalArgumentException.class, () -> {
+ new IndividualBytesFieldCell(Bytes.toBytes("row"), 0, 3, Bytes.toBytes("family"), 0, 6,
+ Bytes.toBytes("qualifier"), 0, 9, 0L, KeyValue.Type.Put, 0, Bytes.toBytes("value"), 0, 100,
+ HConstants.EMPTY_BYTE_ARRAY, 0, 0);
+ });
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testIllegalTags() {
- new IndividualBytesFieldCell(Bytes.toBytes("row"), 0, 3, Bytes.toBytes("family"), 0, 6,
- Bytes.toBytes("qualifier"), 0, 9, 0L, KeyValue.Type.Put, 0, Bytes.toBytes("value"), 0, 5,
- Bytes.toBytes("tags"), 0, 100);
+ assertThrows(IllegalArgumentException.class, () -> {
+ new IndividualBytesFieldCell(Bytes.toBytes("row"), 0, 3, Bytes.toBytes("family"), 0, 6,
+ Bytes.toBytes("qualifier"), 0, 9, 0L, KeyValue.Type.Put, 0, Bytes.toBytes("value"), 0, 5,
+ Bytes.toBytes("tags"), 0, 100);
+ });
}
@Test
diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/TestKeyValue.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/TestKeyValue.java
index 1644a6f1fce7..b49d8d467946 100644
--- a/hbase-common/src/test/java/org/apache/hadoop/hbase/TestKeyValue.java
+++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/TestKeyValue.java
@@ -17,13 +17,13 @@
*/
package org.apache.hadoop.hbase;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-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.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -38,17 +38,14 @@
import org.apache.hadoop.hbase.util.ByteBufferUtils;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-@Category(SmallTests.class)
+@org.junit.jupiter.api.Tag(SmallTests.TAG)
+@ExtendWith(HBaseJupiterExtension.class)
public class TestKeyValue {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestKeyValue.class);
private static final Logger LOG = LoggerFactory.getLogger(TestKeyValue.class);
@Test
@@ -719,7 +716,7 @@ public void testCheckKeyValueBytesFailureCase() throws Exception {
fail("Should fail when parse key value from an invalid bytes for case#" + i + ". " + c);
}
} catch (IllegalArgumentException e) {
- assertEquals("Case#" + i + " failed," + c, c.getExpectedMessage(), e.getMessage());
+ assertEquals(c.getExpectedMessage(), e.getMessage(), "Case#" + i + " failed," + c);
}
}
}
diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/TestServerName.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/TestServerName.java
index c37d0c25d888..9b9f0896799b 100644
--- a/hbase-common/src/test/java/org/apache/hadoop/hbase/TestServerName.java
+++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/TestServerName.java
@@ -17,11 +17,11 @@
*/
package org.apache.hadoop.hbase;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertSame;
-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.assertNotSame;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.HashSet;
import java.util.Set;
@@ -30,17 +30,15 @@
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.hbase.util.Addressing;
import org.apache.hadoop.hbase.util.Bytes;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
-@Category({ MiscTests.class, SmallTests.class })
+@Tag(MiscTests.TAG)
+@Tag(SmallTests.TAG)
+@ExtendWith(HBaseJupiterExtension.class)
public class TestServerName {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestServerName.class);
-
@Test
public void testHash() {
ServerName sn1 = ServerName.parseServerName("asf903.gq1.ygridcore.net,52690,1517835491385");
diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/TestSystemExitInTest.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/TestSystemExitInTest.java
index c8438bc77d16..ce7dec7f9afb 100644
--- a/hbase-common/src/test/java/org/apache/hadoop/hbase/TestSystemExitInTest.java
+++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/TestSystemExitInTest.java
@@ -17,22 +17,22 @@
*/
package org.apache.hadoop.hbase;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
import org.apache.hadoop.hbase.testclassification.MiscTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
-@Category({ MiscTests.class, SmallTests.class })
+@Tag(MiscTests.TAG)
+@Tag(SmallTests.TAG)
+@ExtendWith(HBaseJupiterExtension.class)
public class TestSystemExitInTest {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestSystemExitInTest.class);
-
- @Test(expected = SystemExitRule.SystemExitInTestException.class)
+ @Test
public void testSystemExit() {
- System.exit(1);
+ assertThrows(SystemExitRule.SystemExitInTestException.class, () -> System.exit(1));
}
}
diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/TestTableName.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/TestTableName.java
index d9281d8953e8..1318ba176f05 100644
--- a/hbase-common/src/test/java/org/apache/hadoop/hbase/TestTableName.java
+++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/TestTableName.java
@@ -17,10 +17,10 @@
*/
package org.apache.hadoop.hbase;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import java.nio.ByteBuffer;
import java.util.HashMap;
@@ -28,18 +28,17 @@
import org.apache.hadoop.hbase.testclassification.MiscTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.hbase.util.Bytes;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
/**
* Tests for various kinds of TableNames.
*/
-@Category({ MiscTests.class, SmallTests.class })
+@Tag(MiscTests.TAG)
+@Tag(SmallTests.TAG)
+@ExtendWith(HBaseJupiterExtension.class)
public class TestTableName {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestTableName.class);
private static String[] emptyNames = { "", " " };
private static String[] invalidNamespace = { ":a", "%:a" };
diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/TestTagBuilder.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/TestTagBuilder.java
index a0c8aea937a2..f7cf31a797c8 100644
--- a/hbase-common/src/test/java/org/apache/hadoop/hbase/TestTagBuilder.java
+++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/TestTagBuilder.java
@@ -17,24 +17,21 @@
*/
package org.apache.hadoop.hbase;
-import static org.junit.Assert.assertEquals;
-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.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import org.apache.hadoop.hbase.testclassification.MiscTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.hbase.util.Bytes;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
-@Category({ MiscTests.class, SmallTests.class })
+@org.junit.jupiter.api.Tag(MiscTests.TAG)
+@org.junit.jupiter.api.Tag(SmallTests.TAG)
+@ExtendWith(HBaseJupiterExtension.class)
public class TestTagBuilder {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestTagBuilder.class);
-
@Test
public void testArrayBackedTagBuilder() {
byte type = (byte) 50;
diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/TestTagUtil.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/TestTagUtil.java
index 9ac858e99141..e089c174822a 100644
--- a/hbase-common/src/test/java/org/apache/hadoop/hbase/TestTagUtil.java
+++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/TestTagUtil.java
@@ -17,22 +17,19 @@
*/
package org.apache.hadoop.hbase;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.List;
import org.apache.hadoop.hbase.testclassification.MiscTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
-@Category({ MiscTests.class, SmallTests.class })
+@org.junit.jupiter.api.Tag(MiscTests.TAG)
+@org.junit.jupiter.api.Tag(SmallTests.TAG)
+@ExtendWith(HBaseJupiterExtension.class)
public class TestTagUtil {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestTagUtil.class);
-
@Test
public void testCarryForwardTTLTag() throws Exception {
// No tags so far and the TTL tag must get added to the Tags list
diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/TestTimeout.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/TestTimeout.java
index 557bd14f67a1..ee7ca99a7687 100644
--- a/hbase-common/src/test/java/org/apache/hadoop/hbase/TestTimeout.java
+++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/TestTimeout.java
@@ -18,18 +18,15 @@
package org.apache.hadoop.hbase;
import org.apache.hadoop.hbase.testclassification.SmallTests;
-import org.junit.ClassRule;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
-@Category(SmallTests.class)
+@Tag(SmallTests.TAG)
+@ExtendWith(HBaseJupiterExtension.class)
public class TestTimeout {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestTimeout.class);
-
@Test
public void run1() throws InterruptedException {
Thread.sleep(100);
@@ -39,7 +36,7 @@ public void run1() throws InterruptedException {
* Enable to check if timeout works. Can't enable as it waits 30seconds and expected doesn't do
* Exception catching
*/
- @Ignore
+ @Disabled
@Test
public void infiniteLoop() {
// Launch a background non-daemon thread.
diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/codec/TestCellCodec.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/codec/TestCellCodec.java
index 3508419cea78..4b11ac21f737 100644
--- a/hbase-common/src/test/java/org/apache/hadoop/hbase/codec/TestCellCodec.java
+++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/codec/TestCellCodec.java
@@ -17,9 +17,9 @@
*/
package org.apache.hadoop.hbase.codec;
-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 java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -27,26 +27,24 @@
import java.io.DataOutputStream;
import java.io.IOException;
import org.apache.hadoop.hbase.ExtendedCell;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
+import org.apache.hadoop.hbase.HBaseJupiterExtension;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.PrivateCellUtil;
import org.apache.hadoop.hbase.testclassification.MiscTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.hbase.util.Bytes;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.apache.hbase.thirdparty.com.google.common.io.CountingInputStream;
import org.apache.hbase.thirdparty.com.google.common.io.CountingOutputStream;
-@Category({ MiscTests.class, SmallTests.class })
+@Tag(MiscTests.TAG)
+@Tag(SmallTests.TAG)
+@ExtendWith(HBaseJupiterExtension.class)
public class TestCellCodec {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestCellCodec.class);
-
@Test
public void testEmptyWorks() throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/codec/TestCellCodecWithTags.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/codec/TestCellCodecWithTags.java
index 17c95eb2c729..9fe403fc8a3f 100644
--- a/hbase-common/src/test/java/org/apache/hadoop/hbase/codec/TestCellCodecWithTags.java
+++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/codec/TestCellCodecWithTags.java
@@ -17,9 +17,9 @@
*/
package org.apache.hadoop.hbase.codec;
-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 java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -30,7 +30,7 @@
import org.apache.hadoop.hbase.ArrayBackedTag;
import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.ExtendedCell;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
+import org.apache.hadoop.hbase.HBaseJupiterExtension;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.PrivateCellUtil;
@@ -38,19 +38,16 @@
import org.apache.hadoop.hbase.testclassification.MiscTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.hbase.util.Bytes;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.apache.hbase.thirdparty.com.google.common.io.CountingInputStream;
import org.apache.hbase.thirdparty.com.google.common.io.CountingOutputStream;
-@Category({ MiscTests.class, SmallTests.class })
+@org.junit.jupiter.api.Tag(MiscTests.TAG)
+@org.junit.jupiter.api.Tag(SmallTests.TAG)
+@ExtendWith(HBaseJupiterExtension.class)
public class TestCellCodecWithTags {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestCellCodecWithTags.class);
-
@Test
public void testCellWithTag() throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/codec/TestKeyValueCodecWithTags.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/codec/TestKeyValueCodecWithTags.java
index e2bdecbf7c6b..e30c18281220 100644
--- a/hbase-common/src/test/java/org/apache/hadoop/hbase/codec/TestKeyValueCodecWithTags.java
+++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/codec/TestKeyValueCodecWithTags.java
@@ -17,9 +17,9 @@
*/
package org.apache.hadoop.hbase.codec;
-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 java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -30,7 +30,7 @@
import org.apache.hadoop.hbase.ArrayBackedTag;
import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.ExtendedCell;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
+import org.apache.hadoop.hbase.HBaseJupiterExtension;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.PrivateCellUtil;
@@ -38,19 +38,16 @@
import org.apache.hadoop.hbase.testclassification.MiscTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.hbase.util.Bytes;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.apache.hbase.thirdparty.com.google.common.io.CountingInputStream;
import org.apache.hbase.thirdparty.com.google.common.io.CountingOutputStream;
-@Category({ MiscTests.class, SmallTests.class })
+@org.junit.jupiter.api.Tag(MiscTests.TAG)
+@org.junit.jupiter.api.Tag(SmallTests.TAG)
+@ExtendWith(HBaseJupiterExtension.class)
public class TestKeyValueCodecWithTags {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestKeyValueCodecWithTags.class);
-
@Test
public void testKeyValueWithTag() throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/conf/TestConfigKey.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/conf/TestConfigKey.java
index eedf0964f2a3..8feb8f4f8514 100644
--- a/hbase-common/src/test/java/org/apache/hadoop/hbase/conf/TestConfigKey.java
+++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/conf/TestConfigKey.java
@@ -17,24 +17,24 @@
*/
package org.apache.hadoop.hbase.conf;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.fail;
import java.util.UUID;
import java.util.function.Consumer;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.CompoundConfiguration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
+import org.apache.hadoop.hbase.HBaseJupiterExtension;
import org.apache.hadoop.hbase.testclassification.MiscTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
-@Category({ MiscTests.class, SmallTests.class })
+@Tag(MiscTests.TAG)
+@Tag(SmallTests.TAG)
+@ExtendWith(HBaseJupiterExtension.class)
public class TestConfigKey {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestConfigKey.class);
private interface Interface {
}
diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/conf/TestConfigurationManager.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/conf/TestConfigurationManager.java
index d38a4ee5efc9..149065cde8ed 100644
--- a/hbase-common/src/test/java/org/apache/hadoop/hbase/conf/TestConfigurationManager.java
+++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/conf/TestConfigurationManager.java
@@ -17,26 +17,24 @@
*/
package org.apache.hadoop.hbase.conf;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
+import org.apache.hadoop.hbase.HBaseJupiterExtension;
import org.apache.hadoop.hbase.testclassification.ClientTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-@Category({ SmallTests.class, ClientTests.class })
+@Tag(SmallTests.TAG)
+@Tag(ClientTests.TAG)
+@ExtendWith(HBaseJupiterExtension.class)
public class TestConfigurationManager {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestConfigurationManager.class);
-
private static final Logger LOG = LoggerFactory.getLogger(TestConfigurationManager.class);
static class DummyConfigurationObserver implements ConfigurationObserver {
diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/io/TestByteBuffAllocator.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/io/TestByteBuffAllocator.java
index 8dcb1465684e..56f116de66b2 100644
--- a/hbase-common/src/test/java/org/apache/hadoop/hbase/io/TestByteBuffAllocator.java
+++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/io/TestByteBuffAllocator.java
@@ -19,33 +19,30 @@
import static org.apache.hadoop.hbase.io.ByteBuffAllocator.HEAP;
import static org.apache.hadoop.hbase.io.ByteBuffAllocator.getHeapAllocationRatio;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertSame;
-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.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import java.nio.ByteBuffer;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseConfiguration;
+import org.apache.hadoop.hbase.HBaseJupiterExtension;
import org.apache.hadoop.hbase.nio.ByteBuff;
import org.apache.hadoop.hbase.nio.MultiByteBuff;
import org.apache.hadoop.hbase.nio.SingleByteBuff;
import org.apache.hadoop.hbase.testclassification.RPCTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
-import org.junit.Assert;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
-@Category({ RPCTests.class, SmallTests.class })
+@Tag(RPCTests.TAG)
+@Tag(SmallTests.TAG)
+@ExtendWith(HBaseJupiterExtension.class)
public class TestByteBuffAllocator {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestByteBuffAllocator.class);
-
@Test
public void testRecycleOnlyPooledBuffers() {
int maxBuffersInPool = 10;
@@ -364,25 +361,25 @@ public void testDeprecatedConfigs() {
conf.setInt(ByteBuffAllocator.DEPRECATED_MAX_BUFFER_COUNT_KEY, 10);
conf.setInt(ByteBuffAllocator.DEPRECATED_BUFFER_SIZE_KEY, 1024);
ByteBuffAllocator allocator = ByteBuffAllocator.create(conf, true);
- Assert.assertEquals(1024, allocator.getBufferSize());
- Assert.assertEquals(10, allocator.getTotalBufferCount());
+ assertEquals(1024, allocator.getBufferSize());
+ assertEquals(10, allocator.getTotalBufferCount());
conf = new Configuration();
conf.setInt(ByteBuffAllocator.MAX_BUFFER_COUNT_KEY, 11);
conf.setInt(ByteBuffAllocator.BUFFER_SIZE_KEY, 2048);
allocator = ByteBuffAllocator.create(conf, true);
- Assert.assertEquals(2048, allocator.getBufferSize());
- Assert.assertEquals(11, allocator.getTotalBufferCount());
+ assertEquals(2048, allocator.getBufferSize());
+ assertEquals(11, allocator.getTotalBufferCount());
conf = new Configuration();
conf.setBoolean(ByteBuffAllocator.DEPRECATED_ALLOCATOR_POOL_ENABLED_KEY, false);
- Assert.assertFalse(conf.getBoolean(ByteBuffAllocator.ALLOCATOR_POOL_ENABLED_KEY, true));
+ assertFalse(conf.getBoolean(ByteBuffAllocator.ALLOCATOR_POOL_ENABLED_KEY, true));
conf.setBoolean(ByteBuffAllocator.DEPRECATED_ALLOCATOR_POOL_ENABLED_KEY, true);
- Assert.assertTrue(conf.getBoolean(ByteBuffAllocator.ALLOCATOR_POOL_ENABLED_KEY, false));
+ assertTrue(conf.getBoolean(ByteBuffAllocator.ALLOCATOR_POOL_ENABLED_KEY, false));
conf.setBoolean(ByteBuffAllocator.ALLOCATOR_POOL_ENABLED_KEY, true);
- Assert.assertTrue(conf.getBoolean(ByteBuffAllocator.ALLOCATOR_POOL_ENABLED_KEY, false));
+ assertTrue(conf.getBoolean(ByteBuffAllocator.ALLOCATOR_POOL_ENABLED_KEY, false));
conf.setBoolean(ByteBuffAllocator.ALLOCATOR_POOL_ENABLED_KEY, false);
- Assert.assertFalse(conf.getBoolean(ByteBuffAllocator.ALLOCATOR_POOL_ENABLED_KEY, true));
+ assertFalse(conf.getBoolean(ByteBuffAllocator.ALLOCATOR_POOL_ENABLED_KEY, true));
}
@Test
@@ -391,31 +388,30 @@ public void testHeapAllocationRatio() {
conf.setInt(ByteBuffAllocator.MAX_BUFFER_COUNT_KEY, 11);
conf.setInt(ByteBuffAllocator.BUFFER_SIZE_KEY, 2048);
ByteBuffAllocator alloc1 = ByteBuffAllocator.create(conf, true);
- Assert.assertEquals(getHeapAllocationRatio(alloc1), 0.0f, 1e-6);
+ assertEquals(getHeapAllocationRatio(alloc1), 0.0f, 1e-6);
alloc1.allocate(1);
- Assert.assertEquals(getHeapAllocationRatio(alloc1), 1.0f, 1e-6);
+ assertEquals(getHeapAllocationRatio(alloc1), 1.0f, 1e-6);
alloc1.allocate(2048 / 6 - 1);
- Assert.assertEquals(getHeapAllocationRatio(alloc1), 1.0f, 1e-6);
+ assertEquals(getHeapAllocationRatio(alloc1), 1.0f, 1e-6);
alloc1.allocate(24);
alloc1.allocate(1024);
- Assert.assertEquals(getHeapAllocationRatio(alloc1), 24 / (24f + 2048), 1e-6);
- Assert.assertEquals(getHeapAllocationRatio(alloc1), 0.0f, 1e-6);
+ assertEquals(getHeapAllocationRatio(alloc1), 24 / (24f + 2048), 1e-6);
+ assertEquals(getHeapAllocationRatio(alloc1), 0.0f, 1e-6);
// Allocate something from HEAP
HEAP.allocate(1024);
alloc1.allocate(24);
alloc1.allocate(1024);
- Assert.assertEquals(getHeapAllocationRatio(HEAP, alloc1), (1024f + 24) / (1024f + 24 + 2048),
- 1e-6);
- Assert.assertEquals(getHeapAllocationRatio(HEAP, alloc1), 0.0f, 1e-6);
+ assertEquals(getHeapAllocationRatio(HEAP, alloc1), (1024f + 24) / (1024f + 24 + 2048), 1e-6);
+ assertEquals(getHeapAllocationRatio(HEAP, alloc1), 0.0f, 1e-6);
// Check duplicated heap allocator, say even if we passed (HEAP, HEAP, alloc1), it will only
// caculate the allocation from (HEAP, alloc1).
HEAP.allocate(1024);
alloc1.allocate(1024);
- Assert.assertEquals(getHeapAllocationRatio(HEAP, HEAP, alloc1), 1024f / (1024f + 2048f), 1e-6);
+ assertEquals(getHeapAllocationRatio(HEAP, HEAP, alloc1), 1024f / (1024f + 2048f), 1e-6);
}
/**
diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/io/TestByteBuffAllocatorLeakDetection.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/io/TestByteBuffAllocatorLeakDetection.java
index ffc0292902e4..f1e912aba5fc 100644
--- a/hbase-common/src/test/java/org/apache/hadoop/hbase/io/TestByteBuffAllocatorLeakDetection.java
+++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/io/TestByteBuffAllocatorLeakDetection.java
@@ -17,17 +17,17 @@
*/
package org.apache.hadoop.hbase.io;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.concurrent.atomic.AtomicInteger;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
+import org.apache.hadoop.hbase.HBaseJupiterExtension;
import org.apache.hadoop.hbase.nio.ByteBuff;
import org.apache.hadoop.hbase.testclassification.RPCTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.apache.hbase.thirdparty.io.netty.util.ResourceLeakDetector;
import org.apache.hbase.thirdparty.io.netty.util.internal.logging.InternalLogLevel;
@@ -35,13 +35,11 @@
import org.apache.hbase.thirdparty.io.netty.util.internal.logging.InternalLoggerFactory;
import org.apache.hbase.thirdparty.io.netty.util.internal.logging.Slf4JLoggerFactory;
-@Category({ RPCTests.class, SmallTests.class })
+@Tag(RPCTests.TAG)
+@Tag(SmallTests.TAG)
+@ExtendWith(HBaseJupiterExtension.class)
public class TestByteBuffAllocatorLeakDetection {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestByteBuffAllocatorLeakDetection.class);
-
@SuppressWarnings("unused")
@Test
public void testLeakDetection() throws InterruptedException {
diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/io/TestByteBufferListOutputStream.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/io/TestByteBufferListOutputStream.java
index 4f9ec7d09f84..a278b5c2091f 100644
--- a/hbase-common/src/test/java/org/apache/hadoop/hbase/io/TestByteBufferListOutputStream.java
+++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/io/TestByteBufferListOutputStream.java
@@ -17,28 +17,26 @@
*/
package org.apache.hadoop.hbase.io;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.nio.ByteBuffer;
import java.util.List;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
+import org.apache.hadoop.hbase.HBaseJupiterExtension;
import org.apache.hadoop.hbase.nio.ByteBuff;
import org.apache.hadoop.hbase.testclassification.IOTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.hbase.util.ByteBufferUtils;
import org.apache.hadoop.hbase.util.Bytes;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
-@Category({ IOTests.class, SmallTests.class })
+@Tag(IOTests.TAG)
+@Tag(SmallTests.TAG)
+@ExtendWith(HBaseJupiterExtension.class)
public class TestByteBufferListOutputStream {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestByteBufferListOutputStream.class);
-
@Test
public void testWrites() throws Exception {
ByteBuffAllocator alloc = new ByteBuffAllocator(true, 3, 10, 10 / 6);
diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/io/TestFileChangeWatcher.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/io/TestFileChangeWatcher.java
index 358ea172e143..4b822c9d402d 100644
--- a/hbase-common/src/test/java/org/apache/hadoop/hbase/io/TestFileChangeWatcher.java
+++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/io/TestFileChangeWatcher.java
@@ -20,11 +20,11 @@
import static org.awaitility.Awaitility.await;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.endsWith;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
import java.io.File;
import java.io.IOException;
@@ -155,7 +155,7 @@ public void testNoFalseNotifications() throws Exception {
watcher.start();
awaitWatcherThreadInitialized();
await().during(Duration.ofSeconds(2)).atMost(Duration.ofSeconds(3))
- .untilAsserted(() -> assertEquals("Should not have been notified", 0, notifiedPaths.size()));
+ .untilAsserted(() -> assertEquals(0, notifiedPaths.size(), "Should not have been notified"));
}
@Test
@@ -173,7 +173,7 @@ public void testCallbackWorksOnFileChanges() throws IOException, InterruptedExce
FileUtils.writeStringToFile(tempFile, "Hello world " + index + "\n", StandardCharsets.UTF_8,
true);
await().atMost(Duration.ofSeconds(2)).untilAsserted(
- () -> assertEquals("Wrong number of notifications", index + 1, notifiedPaths.size()));
+ () -> assertEquals(index + 1, notifiedPaths.size(), "Wrong number of notifications"));
Path path = notifiedPaths.get(index);
assertEquals(tempFile.getPath(), path.toString());
}
diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/io/TestMultiByteBuffInputStream.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/io/TestMultiByteBuffInputStream.java
index a82441f9509e..c9666bb58351 100644
--- a/hbase-common/src/test/java/org/apache/hadoop/hbase/io/TestMultiByteBuffInputStream.java
+++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/io/TestMultiByteBuffInputStream.java
@@ -17,28 +17,26 @@
*/
package org.apache.hadoop.hbase.io;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.nio.ByteBuffer;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
+import org.apache.hadoop.hbase.HBaseJupiterExtension;
import org.apache.hadoop.hbase.nio.MultiByteBuff;
import org.apache.hadoop.hbase.testclassification.IOTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.hbase.util.Bytes;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
-@Category({ IOTests.class, SmallTests.class })
+@Tag(IOTests.TAG)
+@Tag(SmallTests.TAG)
+@ExtendWith(HBaseJupiterExtension.class)
public class TestMultiByteBuffInputStream {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestMultiByteBuffInputStream.class);
-
@Test
public void testReads() throws Exception {
ByteArrayOutputStream bos = new ByteArrayOutputStream(100);
diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/io/TestTagCompressionContext.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/io/TestTagCompressionContext.java
index 4c80d0de0413..ab5ca5693bbf 100644
--- a/hbase-common/src/test/java/org/apache/hadoop/hbase/io/TestTagCompressionContext.java
+++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/io/TestTagCompressionContext.java
@@ -17,7 +17,7 @@
*/
package org.apache.hadoop.hbase.io;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.ByteArrayInputStream;
import java.io.DataOutputStream;
@@ -28,7 +28,7 @@
import org.apache.hadoop.hbase.ByteBufferExtendedCell;
import org.apache.hadoop.hbase.ByteBufferKeyValue;
import org.apache.hadoop.hbase.Cell;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
+import org.apache.hadoop.hbase.HBaseJupiterExtension;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.Tag;
import org.apache.hadoop.hbase.io.util.LRUDictionary;
@@ -37,17 +37,14 @@
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.hbase.util.ByteBufferUtils;
import org.apache.hadoop.hbase.util.Bytes;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
-@Category({ MiscTests.class, SmallTests.class })
+@org.junit.jupiter.api.Tag(MiscTests.TAG)
+@org.junit.jupiter.api.Tag(SmallTests.TAG)
+@ExtendWith(HBaseJupiterExtension.class)
public class TestTagCompressionContext {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestTagCompressionContext.class);
-
private static final byte[] ROW = Bytes.toBytes("r1");
private static final byte[] CF = Bytes.toBytes("f");
private static final byte[] Q = Bytes.toBytes("q");
diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/io/compress/TestCodecPool.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/io/compress/TestCodecPool.java
index 6ce7850273da..fa856dbd2a40 100644
--- a/hbase-common/src/test/java/org/apache/hadoop/hbase/io/compress/TestCodecPool.java
+++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/io/compress/TestCodecPool.java
@@ -17,8 +17,8 @@
*/
package org.apache.hadoop.hbase.io.compress;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -32,7 +32,7 @@
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.TimeUnit;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
+import org.apache.hadoop.hbase.HBaseJupiterExtension;
import org.apache.hadoop.hbase.testclassification.MiscTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.io.compress.AlreadyClosedException;
@@ -42,55 +42,53 @@
import org.apache.hadoop.io.compress.DefaultCodec;
import org.apache.hadoop.io.compress.GzipCodec;
import org.apache.hadoop.io.compress.zlib.BuiltInGzipDecompressor;
-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.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
/**
* Along with CodecPool, this is copied from the class of the same name in hadoop-common. Modified
* to accommodate changes to HBase's CodecPool.
*/
-@Category({ MiscTests.class, SmallTests.class })
+@Tag(MiscTests.TAG)
+@Tag(SmallTests.TAG)
+@ExtendWith(HBaseJupiterExtension.class)
public class TestCodecPool {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestCodecPool.class);
-
private final String LEASE_COUNT_ERR = "Incorrect number of leased (de)compressors";
DefaultCodec codec;
- @BeforeClass
+ @BeforeAll
public static void beforeClass() {
CodecPool.initLeaseCounting();
}
- @Before
+ @BeforeEach
public void setup() {
this.codec = new DefaultCodec();
this.codec.setConf(new Configuration());
}
- @Test(timeout = 10000)
+ @Test
public void testCompressorPoolCounts() {
// Get two compressors and return them
Compressor comp1 = CodecPool.getCompressor(codec);
Compressor comp2 = CodecPool.getCompressor(codec);
- assertEquals(LEASE_COUNT_ERR, 2, CodecPool.getLeasedCompressorsCount(codec));
+ assertEquals(2, CodecPool.getLeasedCompressorsCount(codec), LEASE_COUNT_ERR);
CodecPool.returnCompressor(comp2);
- assertEquals(LEASE_COUNT_ERR, 1, CodecPool.getLeasedCompressorsCount(codec));
+ assertEquals(1, CodecPool.getLeasedCompressorsCount(codec), LEASE_COUNT_ERR);
CodecPool.returnCompressor(comp1);
- assertEquals(LEASE_COUNT_ERR, 0, CodecPool.getLeasedCompressorsCount(codec));
+ assertEquals(0, CodecPool.getLeasedCompressorsCount(codec), LEASE_COUNT_ERR);
CodecPool.returnCompressor(comp1);
- assertEquals(LEASE_COUNT_ERR, 0, CodecPool.getLeasedCompressorsCount(codec));
+ assertEquals(0, CodecPool.getLeasedCompressorsCount(codec), LEASE_COUNT_ERR);
}
- @Test(timeout = 10000)
+ @Test
public void testCompressorNotReturnSameInstance() {
Compressor comp = CodecPool.getCompressor(codec);
CodecPool.returnCompressor(comp);
@@ -105,24 +103,24 @@ public void testCompressorNotReturnSameInstance() {
}
}
- @Test(timeout = 10000)
+ @Test
public void testDecompressorPoolCounts() {
// Get two decompressors and return them
Decompressor decomp1 = CodecPool.getDecompressor(codec);
Decompressor decomp2 = CodecPool.getDecompressor(codec);
- assertEquals(LEASE_COUNT_ERR, 2, CodecPool.getLeasedDecompressorsCount(codec));
+ assertEquals(2, CodecPool.getLeasedDecompressorsCount(codec), LEASE_COUNT_ERR);
CodecPool.returnDecompressor(decomp2);
- assertEquals(LEASE_COUNT_ERR, 1, CodecPool.getLeasedDecompressorsCount(codec));
+ assertEquals(1, CodecPool.getLeasedDecompressorsCount(codec), LEASE_COUNT_ERR);
CodecPool.returnDecompressor(decomp1);
- assertEquals(LEASE_COUNT_ERR, 0, CodecPool.getLeasedDecompressorsCount(codec));
+ assertEquals(0, CodecPool.getLeasedDecompressorsCount(codec), LEASE_COUNT_ERR);
CodecPool.returnDecompressor(decomp1);
- assertEquals(LEASE_COUNT_ERR, 0, CodecPool.getLeasedCompressorsCount(codec));
+ assertEquals(0, CodecPool.getLeasedCompressorsCount(codec), LEASE_COUNT_ERR);
}
- @Test(timeout = 10000)
+ @Test
public void testMultiThreadedCompressorPool() throws InterruptedException {
final int iterations = 4;
ExecutorService threadpool = Executors.newFixedThreadPool(3);
@@ -156,10 +154,10 @@ public Boolean call() throws Exception {
threadpool.shutdown();
threadpool.awaitTermination(1000, TimeUnit.SECONDS);
- assertEquals(LEASE_COUNT_ERR, 0, CodecPool.getLeasedCompressorsCount(codec));
+ assertEquals(0, CodecPool.getLeasedCompressorsCount(codec), LEASE_COUNT_ERR);
}
- @Test(timeout = 10000)
+ @Test
public void testMultiThreadedDecompressorPool() throws InterruptedException {
final int iterations = 4;
ExecutorService threadpool = Executors.newFixedThreadPool(3);
@@ -193,10 +191,10 @@ public Boolean call() throws Exception {
threadpool.shutdown();
threadpool.awaitTermination(1000, TimeUnit.SECONDS);
- assertEquals(LEASE_COUNT_ERR, 0, CodecPool.getLeasedDecompressorsCount(codec));
+ assertEquals(0, CodecPool.getLeasedDecompressorsCount(codec), LEASE_COUNT_ERR);
}
- @Test(timeout = 10000)
+ @Test
public void testDecompressorNotReturnSameInstance() {
Decompressor decomp = CodecPool.getDecompressor(codec);
CodecPool.returnDecompressor(decomp);
@@ -211,7 +209,7 @@ public void testDecompressorNotReturnSameInstance() {
}
}
- @Test(timeout = 10000)
+ @Test
public void testDoNotPoolDecompressorNotUseableAfterReturn() throws Exception {
final GzipCodec gzipCodec = new GzipCodec();
diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/io/crypto/TestCipherProvider.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/io/crypto/TestCipherProvider.java
index 1cafaaf7ecb3..4a03d03d8716 100644
--- a/hbase-common/src/test/java/org/apache/hadoop/hbase/io/crypto/TestCipherProvider.java
+++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/io/crypto/TestCipherProvider.java
@@ -17,9 +17,9 @@
*/
package org.apache.hadoop.hbase.io.crypto;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
import java.io.InputStream;
@@ -27,23 +27,21 @@
import java.security.Key;
import java.util.Arrays;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseConfiguration;
+import org.apache.hadoop.hbase.HBaseJupiterExtension;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.io.crypto.aes.AES;
import org.apache.hadoop.hbase.testclassification.MiscTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
-@Category({ MiscTests.class, SmallTests.class })
+@Tag(MiscTests.TAG)
+@Tag(SmallTests.TAG)
+@ExtendWith(HBaseJupiterExtension.class)
public class TestCipherProvider {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestCipherProvider.class);
-
public static class MyCipherProvider implements CipherProvider {
private Configuration conf;
diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/io/crypto/TestEncryption.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/io/crypto/TestEncryption.java
index 4e67c814c2aa..c9552d7fbe71 100644
--- a/hbase-common/src/test/java/org/apache/hadoop/hbase/io/crypto/TestEncryption.java
+++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/io/crypto/TestEncryption.java
@@ -17,31 +17,30 @@
*/
package org.apache.hadoop.hbase.io.crypto;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.security.Key;
import javax.crypto.spec.SecretKeySpec;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseConfiguration;
+import org.apache.hadoop.hbase.HBaseJupiterExtension;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.testclassification.MiscTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.hbase.util.Bytes;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-@Category({ MiscTests.class, SmallTests.class })
+@Tag(MiscTests.TAG)
+@Tag(SmallTests.TAG)
+@ExtendWith(HBaseJupiterExtension.class)
public class TestEncryption {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestEncryption.class);
private static final Logger LOG = LoggerFactory.getLogger(TestEncryption.class);
@@ -135,9 +134,9 @@ private void checkTransformSymmetry(byte[] keyBytes, byte[] iv, byte[] plaintext
Encryption.decrypt(decOut, encIn, plaintext.length, d);
byte[] result = decOut.toByteArray();
- assertEquals("Decrypted result has different length than plaintext", result.length,
- plaintext.length);
- assertTrue("Transformation was not symmetric", Bytes.equals(result, plaintext));
+ assertEquals(result.length, plaintext.length,
+ "Decrypted result has different length than plaintext");
+ assertTrue(Bytes.equals(result, plaintext), "Transformation was not symmetric");
}
private byte[] getRandomBlock(int size) {
diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/io/crypto/TestKeyProvider.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/io/crypto/TestKeyProvider.java
index 741cf05744d8..856cf3e2063a 100644
--- a/hbase-common/src/test/java/org/apache/hadoop/hbase/io/crypto/TestKeyProvider.java
+++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/io/crypto/TestKeyProvider.java
@@ -17,42 +17,40 @@
*/
package org.apache.hadoop.hbase.io.crypto;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.security.Key;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseConfiguration;
+import org.apache.hadoop.hbase.HBaseJupiterExtension;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.io.crypto.aes.AES;
import org.apache.hadoop.hbase.testclassification.MiscTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
-@Category({ MiscTests.class, SmallTests.class })
+@Tag(MiscTests.TAG)
+@Tag(SmallTests.TAG)
+@ExtendWith(HBaseJupiterExtension.class)
public class TestKeyProvider {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestKeyProvider.class);
-
@Test
public void testTestProvider() {
Configuration conf = HBaseConfiguration.create();
conf.set(HConstants.CRYPTO_KEYPROVIDER_CONF_KEY, MockAesKeyProvider.class.getName());
KeyProvider provider = Encryption.getKeyProvider(conf);
- assertNotNull("Null returned for provider", provider);
- assertTrue("Provider is not the expected type", provider instanceof MockAesKeyProvider);
+ assertNotNull(provider, "Null returned for provider");
+ assertTrue(provider instanceof MockAesKeyProvider, "Provider is not the expected type");
Key key = provider.getKey("foo");
- assertNotNull("Test provider did not return a key as expected", key);
- assertEquals("Test provider did not create a key for AES", "AES", key.getAlgorithm());
- assertEquals("Test provider did not create a key of adequate length", AES.KEY_LENGTH,
- key.getEncoded().length);
+ assertNotNull(key, "Test provider did not return a key as expected");
+ assertEquals("AES", key.getAlgorithm(), "Test provider did not create a key for AES");
+ assertEquals(AES.KEY_LENGTH, key.getEncoded().length,
+ "Test provider did not create a key of adequate length");
}
}
diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/io/crypto/TestKeyStoreKeyProvider.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/io/crypto/TestKeyStoreKeyProvider.java
index 581681988c28..723449a048f7 100644
--- a/hbase-common/src/test/java/org/apache/hadoop/hbase/io/crypto/TestKeyStoreKeyProvider.java
+++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/io/crypto/TestKeyStoreKeyProvider.java
@@ -17,8 +17,8 @@
*/
package org.apache.hadoop.hbase.io.crypto;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.io.File;
import java.io.FileOutputStream;
@@ -28,23 +28,21 @@
import java.security.MessageDigest;
import java.util.Properties;
import javax.crypto.spec.SecretKeySpec;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseCommonTestingUtil;
+import org.apache.hadoop.hbase.HBaseJupiterExtension;
import org.apache.hadoop.hbase.testclassification.MiscTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.hbase.util.Bytes;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
-@Category({ MiscTests.class, SmallTests.class })
+@Tag(MiscTests.TAG)
+@Tag(SmallTests.TAG)
+@ExtendWith(HBaseJupiterExtension.class)
public class TestKeyStoreKeyProvider {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestKeyStoreKeyProvider.class);
-
static final HBaseCommonTestingUtil TEST_UTIL = new HBaseCommonTestingUtil();
static final String ALIAS = "test";
static final String PASSWORD = "password";
@@ -53,7 +51,7 @@ public class TestKeyStoreKeyProvider {
static File storeFile;
static File passwordFile;
- @BeforeClass
+ @BeforeAll
public static void setUp() throws Exception {
KEY = MessageDigest.getInstance("SHA-256").digest(Bytes.toBytes(ALIAS));
// Create a JKECS store containing a test secret key
diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/io/crypto/aes/TestAES.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/io/crypto/aes/TestAES.java
index c50da383dc93..75300c9edb1b 100644
--- a/hbase-common/src/test/java/org/apache/hadoop/hbase/io/crypto/aes/TestAES.java
+++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/io/crypto/aes/TestAES.java
@@ -17,8 +17,8 @@
*/
package org.apache.hadoop.hbase.io.crypto.aes;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -32,8 +32,8 @@
import javax.crypto.spec.SecretKeySpec;
import org.apache.commons.io.IOUtils;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseConfiguration;
+import org.apache.hadoop.hbase.HBaseJupiterExtension;
import org.apache.hadoop.hbase.io.crypto.Cipher;
import org.apache.hadoop.hbase.io.crypto.DefaultCipherProvider;
import org.apache.hadoop.hbase.io.crypto.Encryption;
@@ -41,16 +41,15 @@
import org.apache.hadoop.hbase.testclassification.MiscTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.hbase.util.Bytes;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
-@Category({ MiscTests.class, SmallTests.class })
+@Tag(MiscTests.TAG)
+@Tag(SmallTests.TAG)
+@ExtendWith(HBaseJupiterExtension.class)
public class TestAES {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE = HBaseClassTestRule.forClass(TestAES.class);
-
// Validation for AES in CTR mode with a 128 bit key
// From NIST Special Publication 800-38A
@Test
@@ -74,13 +73,13 @@ public void testAESAlgorithm() throws Exception {
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
byte[] b = new byte[16];
IOUtils.readFully(in, b);
- assertTrue("Failed #1", Bytes.equals(b, Bytes.fromHex("874d6191b620e3261bef6864990db6ce")));
+ assertTrue(Bytes.equals(b, Bytes.fromHex("874d6191b620e3261bef6864990db6ce")), "Failed #1");
IOUtils.readFully(in, b);
- assertTrue("Failed #2", Bytes.equals(b, Bytes.fromHex("9806f66b7970fdff8617187bb9fffdff")));
+ assertTrue(Bytes.equals(b, Bytes.fromHex("9806f66b7970fdff8617187bb9fffdff")), "Failed #2");
IOUtils.readFully(in, b);
- assertTrue("Failed #3", Bytes.equals(b, Bytes.fromHex("5ae4df3edbd5d35e5b4f09020db03eab")));
+ assertTrue(Bytes.equals(b, Bytes.fromHex("5ae4df3edbd5d35e5b4f09020db03eab")), "Failed #3");
IOUtils.readFully(in, b);
- assertTrue("Failed #4", Bytes.equals(b, Bytes.fromHex("1e031dda2fbe03d1792170a0f3009cee")));
+ assertTrue(Bytes.equals(b, Bytes.fromHex("1e031dda2fbe03d1792170a0f3009cee")), "Failed #4");
}
@Test
@@ -93,7 +92,7 @@ public void testAlternateRNG() throws Exception {
DefaultCipherProvider.getInstance().setConf(conf);
AES aes = new AES(DefaultCipherProvider.getInstance());
- assertEquals("AES did not find alternate RNG", "TestRNG", aes.getRNG().getAlgorithm());
+ assertEquals("TestRNG", aes.getRNG().getAlgorithm(), "AES did not find alternate RNG");
}
static class TestProvider extends Provider {
diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/io/crypto/aes/TestCommonsAES.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/io/crypto/aes/TestCommonsAES.java
index 2114ebbfb140..c9fe2037d9d0 100644
--- a/hbase-common/src/test/java/org/apache/hadoop/hbase/io/crypto/aes/TestCommonsAES.java
+++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/io/crypto/aes/TestCommonsAES.java
@@ -17,8 +17,8 @@
*/
package org.apache.hadoop.hbase.io.crypto.aes;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -32,8 +32,8 @@
import javax.crypto.spec.SecretKeySpec;
import org.apache.commons.io.IOUtils;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseConfiguration;
+import org.apache.hadoop.hbase.HBaseJupiterExtension;
import org.apache.hadoop.hbase.io.crypto.Cipher;
import org.apache.hadoop.hbase.io.crypto.DefaultCipherProvider;
import org.apache.hadoop.hbase.io.crypto.Encryption;
@@ -41,17 +41,15 @@
import org.apache.hadoop.hbase.testclassification.MiscTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.hbase.util.Bytes;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
-@Category({ MiscTests.class, SmallTests.class })
+@Tag(MiscTests.TAG)
+@Tag(SmallTests.TAG)
+@ExtendWith(HBaseJupiterExtension.class)
public class TestCommonsAES {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestCommonsAES.class);
-
// Validation for AES in CTR mode with a 128 bit key
// From NIST Special Publication 800-38A
@Test
@@ -75,13 +73,13 @@ public void testAESAlgorithm() throws Exception {
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
byte[] b = new byte[16];
IOUtils.readFully(in, b);
- assertTrue("Failed #1", Bytes.equals(b, Bytes.fromHex("874d6191b620e3261bef6864990db6ce")));
+ assertTrue(Bytes.equals(b, Bytes.fromHex("874d6191b620e3261bef6864990db6ce")), "Failed #1");
IOUtils.readFully(in, b);
- assertTrue("Failed #2", Bytes.equals(b, Bytes.fromHex("9806f66b7970fdff8617187bb9fffdff")));
+ assertTrue(Bytes.equals(b, Bytes.fromHex("9806f66b7970fdff8617187bb9fffdff")), "Failed #2");
IOUtils.readFully(in, b);
- assertTrue("Failed #3", Bytes.equals(b, Bytes.fromHex("5ae4df3edbd5d35e5b4f09020db03eab")));
+ assertTrue(Bytes.equals(b, Bytes.fromHex("5ae4df3edbd5d35e5b4f09020db03eab")), "Failed #3");
IOUtils.readFully(in, b);
- assertTrue("Failed #4", Bytes.equals(b, Bytes.fromHex("1e031dda2fbe03d1792170a0f3009cee")));
+ assertTrue(Bytes.equals(b, Bytes.fromHex("1e031dda2fbe03d1792170a0f3009cee")), "Failed #4");
}
@Test
@@ -94,7 +92,7 @@ public void testAlternateRNG() throws Exception {
DefaultCipherProvider.getInstance().setConf(conf);
AES aes = new AES(DefaultCipherProvider.getInstance());
- assertEquals("AES did not find alternate RNG", "TestRNG", aes.getRNG().getAlgorithm());
+ assertEquals("TestRNG", aes.getRNG().getAlgorithm(), "AES did not find alternate RNG");
}
static class TestProvider extends Provider {
diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/io/crypto/tls/AbstractTestX509Parameterized.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/io/crypto/tls/AbstractTestX509Parameterized.java
index 821a68541358..359731a3461c 100644
--- a/hbase-common/src/test/java/org/apache/hadoop/hbase/io/crypto/tls/AbstractTestX509Parameterized.java
+++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/io/crypto/tls/AbstractTestX509Parameterized.java
@@ -21,17 +21,17 @@
import java.io.IOException;
import java.security.Security;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.List;
+import java.util.stream.Stream;
import org.apache.commons.io.FileUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseCommonTestingUtil;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.runners.Parameterized;
+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.params.provider.Arguments;
/**
* Base class for parameterized unit tests that use X509TestContext for testing different X509
@@ -51,35 +51,34 @@ public abstract class AbstractTestX509Parameterized {
private static final HBaseCommonTestingUtil UTIL = new HBaseCommonTestingUtil();
private static X509TestContextProvider PROVIDER;
- @Parameterized.Parameter()
- public X509KeyType caKeyType;
+ private X509KeyType caKeyType;
+ private X509KeyType certKeyType;
+ private char[] keyPassword;
+ private Integer paramIndex;
- @Parameterized.Parameter(value = 1)
- public X509KeyType certKeyType;
-
- @Parameterized.Parameter(value = 2)
- public char[] keyPassword;
-
- @Parameterized.Parameter(value = 3)
- public Integer paramIndex;
+ public AbstractTestX509Parameterized(X509KeyType caKeyType, X509KeyType certKeyType,
+ char[] keyPassword, Integer paramIndex) {
+ this.caKeyType = caKeyType;
+ this.certKeyType = certKeyType;
+ this.keyPassword = keyPassword;
+ this.paramIndex = paramIndex;
+ }
/**
* Default parameters suitable for most subclasses. See example usage in {@link TestX509Util}.
- * @return an array of parameter combinations to test with.
+ * @return a stream of parameter combinations to test with.
*/
- @Parameterized.Parameters(
- name = "{index}: caKeyType={0}, certKeyType={1}, keyPassword={2}, paramIndex={3}")
- public static Collection