diff --git a/hbase-mapreduce/pom.xml b/hbase-mapreduce/pom.xml
index 99671e9c6925..85311f91be9b 100644
--- a/hbase-mapreduce/pom.xml
+++ b/hbase-mapreduce/pom.xml
@@ -185,7 +185,7 @@
org.mockito
- mockito-core
+ mockito-junit-jupiter
test
@@ -215,11 +215,6 @@
junit-jupiter-params
test
-
- org.junit.vintage
- junit-vintage-engine
- test
-
org.awaitility
awaitility
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/TestPerformanceEvaluation.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/TestPerformanceEvaluation.java
index 40bcd045c0f3..4e9dab096e4b 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/TestPerformanceEvaluation.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/TestPerformanceEvaluation.java
@@ -17,12 +17,12 @@
*/
package org.apache.hadoop.hbase;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThrows;
-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.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import com.codahale.metrics.Histogram;
import com.codahale.metrics.Snapshot;
@@ -51,17 +51,14 @@
import org.apache.hadoop.hbase.testclassification.MiscTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.hbase.util.GsonUtil;
-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.apache.hbase.thirdparty.com.google.gson.Gson;
-@Category({ MiscTests.class, SmallTests.class })
+@Tag(MiscTests.TAG)
+@Tag(SmallTests.TAG)
public class TestPerformanceEvaluation {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestPerformanceEvaluation.class);
private static final HBaseTestingUtility HTU = new HBaseTestingUtility();
@@ -166,7 +163,7 @@ public void testRandomReadCalculation() {
break;
}
}
- assertTrue("We need to get a value more than 1000", foundValue);
+ assertTrue(foundValue, "We need to get a value more than 1000");
}
@Test
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapred/TestDriver.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapred/TestDriver.java
index 6c49a43bf463..8b8d240088da 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapred/TestDriver.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapred/TestDriver.java
@@ -20,21 +20,17 @@
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.testclassification.MapReduceTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.util.ProgramDriver;
-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.mockito.Mockito;
-@Category({ MapReduceTests.class, SmallTests.class })
+@Tag(MapReduceTests.TAG)
+@Tag(SmallTests.TAG)
public class TestDriver {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE = HBaseClassTestRule.forClass(TestDriver.class);
-
@Test
public void testDriverMainMethod() throws Throwable {
ProgramDriver programDriverMock = mock(ProgramDriver.class);
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapred/TestGroupingTableMap.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapred/TestGroupingTableMap.java
index 725b489057a9..0250f692c062 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapred/TestGroupingTableMap.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapred/TestGroupingTableMap.java
@@ -17,8 +17,9 @@
*/
package org.apache.hadoop.hbase.mapred;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
@@ -32,7 +33,6 @@
import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.Cell;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
@@ -42,20 +42,15 @@
import org.apache.hadoop.mapred.JobConf;
import org.apache.hadoop.mapred.OutputCollector;
import org.apache.hadoop.mapred.Reporter;
-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.apache.hbase.thirdparty.com.google.common.collect.ImmutableList;
-@Category({ MapReduceTests.class, SmallTests.class })
+@Tag(MapReduceTests.TAG)
+@Tag(SmallTests.TAG)
public class TestGroupingTableMap {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestGroupingTableMap.class);
-
@Test
@SuppressWarnings("unchecked")
public void shouldNotCallCollectonSinceFindUniqueKeyValueMoreThanOnes() throws Exception {
@@ -149,7 +144,7 @@ public void collect(ImmutableBytesWritable arg, Result result) throws IOExceptio
gTableMap.map(null, result, outputCollector, reporter);
verify(result).listCells();
- Assert.assertTrue("Output not received", outputCollected.get());
+ assertTrue(outputCollected.get(), "Output not received");
final byte[] firstPartValue = Bytes.toBytes("238947928");
final byte[] secondPartValue = Bytes.toBytes("4678456942345");
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapred/TestIdentityTableMap.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapred/TestIdentityTableMap.java
index 96e25b51f659..14df668d79a6 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapred/TestIdentityTableMap.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapred/TestIdentityTableMap.java
@@ -22,25 +22,20 @@
import static org.mockito.Mockito.verify;
import java.io.IOException;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
import org.apache.hadoop.hbase.testclassification.MapReduceTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.mapred.OutputCollector;
import org.apache.hadoop.mapred.Reporter;
-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.mockito.Mockito;
-@Category({ MapReduceTests.class, SmallTests.class })
+@Tag(MapReduceTests.TAG)
+@Tag(SmallTests.TAG)
public class TestIdentityTableMap {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestIdentityTableMap.class);
-
@Test
@SuppressWarnings({ "deprecation", "unchecked" })
public void shouldCollectPredefinedTimes() throws IOException {
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapred/TestMultiTableSnapshotInputFormat.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapred/TestMultiTableSnapshotInputFormat.java
index c042bd35a56d..065acfafc0dc 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapred/TestMultiTableSnapshotInputFormat.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapred/TestMultiTableSnapshotInputFormat.java
@@ -17,14 +17,13 @@
*/
package org.apache.hadoop.hbase.mapred;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
@@ -37,21 +36,17 @@
import org.apache.hadoop.mapred.OutputCollector;
import org.apache.hadoop.mapred.Reporter;
import org.apache.hadoop.mapred.RunningJob;
-import org.junit.ClassRule;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.Tag;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.hbase.thirdparty.com.google.common.collect.Lists;
-@Category({ VerySlowMapReduceTests.class, LargeTests.class })
+@Tag(VerySlowMapReduceTests.TAG)
+@Tag(LargeTests.TAG)
public class TestMultiTableSnapshotInputFormat
extends org.apache.hadoop.hbase.mapreduce.TestMultiTableSnapshotInputFormat {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestMultiTableSnapshotInputFormat.class);
-
private static final Logger LOG =
LoggerFactory.getLogger(TestMultiTableSnapshotInputFormat.class);
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapred/TestRowCounter.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapred/TestRowCounter.java
index 0f71055c6a72..51bae4b52139 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapred/TestRowCounter.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapred/TestRowCounter.java
@@ -17,9 +17,9 @@
*/
package org.apache.hadoop.hbase.mapred;
-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 static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.Mockito.mock;
@@ -28,7 +28,6 @@
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.PrintStream;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
@@ -38,20 +37,16 @@
import org.apache.hadoop.mapred.JobConf;
import org.apache.hadoop.mapred.OutputCollector;
import org.apache.hadoop.mapred.Reporter;
-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.mockito.Mockito;
import org.apache.hbase.thirdparty.com.google.common.base.Joiner;
-@Category({ MapReduceTests.class, MediumTests.class })
+@Tag(MapReduceTests.TAG)
+@Tag(MediumTests.TAG)
public class TestRowCounter {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestRowCounter.class);
-
@Test
@SuppressWarnings("deprecation")
public void shouldPrintUsage() throws Exception {
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapred/TestSplitTable.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapred/TestSplitTable.java
index 61c678544a6c..60ba178eea58 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapred/TestSplitTable.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapred/TestSplitTable.java
@@ -17,31 +17,21 @@
*/
package org.apache.hadoop.hbase.mapred;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.testclassification.MapReduceTests;
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.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.rules.TestName;
-
-@Category({ MapReduceTests.class, SmallTests.class })
-public class TestSplitTable {
-
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestSplitTable.class);
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
- @Rule
- public TestName name = new TestName();
+@Tag(MapReduceTests.TAG)
+@Tag(SmallTests.TAG)
+public class TestSplitTable {
@Test
@SuppressWarnings({ "deprecation", "SelfComparison" })
@@ -104,16 +94,16 @@ public void testSplitTableEquals() {
@Test
@SuppressWarnings("deprecation")
- public void testToString() {
- TableSplit split = new TableSplit(TableName.valueOf(name.getMethodName()),
- "row-start".getBytes(), "row-end".getBytes(), "location");
- String str = "HBase table split(table name: " + name.getMethodName()
+ public void testToString(TestInfo testInfo) {
+ TableSplit split = new TableSplit(TableName.valueOf(testInfo.getTestMethod().get().getName()),
+ Bytes.toBytes("row-start"), Bytes.toBytes("row-end"), "location");
+ String str = "HBase table split(table name: " + testInfo.getTestMethod().get().getName()
+ ", start row: row-start, " + "end row: row-end, region location: location)";
- Assert.assertEquals(str, split.toString());
+ assertEquals(str, split.toString());
split = new TableSplit((TableName) null, null, null, null);
str = "HBase table split(table name: null, start row: null, "
+ "end row: null, region location: null)";
- Assert.assertEquals(str, split.toString());
+ assertEquals(str, split.toString());
}
}
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapred/TestTableInputFormat.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapred/TestTableInputFormat.java
index a99ac6e0ccf6..1a87abff8187 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapred/TestTableInputFormat.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapred/TestTableInputFormat.java
@@ -17,9 +17,10 @@
*/
package org.apache.hadoop.hbase.mapred;
-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.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doReturn;
@@ -33,7 +34,6 @@
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CompareOperator;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.NotServingRegionException;
@@ -61,12 +61,11 @@
import org.apache.hadoop.mapred.Reporter;
import org.apache.hadoop.mapred.RunningJob;
import org.apache.hadoop.mapred.lib.NullOutputFormat;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.slf4j.Logger;
@@ -75,13 +74,10 @@
/**
* This tests the TableInputFormat and its recovery semantics
*/
-@Category({ MapReduceTests.class, LargeTests.class })
+@Tag(MapReduceTests.TAG)
+@Tag(LargeTests.TAG)
public class TestTableInputFormat {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestTableInputFormat.class);
-
private static final Logger LOG = LoggerFactory.getLogger(TestTableInputFormat.class);
private final static HBaseTestingUtility UTIL = new HBaseTestingUtility();
@@ -90,17 +86,17 @@ public class TestTableInputFormat {
private static final byte[][] columns = new byte[][] { FAMILY };
- @BeforeClass
+ @BeforeAll
public static void beforeClass() throws Exception {
UTIL.startMiniCluster();
}
- @AfterClass
+ @AfterAll
public static void afterClass() throws Exception {
UTIL.shutdownMiniCluster();
}
- @Before
+ @BeforeEach
public void before() throws IOException {
LOG.info("before");
UTIL.ensureSomeRegionServersAvailable(1);
@@ -265,10 +261,10 @@ public void testTableRecordReaderScannerFail() throws IOException {
/**
* Run test assuming Scanner IOException failure using mapred api,
*/
- @Test(expected = IOException.class)
+ @Test
public void testTableRecordReaderScannerFailTwice() throws IOException {
Table htable = createIOEScannerTable("table3".getBytes(), 2);
- runTestMapred(htable);
+ assertThrows(IOException.class, () -> runTestMapred(htable));
}
/**
@@ -285,10 +281,11 @@ public void testTableRecordReaderScannerTimeout() throws IOException {
* Run test assuming NotServingRegionException using mapred api.
* @throws org.apache.hadoop.hbase.DoNotRetryIOException
*/
- @Test(expected = org.apache.hadoop.hbase.NotServingRegionException.class)
+ @Test
public void testTableRecordReaderScannerTimeoutTwice() throws IOException {
Table htable = createDNRIOEScannerTable("table5".getBytes(), 2);
- runTestMapred(htable);
+ assertThrows(org.apache.hadoop.hbase.NotServingRegionException.class,
+ () -> runTestMapred(htable));
}
/**
@@ -329,19 +326,25 @@ void testInputFormat(Class extends InputFormat> clazz) throws IOException {
job.setNumReduceTasks(0);
LOG.debug("submitting job.");
final RunningJob run = JobClient.runJob(job);
- assertTrue("job failed!", run.isSuccessful());
- assertEquals("Saw the wrong number of instances of the filtered-for row.", 2, run.getCounters()
- .findCounter(TestTableInputFormat.class.getName() + ":row", "aaa").getCounter());
- assertEquals("Saw any instances of the filtered out row.", 0, run.getCounters()
- .findCounter(TestTableInputFormat.class.getName() + ":row", "bbb").getCounter());
- assertEquals("Saw the wrong number of instances of columnA.", 1, run.getCounters()
- .findCounter(TestTableInputFormat.class.getName() + ":family", "columnA").getCounter());
- assertEquals("Saw the wrong number of instances of columnB.", 1, run.getCounters()
- .findCounter(TestTableInputFormat.class.getName() + ":family", "columnB").getCounter());
- assertEquals("Saw the wrong count of values for the filtered-for row.", 2, run.getCounters()
- .findCounter(TestTableInputFormat.class.getName() + ":value", "value aaa").getCounter());
- assertEquals("Saw the wrong count of values for the filtered-out row.", 0, run.getCounters()
- .findCounter(TestTableInputFormat.class.getName() + ":value", "value bbb").getCounter());
+ assertTrue(run.isSuccessful(), "job failed!");
+ assertEquals(2, run.getCounters()
+ .findCounter(TestTableInputFormat.class.getName() + ":row", "aaa").getCounter(),
+ "Saw the wrong number of instances of the filtered-for row.");
+ assertEquals(0, run.getCounters()
+ .findCounter(TestTableInputFormat.class.getName() + ":row", "bbb").getCounter(),
+ "Saw any instances of the filtered out row.");
+ assertEquals(1, run.getCounters()
+ .findCounter(TestTableInputFormat.class.getName() + ":family", "columnA").getCounter(),
+ "Saw the wrong number of instances of columnA.");
+ assertEquals(1, run.getCounters()
+ .findCounter(TestTableInputFormat.class.getName() + ":family", "columnB").getCounter(),
+ "Saw the wrong number of instances of columnB.");
+ assertEquals(2, run.getCounters()
+ .findCounter(TestTableInputFormat.class.getName() + ":value", "value aaa").getCounter(),
+ "Saw the wrong count of values for the filtered-for row.");
+ assertEquals(0, run.getCounters()
+ .findCounter(TestTableInputFormat.class.getName() + ":value", "value bbb").getCounter(),
+ "Saw the wrong count of values for the filtered-out row.");
}
public static class ExampleVerifier implements TableMap {
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapred/TestTableMapReduce.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapred/TestTableMapReduce.java
index 2820d9111277..92b6301d0b4d 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapred/TestTableMapReduce.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapred/TestTableMapReduce.java
@@ -17,12 +17,11 @@
*/
package org.apache.hadoop.hbase.mapred;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.File;
import java.io.IOException;
import org.apache.hadoop.fs.FileUtil;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.client.Table;
@@ -37,8 +36,7 @@
import org.apache.hadoop.mapred.OutputCollector;
import org.apache.hadoop.mapred.Reporter;
import org.apache.hadoop.mapred.RunningJob;
-import org.junit.ClassRule;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.Tag;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -47,14 +45,11 @@
* simple - take every row in the table, reverse the value of a particular cell, and write it back
* to the table.
*/
-@Category({ MapReduceTests.class, LargeTests.class })
+@Tag(MapReduceTests.TAG)
+@Tag(LargeTests.TAG)
@SuppressWarnings("deprecation")
public class TestTableMapReduce extends TestTableMapReduceBase {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestTableMapReduce.class);
-
private static final Logger LOG = LoggerFactory.getLogger(TestTableMapReduce.class.getName());
protected Logger getLog() {
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapred/TestTableMapReduceUtil.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapred/TestTableMapReduceUtil.java
index 01a24fda6f3c..129db7321f25 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapred/TestTableMapReduceUtil.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapred/TestTableMapReduceUtil.java
@@ -17,8 +17,9 @@
*/
package org.apache.hadoop.hbase.mapred;
-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.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.File;
import java.io.IOException;
@@ -28,7 +29,6 @@
import java.util.Set;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileUtil;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Put;
@@ -44,26 +44,21 @@
import org.apache.hadoop.mapred.OutputCollector;
import org.apache.hadoop.mapred.Reporter;
import org.apache.hadoop.mapred.RunningJob;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.hbase.thirdparty.com.google.common.collect.ImmutableMap;
import org.apache.hbase.thirdparty.com.google.common.collect.ImmutableSet;
-@Category({ MapReduceTests.class, LargeTests.class })
+@Tag(MapReduceTests.TAG)
+@Tag(LargeTests.TAG)
public class TestTableMapReduceUtil {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestTableMapReduceUtil.class);
-
private static final Logger LOG = LoggerFactory.getLogger(TestTableMapReduceUtil.class);
private static Table presidentsTable;
@@ -88,18 +83,18 @@ public class TestTableMapReduceUtil {
private static final HBaseTestingUtility UTIL = new HBaseTestingUtility();
- @BeforeClass
+ @BeforeAll
public static void beforeClass() throws Exception {
UTIL.startMiniCluster();
presidentsTable = createAndFillTable(TableName.valueOf(TABLE_NAME));
}
- @AfterClass
+ @AfterAll
public static void afterClass() throws Exception {
UTIL.shutdownMiniCluster();
}
- @Before
+ @BeforeEach
public void before() throws IOException {
LOG.info("before");
UTIL.ensureSomeRegionServersAvailable(1);
@@ -136,7 +131,7 @@ private static void createPutCommand(Table table) throws IOException {
*/
@Test
public void shouldNumberOfReduceTaskNotExceedNumberOfRegionsForGivenTable() throws IOException {
- Assert.assertNotNull(presidentsTable);
+ assertNotNull(presidentsTable);
Configuration cfg = UTIL.getConfiguration();
JobConf jobConf = new JobConf(cfg);
TableMapReduceUtil.setNumReduceTasks(TABLE_NAME, jobConf);
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapred/TestTableOutputFormatConnectionExhaust.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapred/TestTableOutputFormatConnectionExhaust.java
index 1f5f7174c280..82e9fd13c96e 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapred/TestTableOutputFormatConnectionExhaust.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapred/TestTableOutputFormatConnectionExhaust.java
@@ -17,22 +17,20 @@
*/
package org.apache.hadoop.hbase.mapred;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.fail;
import java.io.IOException;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.mapred.JobConf;
import org.apache.hadoop.mapred.RecordWriter;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -41,13 +39,9 @@
* we can have many instances and not leak connections. This test creates a few TableOutputFormats
* and shouldn't fail due to ZK connection exhaustion.
*/
-@Category(MediumTests.class)
+@Tag(MediumTests.TAG)
public class TestTableOutputFormatConnectionExhaust {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestTableOutputFormatConnectionExhaust.class);
-
private static final Logger LOG =
LoggerFactory.getLogger(TestTableOutputFormatConnectionExhaust.class);
@@ -55,7 +49,7 @@ public class TestTableOutputFormatConnectionExhaust {
static final String TABLE = "TestTableOutputFormatConnectionExhaust";
static final String FAMILY = "family";
- @BeforeClass
+ @BeforeAll
public static void beforeClass() throws Exception {
// Default in ZookeeperMiniCluster is 1000, setting artificially low to trigger exhaustion.
// need min of 7 to properly start the default mini HBase cluster
@@ -63,12 +57,12 @@ public static void beforeClass() throws Exception {
UTIL.startMiniCluster();
}
- @AfterClass
+ @AfterAll
public static void afterClass() throws Exception {
UTIL.shutdownMiniCluster();
}
- @Before
+ @BeforeEach
public void before() throws IOException {
LOG.info("before");
UTIL.ensureSomeRegionServersAvailable(1);
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapred/TestTableSnapshotInputFormat.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapred/TestTableSnapshotInputFormat.java
index 756d41fc31e8..5452c8ede782 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapred/TestTableSnapshotInputFormat.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapred/TestTableSnapshotInputFormat.java
@@ -18,12 +18,13 @@
package org.apache.hadoop.hbase.mapred;
import static org.apache.hadoop.hbase.mapreduce.TableSnapshotInputFormatImpl.SNAPSHOT_INPUTFORMAT_LOCALITY_ENABLED_DEFAULT;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;
import java.io.IOException;
import java.util.Iterator;
import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.TableName;
@@ -45,28 +46,27 @@
import org.apache.hadoop.mapred.Reporter;
import org.apache.hadoop.mapred.RunningJob;
import org.apache.hadoop.mapred.lib.NullOutputFormat;
-import org.junit.Assert;
-import org.junit.ClassRule;
-import org.junit.Ignore;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.rules.TestName;
-
-@Category({ VerySlowMapReduceTests.class, LargeTests.class })
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
+
+@Tag(VerySlowMapReduceTests.TAG)
+@Tag(LargeTests.TAG)
public class TestTableSnapshotInputFormat extends TableSnapshotInputFormatTestBase {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestTableSnapshotInputFormat.class);
-
private static final byte[] aaa = Bytes.toBytes("aaa");
private static final byte[] after_zzz = Bytes.toBytes("zz{"); // 'z' + 1 => '{'
private static final String COLUMNS =
Bytes.toString(FAMILIES[0]) + " " + Bytes.toString(FAMILIES[1]);
- @Rule
- public TestName name = new TestName();
+ private String methodName;
+
+ @BeforeEach
+ public void beforeEach(TestInfo testInfo) {
+ methodName = testInfo.getTestMethod().get().getName();
+ }
@Override
protected byte[] getStartRow() {
@@ -108,7 +108,7 @@ public void close() {
@Test
public void testInitTableSnapshotMapperJobConfig() throws Exception {
- final TableName tableName = TableName.valueOf(name.getMethodName());
+ final TableName tableName = TableName.valueOf(methodName);
String snapshotName = "foo";
try {
@@ -122,11 +122,11 @@ public void testInitTableSnapshotMapperJobConfig() throws Exception {
// TODO: would be better to examine directly the cache instance that results from this
// config. Currently this is not possible because BlockCache initialization is static.
- Assert.assertEquals("Snapshot job should be configured for default LruBlockCache.",
- HConstants.HFILE_BLOCK_CACHE_SIZE_DEFAULT,
- job.getFloat(HConstants.HFILE_BLOCK_CACHE_SIZE_KEY, -1), 0.01);
- Assert.assertEquals("Snapshot job should not use BucketCache.", 0,
- job.getFloat("hbase.bucketcache.size", -1), 0.01);
+ assertEquals(HConstants.HFILE_BLOCK_CACHE_SIZE_DEFAULT,
+ job.getFloat(HConstants.HFILE_BLOCK_CACHE_SIZE_KEY, -1), 0.01,
+ "Snapshot job should be configured for default LruBlockCache.");
+ assertEquals(0, job.getFloat("hbase.bucketcache.size", -1), 0.01,
+ "Snapshot job should not use BucketCache.");
} finally {
UTIL.getAdmin().deleteSnapshot(snapshotName);
UTIL.deleteTable(tableName);
@@ -169,7 +169,7 @@ public void testRestoreSnapshotDoesNotCreateBackRefLinksInit(TableName tableName
protected void testWithMockedMapReduce(HBaseTestingUtility util, String snapshotName,
int numRegions, int numSplitsPerRegion, int expectedNumSplits, boolean setLocalityEnabledTo)
throws Exception {
- final TableName tableName = TableName.valueOf(name.getMethodName());
+ final TableName tableName = TableName.valueOf(methodName);
try {
createTableAndSnapshot(util, tableName, snapshotName, getStartRow(), getEndRow(), numRegions);
@@ -203,7 +203,7 @@ private void verifyWithMockedMapReduce(JobConf job, int numRegions, int expected
TableSnapshotInputFormat tsif = new TableSnapshotInputFormat();
InputSplit[] splits = tsif.getSplits(job, 0);
- Assert.assertEquals(expectedNumSplits, splits.length);
+ assertEquals(expectedNumSplits, splits.length);
HBaseTestingUtility.SeenRowTracker rowTracker =
new HBaseTestingUtility.SeenRowTracker(startRow, stopRow);
@@ -215,7 +215,7 @@ private void verifyWithMockedMapReduce(JobConf job, int numRegions, int expected
for (int i = 0; i < splits.length; i++) {
// validate input split
InputSplit split = splits[i];
- Assert.assertTrue(split instanceof TableSnapshotInputFormat.TableSnapshotRegionSplit);
+ assertTrue(split instanceof TableSnapshotInputFormat.TableSnapshotRegionSplit);
if (localityEnabled) {
// When localityEnabled is true, meant to verify split.getLocations()
// by the following statement:
@@ -223,9 +223,9 @@ private void verifyWithMockedMapReduce(JobConf job, int numRegions, int expected
// However, getLocations() of some splits could return an empty array (length is 0),
// so drop the verification on length.
// TODO: investigate how to verify split.getLocations() when localityEnabled is true
- Assert.assertTrue(split.getLocations() != null);
+ assertTrue(split.getLocations() != null);
} else {
- Assert.assertTrue(split.getLocations() != null && split.getLocations().length == 0);
+ assertTrue(split.getLocations() != null && split.getLocations().length == 0);
}
// validate record reader
@@ -291,7 +291,7 @@ public static void doTestWithMapReduce(HBaseTestingUtility util, TableName table
jobConf.setOutputFormat(NullOutputFormat.class);
RunningJob job = JobClient.runJob(jobConf);
- Assert.assertTrue(job.isSuccessful());
+ assertTrue(job.isSuccessful());
} finally {
if (!shutdownCluster) {
util.getAdmin().deleteSnapshot(snapshotName);
@@ -300,7 +300,7 @@ public static void doTestWithMapReduce(HBaseTestingUtility util, TableName table
}
}
- @Ignore // Ignored in mapred package because it keeps failing but allowed in mapreduce package.
+ @Disabled // Ignored in mapred package because it keeps failing but allowed in mapreduce package.
@Test
public void testWithMapReduceMultipleMappersPerRegion() throws Exception {
testWithMapReduce(UTIL, "testWithMapReduceMultiRegion", 10, 5, 50, false);
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/CopyTableTestBase.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/CopyTableTestBase.java
index d7648c26406d..d00f11fd2a39 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/CopyTableTestBase.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/CopyTableTestBase.java
@@ -17,10 +17,10 @@
*/
package org.apache.hadoop.hbase.mapreduce;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
import org.apache.commons.lang3.ArrayUtils;
@@ -39,8 +39,7 @@
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
import org.apache.hadoop.util.ToolRunner;
-import org.junit.Rule;
-import org.junit.rules.TestName;
+import org.junit.jupiter.api.TestInfo;
/**
* Base class for testing CopyTable MR tool.
@@ -55,9 +54,6 @@ public abstract class CopyTableTestBase {
protected static final byte[] FAMILY_B = Bytes.toBytes(FAMILY_B_STRING);
protected static final byte[] QUALIFIER = Bytes.toBytes("q");
- @Rule
- public TestName name = new TestName();
-
protected abstract Table createSourceTable(TableDescriptor desc) throws Exception;
protected abstract Table createTargetTable(TableDescriptor desc) throws Exception;
@@ -91,9 +87,10 @@ protected final void verifyRows(Table t, byte[] family, byte[] column) throws IO
}
}
- protected final void doCopyTableTest(Configuration conf, boolean bulkload) throws Exception {
- TableName tableName1 = TableName.valueOf(name.getMethodName() + "1");
- TableName tableName2 = TableName.valueOf(name.getMethodName() + "2");
+ protected final void doCopyTableTest(Configuration conf, boolean bulkload, TestInfo testInfo)
+ throws Exception {
+ TableName tableName1 = TableName.valueOf(testInfo.getTestMethod().get().getName() + "1");
+ TableName tableName2 = TableName.valueOf(testInfo.getTestMethod().get().getName() + "2");
byte[] family = Bytes.toBytes("family");
byte[] column = Bytes.toBytes("c1");
TableDescriptor desc1 = TableDescriptorBuilder.newBuilder(tableName1)
@@ -123,10 +120,10 @@ protected final void doCopyTableTest(Configuration conf, boolean bulkload) throw
}
}
- protected final void doCopyTableTestWithMob(Configuration conf, boolean bulkload)
- throws Exception {
- TableName tableName1 = TableName.valueOf(name.getMethodName() + "1");
- TableName tableName2 = TableName.valueOf(name.getMethodName() + "2");
+ protected final void doCopyTableTestWithMob(Configuration conf, boolean bulkload,
+ TestInfo testInfo) throws Exception {
+ TableName tableName1 = TableName.valueOf(testInfo.getTestMethod().get().getName() + "1");
+ TableName tableName2 = TableName.valueOf(testInfo.getTestMethod().get().getName() + "2");
byte[] family = Bytes.toBytes("mob");
byte[] column = Bytes.toBytes("c1");
@@ -163,15 +160,15 @@ protected final void doCopyTableTestWithMob(Configuration conf, boolean bulkload
Result r = t2.get(g);
assertEquals(1, r.size());
assertTrue(CellUtil.matchingQualifier(r.rawCells()[0], column));
- assertEquals("compare row values between two tables",
- t1.getDescriptor().getValue("row" + i), t2.getDescriptor().getValue("row" + i));
+ assertEquals(t1.getDescriptor().getValue("row" + i), t2.getDescriptor().getValue("row" + i),
+ "compare row values between two tables");
}
- assertEquals("compare count of mob rows after table copy", MobTestUtil.countMobRows(t1),
- MobTestUtil.countMobRows(t2));
- assertEquals("compare count of mob row values between two tables",
- t1.getDescriptor().getValues().size(), t2.getDescriptor().getValues().size());
- assertTrue("The mob row count is 0 but should be > 0", MobTestUtil.countMobRows(t2) > 0);
+ assertEquals(MobTestUtil.countMobRows(t1), MobTestUtil.countMobRows(t2),
+ "compare count of mob rows after table copy");
+ assertEquals(t1.getDescriptor().getValues().size(), t2.getDescriptor().getValues().size(),
+ "compare count of mob row values between two tables");
+ assertTrue(MobTestUtil.countMobRows(t2) > 0, "The mob row count is 0 but should be > 0");
} finally {
dropSourceTable(tableName1);
dropTargetTable(tableName2);
@@ -183,9 +180,9 @@ protected final boolean runCopy(Configuration conf, String[] args) throws Except
return status == 0;
}
- protected final void testStartStopRow(Configuration conf) throws Exception {
- final TableName tableName1 = TableName.valueOf(name.getMethodName() + "1");
- final TableName tableName2 = TableName.valueOf(name.getMethodName() + "2");
+ protected final void testStartStopRow(Configuration conf, TestInfo testInfo) throws Exception {
+ final TableName tableName1 = TableName.valueOf(testInfo.getTestMethod().get().getName() + "1");
+ final TableName tableName2 = TableName.valueOf(testInfo.getTestMethod().get().getName() + "2");
final byte[] family = Bytes.toBytes("family");
final byte[] column = Bytes.toBytes("c1");
final byte[] row0 = Bytes.toBytesBinary("\\x01row0");
@@ -231,9 +228,9 @@ protected final void testStartStopRow(Configuration conf) throws Exception {
}
}
- protected final void testRenameFamily(Configuration conf) throws Exception {
- TableName sourceTable = TableName.valueOf(name.getMethodName() + "-source");
- TableName targetTable = TableName.valueOf(name.getMethodName() + "-target");
+ protected final void testRenameFamily(Configuration conf, TestInfo testInfo) throws Exception {
+ TableName sourceTable = TableName.valueOf(testInfo.getTestMethod().get().getName() + "-source");
+ TableName targetTable = TableName.valueOf(testInfo.getTestMethod().get().getName() + "-target");
TableDescriptor desc1 = TableDescriptorBuilder.newBuilder(sourceTable)
.setColumnFamily(ColumnFamilyDescriptorBuilder.of(FAMILY_A))
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/MultiTableInputFormatTestBase.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/MultiTableInputFormatTestBase.java
index a9d9c4974f2f..17cbed4ac61b 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/MultiTableInputFormatTestBase.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/MultiTableInputFormatTestBase.java
@@ -17,8 +17,8 @@
*/
package org.apache.hadoop.hbase.mapreduce;
-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.File;
import java.io.IOException;
@@ -41,10 +41,10 @@
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.Reducer;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -54,7 +54,7 @@
* Base set of tests and setup for input formats touching multiple tables.
*/
public abstract class MultiTableInputFormatTestBase {
- static final Logger LOG = LoggerFactory.getLogger(TestMultiTableInputFormat.class);
+ static final Logger LOG = LoggerFactory.getLogger(MultiTableInputFormatTestBase.class);
public static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
static final String TABLE_NAME = "scantest";
static final byte[] INPUT_FAMILY = Bytes.toBytes("contents");
@@ -69,7 +69,7 @@ public abstract class MultiTableInputFormatTestBase {
}
}
- @BeforeClass
+ @BeforeAll
public static void setUpBeforeClass() throws Exception {
// switch TIF to log at DEBUG level
TEST_UTIL.enableDebug(MultiTableInputFormatBase.class);
@@ -84,12 +84,12 @@ public static void setUpBeforeClass() throws Exception {
}
}
- @AfterClass
+ @AfterAll
public static void tearDownAfterClass() throws Exception {
TEST_UTIL.shutdownMiniCluster();
}
- @After
+ @AfterEach
public void tearDown() throws Exception {
Configuration c = TEST_UTIL.getConfiguration();
FileUtil.fullyDelete(new File(c.get("hadoop.tmp.dir")));
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TableSnapshotInputFormatTestBase.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TableSnapshotInputFormatTestBase.java
index 31657870fd55..569ce13d9377 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TableSnapshotInputFormatTestBase.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TableSnapshotInputFormatTestBase.java
@@ -17,7 +17,9 @@
*/
package org.apache.hadoop.hbase.mapreduce;
-import static org.junit.Assert.assertFalse;
+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 java.io.IOException;
import java.util.Arrays;
@@ -42,10 +44,9 @@
import org.apache.hadoop.hbase.util.CommonFSUtils;
import org.apache.hadoop.hbase.util.FSUtils;
import org.apache.hadoop.hbase.util.HFileArchiveUtil;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -58,7 +59,7 @@ public abstract class TableSnapshotInputFormatTestBase {
protected FileSystem fs;
protected Path rootDir;
- @Before
+ @BeforeEach
public void setupCluster() throws Exception {
setupConf(UTIL.getConfiguration());
StartMiniClusterOption option =
@@ -69,7 +70,7 @@ public void setupCluster() throws Exception {
fs = rootDir.getFileSystem(UTIL.getConfiguration());
}
- @After
+ @AfterEach
public void tearDownCluster() throws Exception {
UTIL.shutdownMiniCluster();
}
@@ -142,11 +143,11 @@ public void testRestoreSnapshotDoesNotCreateBackRefLinks() throws Exception {
Path path = HFileLink.getBackReferencesDir(storeDir, status.getPath().getName());
// assert back references directory is empty
- assertFalse("There is a back reference in " + path, fs.exists(path));
+ assertFalse(fs.exists(path), "There is a back reference in " + path);
path = HFileLink.getBackReferencesDir(archiveStoreDir, status.getPath().getName());
// assert back references directory is empty
- assertFalse("There is a back reference in " + path, fs.exists(path));
+ assertFalse(fs.exists(path), "There is a back reference in " + path);
}
}
}
@@ -176,14 +177,14 @@ protected static void verifyRowFromMap(ImmutableBytesWritable key, Result result
Cell cell = scanner.current();
// assert that all Cells in the Result have the same key
- Assert.assertEquals(0, Bytes.compareTo(row, 0, row.length, cell.getRowArray(),
- cell.getRowOffset(), cell.getRowLength()));
+ assertEquals(0, Bytes.compareTo(row, 0, row.length, cell.getRowArray(), cell.getRowOffset(),
+ cell.getRowLength()));
}
for (byte[] family : FAMILIES) {
byte[] actual = result.getValue(family, family);
- Assert.assertArrayEquals("Row in snapshot does not match, expected:" + Bytes.toString(row)
- + " ,actual:" + Bytes.toString(actual), row, actual);
+ assertArrayEquals(row, actual, "Row in snapshot does not match, expected:"
+ + Bytes.toString(row) + " ,actual:" + Bytes.toString(actual));
}
}
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestCellBasedHFileOutputFormat2.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestCellBasedHFileOutputFormat2.java
index 58f600a8a859..aa1b4212fc52 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestCellBasedHFileOutputFormat2.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestCellBasedHFileOutputFormat2.java
@@ -18,12 +18,12 @@
package org.apache.hadoop.hbase.mapreduce;
import static org.apache.hadoop.hbase.regionserver.HStoreFile.BLOOM_FILTER_TYPE_KEY;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNotSame;
-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.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import java.io.IOException;
import java.lang.reflect.Field;
@@ -48,7 +48,6 @@
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.CompatibilitySingletonFactory;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HColumnDescriptor;
@@ -101,10 +100,8 @@
import org.apache.hadoop.mapreduce.RecordWriter;
import org.apache.hadoop.mapreduce.TaskAttemptContext;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
-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.Test;
import org.mockito.Mockito;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -114,13 +111,10 @@
* output. Creates a few inner classes to implement splits and an inputformat that emits keys and
* values like those of {@link PerformanceEvaluation}.
*/
-@Category({ VerySlowMapReduceTests.class, LargeTests.class })
+@org.junit.jupiter.api.Tag(VerySlowMapReduceTests.TAG)
+@org.junit.jupiter.api.Tag(LargeTests.TAG)
public class TestCellBasedHFileOutputFormat2 {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestCellBasedHFileOutputFormat2.class);
-
private final static int ROWSPERSPLIT = 1024;
public static final byte[] FAMILY_NAME = TestHRegionFileSystem.FAMILY_NAME;
@@ -286,7 +280,7 @@ private void setupRandomGeneratorMapper(Job job, boolean putSortReducer) {
* timestamp is {@link HConstants#LATEST_TIMESTAMP}.
* @see HBASE-2615
*/
- @Ignore("Goes zombie too frequently; needs work. See HBASE-14563")
+ @Disabled("Goes zombie too frequently; needs work. See HBASE-14563")
@Test
public void test_LATEST_TIMESTAMP_isReplaced() throws Exception {
Configuration conf = new Configuration(this.util.getConfiguration());
@@ -336,7 +330,7 @@ private TaskAttemptContext createTestTaskAttemptContext(final Job job) throws Ex
* Test that {@link HFileOutputFormat2} creates an HFile with TIMERANGE metadata used by
* time-restricted scans.
*/
- @Ignore("Goes zombie too frequently; needs work. See HBASE-14563")
+ @Disabled("Goes zombie too frequently; needs work. See HBASE-14563")
@Test
public void test_TIMERANGE() throws Exception {
Configuration conf = new Configuration(this.util.getConfiguration());
@@ -400,7 +394,7 @@ public void test_TIMERANGE() throws Exception {
/**
* Run small MR job.
*/
- @Ignore("Goes zombie too frequently; needs work. See HBASE-14563")
+ @Disabled("Goes zombie too frequently; needs work. See HBASE-14563")
@Test
public void testWritingPEData() throws Exception {
Configuration conf = util.getConfiguration();
@@ -489,7 +483,7 @@ public void test_WritingTagData() throws Exception {
}
}
- @Ignore("Goes zombie too frequently; needs work. See HBASE-14563")
+ @Disabled("Goes zombie too frequently; needs work. See HBASE-14563")
@Test
public void testJobConfiguration() throws Exception {
Configuration conf = new Configuration(this.util.getConfiguration());
@@ -523,14 +517,14 @@ private byte[][] generateRandomSplitKeys(int numKeys) {
return ret;
}
- @Ignore("Goes zombie too frequently; needs work. See HBASE-14563")
+ @Disabled("Goes zombie too frequently; needs work. See HBASE-14563")
@Test
public void testMRIncrementalLoad() throws Exception {
LOG.info("\nStarting test testMRIncrementalLoad\n");
doIncrementalLoadTest(false, false, false, "testMRIncrementalLoad");
}
- @Ignore("Goes zombie too frequently; needs work. See HBASE-14563")
+ @Disabled("Goes zombie too frequently; needs work. See HBASE-14563")
@Test
public void testMRIncrementalLoadWithSplit() throws Exception {
LOG.info("\nStarting test testMRIncrementalLoadWithSplit\n");
@@ -545,7 +539,7 @@ public void testMRIncrementalLoadWithSplit() throws Exception {
* supports explicit hostnames parameter (just like MiniDFSCluster does), we could test region
* locality features more easily.
*/
- @Ignore("Goes zombie too frequently; needs work. See HBASE-14563")
+ @Disabled("Goes zombie too frequently; needs work. See HBASE-14563")
@Test
public void testMRIncrementalLoadWithLocality() throws Exception {
LOG.info("\nStarting test testMRIncrementalLoadWithLocality\n");
@@ -553,7 +547,7 @@ public void testMRIncrementalLoadWithLocality() throws Exception {
doIncrementalLoadTest(true, true, false, "testMRIncrementalLoadWithLocality2");
}
- // @Ignore("Wahtevs")
+ // @Disabled("Wahtevs")
@Test
public void testMRIncrementalLoadWithPutSortReducer() throws Exception {
LOG.info("\nStarting test testMRIncrementalLoadWithPutSortReducer\n");
@@ -602,9 +596,9 @@ private void doIncrementalLoadTest(boolean shouldChangeRegions, boolean shouldKe
Table table = util.createTable(tableName, FAMILIES, splitKeys);
RegionLocator r = util.getConnection().getRegionLocator(tableName);
- assertEquals("Should start with empty table", 0, util.countRows(table));
+ assertEquals(0, util.countRows(table), "Should start with empty table");
int numRegions = r.getStartKeys().length;
- assertEquals("Should make " + regionNum + " regions", numRegions, regionNum);
+ assertEquals(numRegions, regionNum, "Should make " + regionNum + " regions");
allTables.put(tableStrSingle, table);
tableInfo.add(new HFileOutputFormat2.TableInfo(table.getTableDescriptor(), r));
@@ -615,7 +609,7 @@ private void doIncrementalLoadTest(boolean shouldChangeRegions, boolean shouldKe
for (Table tableSingle : allTables.values()) {
// This doesn't write into the table, just makes files
- assertEquals("HFOF should not touch actual table", 0, util.countRows(tableSingle));
+ assertEquals(0, util.countRows(tableSingle), "HFOF should not touch actual table");
}
int numTableDirs = 0;
for (FileStatus tf : testDir.getFileSystem(conf).listStatus(testDir)) {
@@ -639,10 +633,10 @@ private void doIncrementalLoadTest(boolean shouldChangeRegions, boolean shouldKe
}
}
}
- assertEquals("Column family not found in FS.", FAMILIES.length, dir);
+ assertEquals(FAMILIES.length, dir, "Column family not found in FS.");
}
if (writeMultipleTables) {
- assertEquals("Dir for all input tables not created", numTableDirs, allTables.size());
+ assertEquals(numTableDirs, allTables.size(), "Dir for all input tables not created");
}
Admin admin = util.getConnection().getAdmin();
@@ -685,12 +679,12 @@ private void doIncrementalLoadTest(boolean shouldChangeRegions, boolean shouldKe
int expectedRows = 0;
if (putSortReducer) {
// no rows should be extracted
- assertEquals("LoadIncrementalHFiles should put expected data in table", expectedRows,
- util.countRows(currentTable));
+ assertEquals(expectedRows, util.countRows(currentTable),
+ "LoadIncrementalHFiles should put expected data in table");
} else {
expectedRows = NMapInputFormat.getNumMapTasks(conf) * ROWSPERSPLIT;
- assertEquals("LoadIncrementalHFiles should put expected data in table", expectedRows,
- util.countRows(currentTable));
+ assertEquals(expectedRows, util.countRows(currentTable),
+ "LoadIncrementalHFiles should put expected data in table");
Scan scan = new Scan();
ResultScanner results = currentTable.getScanner(scan);
for (Result res : results) {
@@ -723,8 +717,8 @@ private void doIncrementalLoadTest(boolean shouldChangeRegions, boolean shouldKe
}
admin.enableTable(currentTableName);
util.waitTableAvailable(currentTableName);
- assertEquals("Data should remain after reopening of regions", tableDigestBefore,
- util.checksumRows(currentTable));
+ assertEquals(tableDigestBefore, util.checksumRows(currentTable),
+ "Data should remain after reopening of regions");
}
} finally {
for (HFileOutputFormat2.TableInfo tableInfoSingle : tableInfo) {
@@ -774,7 +768,7 @@ private void runIncrementalPELoad(Configuration conf,
* {@link HFileOutputFormat2#createFamilyCompressionMap(Configuration)}. Tests that the
* compression map is correctly serialized into and deserialized from configuration
*/
- @Ignore("Goes zombie too frequently; needs work. See HBASE-14563")
+ @Disabled("Goes zombie too frequently; needs work. See HBASE-14563")
@Test
public void testSerializeDeserializeFamilyCompressionMap() throws IOException {
for (int numCfs = 0; numCfs <= 3; numCfs++) {
@@ -794,8 +788,9 @@ public void testSerializeDeserializeFamilyCompressionMap() throws IOException {
// test that we have a value for all column families that matches with the
// used mock values
for (Entry entry : familyToCompression.entrySet()) {
- assertEquals("Compression configuration incorrect for column family:" + entry.getKey(),
- entry.getValue(), retrievedFamilyToCompressionMap.get(entry.getKey().getBytes("UTF-8")));
+ assertEquals(entry.getValue(),
+ retrievedFamilyToCompressionMap.get(entry.getKey().getBytes("UTF-8")),
+ "Compression configuration incorrect for column family:" + entry.getKey());
}
}
}
@@ -837,7 +832,7 @@ private Map getMockColumnFamiliesForCompression(i
* {@link HFileOutputFormat2#createFamilyBloomTypeMap(Configuration)}. Tests that the compression
* map is correctly serialized into and deserialized from configuration
*/
- @Ignore("Goes zombie too frequently; needs work. See HBASE-14563")
+ @Disabled("Goes zombie too frequently; needs work. See HBASE-14563")
@Test
public void testSerializeDeserializeFamilyBloomTypeMap() throws IOException {
for (int numCfs = 0; numCfs <= 2; numCfs++) {
@@ -857,8 +852,9 @@ public void testSerializeDeserializeFamilyBloomTypeMap() throws IOException {
// test that we have a value for all column families that matches with the
// used mock values
for (Entry entry : familyToBloomType.entrySet()) {
- assertEquals("BloomType configuration incorrect for column family:" + entry.getKey(),
- entry.getValue(), retrievedFamilyToBloomTypeMap.get(entry.getKey().getBytes("UTF-8")));
+ assertEquals(entry.getValue(),
+ retrievedFamilyToBloomTypeMap.get(entry.getKey().getBytes("UTF-8")),
+ "BloomType configuration incorrect for column family:" + entry.getKey());
}
}
}
@@ -897,7 +893,7 @@ private Map getMockColumnFamiliesForBloomType(int numCfs) {
* {@link HFileOutputFormat2#createFamilyBlockSizeMap(Configuration)}. Tests that the compression
* map is correctly serialized into and deserialized from configuration
*/
- @Ignore("Goes zombie too frequently; needs work. See HBASE-14563")
+ @Disabled("Goes zombie too frequently; needs work. See HBASE-14563")
@Test
public void testSerializeDeserializeFamilyBlockSizeMap() throws IOException {
for (int numCfs = 0; numCfs <= 3; numCfs++) {
@@ -917,8 +913,9 @@ public void testSerializeDeserializeFamilyBlockSizeMap() throws IOException {
// test that we have a value for all column families that matches with the
// used mock values
for (Entry entry : familyToBlockSize.entrySet()) {
- assertEquals("BlockSize configuration incorrect for column family:" + entry.getKey(),
- entry.getValue(), retrievedFamilyToBlockSizeMap.get(entry.getKey().getBytes("UTF-8")));
+ assertEquals(entry.getValue(),
+ retrievedFamilyToBlockSizeMap.get(entry.getKey().getBytes("UTF-8")),
+ "BlockSize configuration incorrect for column family:" + entry.getKey());
}
}
}
@@ -960,7 +957,7 @@ private Map getMockColumnFamiliesForBlockSize(int numCfs) {
* and {@link HFileOutputFormat2#createFamilyDataBlockEncodingMap(Configuration)}. Tests that the
* compression map is correctly serialized into and deserialized from configuration
*/
- @Ignore("Goes zombie too frequently; needs work. See HBASE-14563")
+ @Disabled("Goes zombie too frequently; needs work. See HBASE-14563")
@Test
public void testSerializeDeserializeFamilyDataBlockEncodingMap() throws IOException {
for (int numCfs = 0; numCfs <= 3; numCfs++) {
@@ -982,10 +979,9 @@ public void testSerializeDeserializeFamilyDataBlockEncodingMap() throws IOExcept
// test that we have a value for all column families that matches with the
// used mock values
for (Entry entry : familyToDataBlockEncoding.entrySet()) {
- assertEquals(
- "DataBlockEncoding configuration incorrect for column family:" + entry.getKey(),
- entry.getValue(),
- retrievedFamilyToDataBlockEncodingMap.get(entry.getKey().getBytes("UTF-8")));
+ assertEquals(entry.getValue(),
+ retrievedFamilyToDataBlockEncodingMap.get(entry.getKey().getBytes("UTF-8")),
+ "DataBlockEncoding configuration incorrect for column family:" + entry.getKey());
}
}
}
@@ -1037,7 +1033,7 @@ private void setupMockTableName(RegionLocator table) throws IOException {
* Test that {@link HFileOutputFormat2} RecordWriter uses compression and bloom filter settings
* from the column family descriptor
*/
- @Ignore("Goes zombie too frequently; needs work. See HBASE-14563")
+ @Disabled("Goes zombie too frequently; needs work. See HBASE-14563")
@Test
public void testColumnFamilySettings() throws Exception {
Configuration conf = new Configuration(this.util.getConfiguration());
@@ -1098,12 +1094,11 @@ public void testColumnFamilySettings() throws Exception {
byte[] bloomFilter = fileInfo.get(BLOOM_FILTER_TYPE_KEY);
if (bloomFilter == null) bloomFilter = Bytes.toBytes("NONE");
- assertEquals(
- "Incorrect bloom filter used for column family " + familyStr + "(reader: " + reader + ")",
- hcd.getBloomFilterType(), BloomType.valueOf(Bytes.toString(bloomFilter)));
- assertEquals(
- "Incorrect compression used for column family " + familyStr + "(reader: " + reader + ")",
- hcd.getCompressionType(), reader.getFileContext().getCompression());
+ assertEquals(hcd.getBloomFilterType(), BloomType.valueOf(Bytes.toString(bloomFilter)),
+ "Incorrect bloom filter used for column family " + familyStr + "(reader: " + reader
+ + ")");
+ assertEquals(hcd.getCompressionType(), reader.getFileContext().getCompression(),
+ "Incorrect compression used for column family " + familyStr + "(reader: " + reader + ")");
}
} finally {
dir.getFileSystem(conf).delete(dir, true);
@@ -1143,7 +1138,7 @@ private void writeRandomKeyValues(RecordWriter wri
* excluded from minor compaction. Without the fix of HBASE-6901, an
* ArrayIndexOutOfBoundsException will be thrown.
*/
- @Ignore("Flakey: See HBASE-9051")
+ @Disabled("Flakey: See HBASE-9051")
@Test
public void testExcludeAllFromMinorCompaction() throws Exception {
Configuration conf = util.getConfiguration();
@@ -1155,7 +1150,7 @@ public void testExcludeAllFromMinorCompaction() throws Exception {
Table table = util.createTable(TABLE_NAMES[0], FAMILIES);
RegionLocator locator = conn.getRegionLocator(TABLE_NAMES[0])) {
final FileSystem fs = util.getDFSCluster().getFileSystem();
- assertEquals("Should start with empty table", 0, util.countRows(table));
+ assertEquals(0, util.countRows(table), "Should start with empty table");
// deep inspection: get the StoreFile dir
final Path storePath =
@@ -1179,8 +1174,8 @@ public void testExcludeAllFromMinorCompaction() throws Exception {
// Ensure data shows up
int expectedRows = 2 * NMapInputFormat.getNumMapTasks(conf) * ROWSPERSPLIT;
- assertEquals("LoadIncrementalHFiles should put expected data in table", expectedRows,
- util.countRows(table));
+ assertEquals(expectedRows, util.countRows(table),
+ "LoadIncrementalHFiles should put expected data in table");
// should have a second StoreFile now
assertEquals(2, fs.listStatus(storePath).length);
@@ -1225,7 +1220,7 @@ public Boolean call() throws Exception {
}
}
- @Ignore("Goes zombie too frequently; needs work. See HBASE-14563")
+ @Disabled("Goes zombie too frequently; needs work. See HBASE-14563")
@Test
public void testExcludeMinorCompaction() throws Exception {
Configuration conf = util.getConfiguration();
@@ -1238,7 +1233,7 @@ public void testExcludeMinorCompaction() throws Exception {
Path testDir = util.getDataTestDirOnTestFS("testExcludeMinorCompaction");
final FileSystem fs = util.getDFSCluster().getFileSystem();
Table table = util.createTable(TABLE_NAMES[0], FAMILIES);
- assertEquals("Should start with empty table", 0, util.countRows(table));
+ assertEquals(0, util.countRows(table), "Should start with empty table");
// deep inspection: get the StoreFile dir
final Path storePath =
@@ -1273,8 +1268,8 @@ public Boolean call() throws Exception {
// Ensure data shows up
int expectedRows = NMapInputFormat.getNumMapTasks(conf) * ROWSPERSPLIT;
- assertEquals("LoadIncrementalHFiles should put expected data in table", expectedRows + 1,
- util.countRows(table));
+ assertEquals(expectedRows + 1, util.countRows(table),
+ "LoadIncrementalHFiles should put expected data in table");
// should have a second StoreFile now
assertEquals(2, fs.listStatus(storePath).length);
@@ -1319,9 +1314,9 @@ private void quickPoll(Callable c, int waitMs) throws Exception {
fail();
}
- public static void main(String args[]) throws Exception {
- new TestCellBasedHFileOutputFormat2().manualTest(args);
- }
+ // public static void main(String args[]) throws Exception {
+ // new TestCellBasedHFileOutputFormat2().manualTest(args);
+ // }
public void manualTest(String args[]) throws Exception {
Configuration conf = HBaseConfiguration.create();
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestCellBasedImportExport2.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestCellBasedImportExport2.java
index c9fb941a2022..a1d6293d4546 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestCellBasedImportExport2.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestCellBasedImportExport2.java
@@ -17,10 +17,10 @@
*/
package org.apache.hadoop.hbase.mapreduce;
-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 static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
@@ -39,7 +39,6 @@
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellUtil;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.KeepDeletedCells;
@@ -76,16 +75,13 @@
import org.apache.hadoop.mapreduce.Mapper.Context;
import org.apache.hadoop.util.GenericOptionsParser;
import org.apache.hadoop.util.ToolRunner;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.Before;
-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.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.slf4j.Logger;
@@ -94,13 +90,10 @@
/**
* Tests the table import and table export MR job functionality
*/
-@Category({ VerySlowMapReduceTests.class, MediumTests.class })
+@Tag(VerySlowMapReduceTests.TAG)
+@Tag(MediumTests.TAG)
public class TestCellBasedImportExport2 {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestCellBasedImportExport2.class);
-
private static final Logger LOG = LoggerFactory.getLogger(TestCellBasedImportExport2.class);
protected static final HBaseTestingUtility UTIL = new HBaseTestingUtility();
private static final byte[] ROW1 = Bytes.toBytesBinary("\\x32row1");
@@ -118,8 +111,9 @@ public class TestCellBasedImportExport2 {
private static final long now = EnvironmentEdgeManager.currentTime();
private final TableName EXPORT_TABLE = TableName.valueOf("export_table");
private final TableName IMPORT_TABLE = TableName.valueOf("import_table");
+ private String methodName;
- @BeforeClass
+ @BeforeAll
public static void beforeClass() throws Throwable {
// Up the handlers; this test needs more than usual.
UTIL.getConfiguration().setInt(HConstants.REGION_SERVER_HIGH_PRIORITY_HANDLER_COUNT, 10);
@@ -128,20 +122,18 @@ public static void beforeClass() throws Throwable {
new Path(OUTPUT_DIR).makeQualified(FileSystem.get(UTIL.getConfiguration())).toString();
}
- @AfterClass
+ @AfterAll
public static void afterClass() throws Throwable {
UTIL.shutdownMiniCluster();
}
- @Rule
- public final TestName name = new TestName();
-
- @Before
- public void announce() {
- LOG.info("Running " + name.getMethodName());
+ @BeforeEach
+ public void announce(TestInfo testInfo) throws IOException {
+ methodName = testInfo.getTestMethod().get().getName();
+ LOG.info("Running " + methodName);
}
- @After
+ @AfterEach
public void cleanup() throws Throwable {
FileSystem fs = FileSystem.get(UTIL.getConfiguration());
fs.delete(new Path(OUTPUT_DIR), true);
@@ -182,7 +174,7 @@ boolean runImport(String[] args) throws Throwable {
*/
@Test
public void testSimpleCase() throws Throwable {
- try (Table t = UTIL.createTable(TableName.valueOf(name.getMethodName()), FAMILYA, 3);) {
+ try (Table t = UTIL.createTable(TableName.valueOf(methodName), FAMILYA, 3);) {
Put p = new Put(ROW1);
p.addColumn(FAMILYA, QUAL, now, QUAL);
p.addColumn(FAMILYA, QUAL, now + 1, QUAL);
@@ -203,12 +195,19 @@ public void testSimpleCase() throws Throwable {
String[] args = new String[] {
// Only export row1 & row2.
"-D" + TableInputFormat.SCAN_ROW_START + "=\\x32row1",
- "-D" + TableInputFormat.SCAN_ROW_STOP + "=\\x32row3", name.getMethodName(), FQ_OUTPUT_DIR,
- "1000", // max number of key versions per key to export
+ "-D" + TableInputFormat.SCAN_ROW_STOP + "=\\x32row3", methodName, FQ_OUTPUT_DIR, "1000", // max
+ // number
+ // of
+ // key
+ // versions
+ // per
+ // key
+ // to
+ // export
};
assertTrue(runExport(args));
- final String IMPORT_TABLE = name.getMethodName() + "import";
+ final String IMPORT_TABLE = methodName + "import";
try (Table t = UTIL.createTable(TableName.valueOf(IMPORT_TABLE), FAMILYB, 3);) {
args =
new String[] { "-D" + Import.CF_RENAME_PROP + "=" + FAMILYA_STRING + ":" + FAMILYB_STRING,
@@ -275,8 +274,7 @@ public void testImport94Table() throws Throwable {
*/
@Test
public void testExportScannerBatching() throws Throwable {
- TableDescriptor desc = TableDescriptorBuilder
- .newBuilder(TableName.valueOf(name.getMethodName()))
+ TableDescriptor desc = TableDescriptorBuilder.newBuilder(TableName.valueOf(methodName))
.setColumnFamily(ColumnFamilyDescriptorBuilder.newBuilder(FAMILYA).setMaxVersions(1).build())
.build();
UTIL.getAdmin().createTable(desc);
@@ -294,7 +292,7 @@ public void testExportScannerBatching() throws Throwable {
// scanner
// batching
// arg.
- name.getMethodName(), FQ_OUTPUT_DIR };
+ methodName, FQ_OUTPUT_DIR };
assertTrue(runExport(args));
FileSystem fs = FileSystem.get(UTIL.getConfiguration());
@@ -304,11 +302,10 @@ public void testExportScannerBatching() throws Throwable {
@Test
public void testWithDeletes() throws Throwable {
- TableDescriptor desc =
- TableDescriptorBuilder.newBuilder(TableName.valueOf(name.getMethodName()))
- .setColumnFamily(ColumnFamilyDescriptorBuilder.newBuilder(FAMILYA).setMaxVersions(5)
- .setKeepDeletedCells(KeepDeletedCells.TRUE).build())
- .build();
+ TableDescriptor desc = TableDescriptorBuilder
+ .newBuilder(TableName.valueOf(methodName)).setColumnFamily(ColumnFamilyDescriptorBuilder
+ .newBuilder(FAMILYA).setMaxVersions(5).setKeepDeletedCells(KeepDeletedCells.TRUE).build())
+ .build();
UTIL.getAdmin().createTable(desc);
try (Table t = UTIL.getConnection().getTable(desc.getTableName());) {
@@ -327,12 +324,20 @@ public void testWithDeletes() throws Throwable {
t.delete(d);
}
- String[] args = new String[] { "-D" + ExportUtils.RAW_SCAN + "=true", name.getMethodName(),
- FQ_OUTPUT_DIR, "1000", // max number of key versions per key to export
- };
+ String[] args =
+ new String[] { "-D" + ExportUtils.RAW_SCAN + "=true", methodName, FQ_OUTPUT_DIR, "1000", // max
+ // number
+ // of
+ // key
+ // versions
+ // per
+ // key
+ // to
+ // export
+ };
assertTrue(runExport(args));
- final String IMPORT_TABLE = name.getMethodName() + "import";
+ final String IMPORT_TABLE = methodName + "import";
desc = TableDescriptorBuilder
.newBuilder(TableName.valueOf(IMPORT_TABLE)).setColumnFamily(ColumnFamilyDescriptorBuilder
.newBuilder(FAMILYA).setMaxVersions(5).setKeepDeletedCells(KeepDeletedCells.TRUE).build())
@@ -360,12 +365,11 @@ public void testWithDeletes() throws Throwable {
@Test
public void testWithMultipleDeleteFamilyMarkersOfSameRowSameFamily() throws Throwable {
- final TableName exportTable = TableName.valueOf(name.getMethodName());
- TableDescriptor desc =
- TableDescriptorBuilder.newBuilder(TableName.valueOf(name.getMethodName()))
- .setColumnFamily(ColumnFamilyDescriptorBuilder.newBuilder(FAMILYA).setMaxVersions(5)
- .setKeepDeletedCells(KeepDeletedCells.TRUE).build())
- .build();
+ final TableName exportTable = TableName.valueOf(methodName);
+ TableDescriptor desc = TableDescriptorBuilder
+ .newBuilder(TableName.valueOf(methodName)).setColumnFamily(ColumnFamilyDescriptorBuilder
+ .newBuilder(FAMILYA).setMaxVersions(5).setKeepDeletedCells(KeepDeletedCells.TRUE).build())
+ .build();
UTIL.getAdmin().createTable(desc);
Table exportT = UTIL.getConnection().getTable(exportTable);
@@ -394,7 +398,7 @@ public void testWithMultipleDeleteFamilyMarkersOfSameRowSameFamily() throws Thro
};
assertTrue(runExport(args));
- final String importTable = name.getMethodName() + "import";
+ final String importTable = methodName + "import";
desc = TableDescriptorBuilder
.newBuilder(TableName.valueOf(importTable)).setColumnFamily(ColumnFamilyDescriptorBuilder
.newBuilder(FAMILYA).setMaxVersions(5).setKeepDeletedCells(KeepDeletedCells.TRUE).build())
@@ -431,8 +435,7 @@ public void testWithMultipleDeleteFamilyMarkersOfSameRowSameFamily() throws Thro
@Test
public void testWithFilter() throws Throwable {
// Create simple table to export
- TableDescriptor desc = TableDescriptorBuilder
- .newBuilder(TableName.valueOf(name.getMethodName()))
+ TableDescriptor desc = TableDescriptorBuilder.newBuilder(TableName.valueOf(methodName))
.setColumnFamily(ColumnFamilyDescriptorBuilder.newBuilder(FAMILYA).setMaxVersions(5).build())
.build();
UTIL.getAdmin().createTable(desc);
@@ -452,11 +455,11 @@ public void testWithFilter() throws Throwable {
exportTable.put(Arrays.asList(p1, p2));
// Export the simple table
- String[] args = new String[] { name.getMethodName(), FQ_OUTPUT_DIR, "1000" };
+ String[] args = new String[] { methodName, FQ_OUTPUT_DIR, "1000" };
assertTrue(runExport(args));
// Import to a new table
- final String IMPORT_TABLE = name.getMethodName() + "import";
+ final String IMPORT_TABLE = methodName + "import";
desc = TableDescriptorBuilder.newBuilder(TableName.valueOf(IMPORT_TABLE))
.setColumnFamily(ColumnFamilyDescriptorBuilder.newBuilder(FAMILYA).setMaxVersions(5).build())
.build();
@@ -472,14 +475,14 @@ public void testWithFilter() throws Throwable {
PrefixFilter filter = new PrefixFilter(ROW1);
int count = getCount(exportTable, filter);
- Assert.assertEquals("Unexpected row count between export and import tables", count,
- getCount(importTable, null));
+ assertEquals(count, getCount(importTable, null),
+ "Unexpected row count between export and import tables");
// and then test that a broken command doesn't bork everything - easier here because we don't
// need to re-run the export job
args = new String[] { "-D" + Import.FILTER_CLASS_CONF_KEY + "=" + Filter.class.getName(),
- "-D" + Import.FILTER_ARGS_CONF_KEY + "=" + Bytes.toString(ROW1) + "", name.getMethodName(),
+ "-D" + Import.FILTER_ARGS_CONF_KEY + "=" + Bytes.toString(ROW1) + "", methodName,
FQ_OUTPUT_DIR, "1000" };
assertFalse(runImport(args));
@@ -658,7 +661,7 @@ public void testAddFilterAndArguments() throws IOException {
@Test
public void testDurability() throws Throwable {
// Create an export table.
- String exportTableName = name.getMethodName() + "export";
+ String exportTableName = methodName + "export";
try (Table exportTable = UTIL.createTable(TableName.valueOf(exportTableName), FAMILYA, 3);) {
// Insert some data
@@ -679,7 +682,7 @@ public void testDurability() throws Throwable {
assertTrue(runExport(args));
// Create the table for import
- String importTableName = name.getMethodName() + "import1";
+ String importTableName = methodName + "import1";
Table importTable = UTIL.createTable(TableName.valueOf(importTableName), FAMILYA, 3);
// Register the wal listener for the import table
@@ -699,7 +702,7 @@ public void testDurability() throws Throwable {
assertTrue(getCount(importTable, null) == 2);
// Run the import with the default durability option
- importTableName = name.getMethodName() + "import2";
+ importTableName = methodName + "import2";
importTable = UTIL.createTable(TableName.valueOf(importTableName), FAMILYA, 3);
region = UTIL.getHBaseCluster().getRegionServerThreads().get(0).getRegionServer()
.getRegions(importTable.getName()).get(0).getRegionInfo();
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestCellBasedWALPlayer2.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestCellBasedWALPlayer2.java
index 283acbabf6e4..c73aa2825af9 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestCellBasedWALPlayer2.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestCellBasedWALPlayer2.java
@@ -17,9 +17,9 @@
*/
package org.apache.hadoop.hbase.mapreduce;
-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 static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
@@ -33,7 +33,6 @@
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellUtil;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.KeyValue;
@@ -58,26 +57,21 @@
import org.apache.hadoop.mapreduce.Mapper;
import org.apache.hadoop.mapreduce.Mapper.Context;
import org.apache.hadoop.util.ToolRunner;
-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.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
/**
* Basic test for the WALPlayer M/R tool
*/
-@Category({ MapReduceTests.class, LargeTests.class })
+@Tag(MapReduceTests.TAG)
+@Tag(LargeTests.TAG)
public class TestCellBasedWALPlayer2 {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestCellBasedWALPlayer2.class);
-
private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
private static MiniHBaseCluster cluster;
private static Path rootDir;
@@ -86,10 +80,7 @@ public class TestCellBasedWALPlayer2 {
private static FileSystem logFs;
private static Configuration conf;
- @Rule
- public TestName name = new TestName();
-
- @BeforeClass
+ @BeforeAll
public static void beforeClass() throws Exception {
conf = TEST_UTIL.getConfiguration();
rootDir = TEST_UTIL.createRootDir();
@@ -99,7 +90,7 @@ public static void beforeClass() throws Exception {
cluster = TEST_UTIL.startMiniCluster();
}
- @AfterClass
+ @AfterAll
public static void afterClass() throws Exception {
TEST_UTIL.shutdownMiniCluster();
fs.delete(rootDir, true);
@@ -110,9 +101,9 @@ public static void afterClass() throws Exception {
* Simple end-to-end test
*/
@Test
- public void testWALPlayer() throws Exception {
- final TableName tableName1 = TableName.valueOf(name.getMethodName() + "1");
- final TableName tableName2 = TableName.valueOf(name.getMethodName() + "2");
+ public void testWALPlayer(TestInfo testInfo) throws Exception {
+ final TableName tableName1 = TableName.valueOf(testInfo.getTestMethod().get().getName() + "1");
+ final TableName tableName2 = TableName.valueOf(testInfo.getTestMethod().get().getName() + "2");
final byte[] FAMILY = Bytes.toBytes("family");
final byte[] COLUMN1 = Bytes.toBytes("c1");
final byte[] COLUMN2 = Bytes.toBytes("c2");
@@ -229,7 +220,5 @@ public void testMainMethod() throws Exception {
System.setErr(oldPrintStream);
System.setSecurityManager(SECURITY_MANAGER);
}
-
}
-
}
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestCellCounter.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestCellCounter.java
index cc2b3459a867..a952566c2c68 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestCellCounter.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestCellCounter.java
@@ -17,9 +17,9 @@
*/
package org.apache.hadoop.hbase.mapreduce;
-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 java.io.ByteArrayOutputStream;
import java.io.File;
@@ -30,7 +30,6 @@
import org.apache.hadoop.fs.FileUtil;
import org.apache.hadoop.fs.LocalFileSystem;
import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.TableName;
@@ -42,19 +41,15 @@
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
import org.apache.hadoop.hbase.util.LauncherSecurityManager;
import org.apache.hadoop.util.ToolRunner;
-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;
-@Category({ MapReduceTests.class, LargeTests.class })
+@Tag(MapReduceTests.TAG)
+@Tag(LargeTests.TAG)
public class TestCellCounter {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestCellCounter.class);
private static final HBaseTestingUtility UTIL = new HBaseTestingUtility();
private static final byte[] ROW1 = Bytes.toBytesBinary("\\x01row1");
@@ -70,17 +65,14 @@ public class TestCellCounter {
"target" + File.separator + "test-data" + File.separator + "output";
private static long now = EnvironmentEdgeManager.currentTime();
- @Rule
- public TestName name = new TestName();
-
- @BeforeClass
+ @BeforeAll
public static void beforeClass() throws Exception {
UTIL.startMiniCluster();
FQ_OUTPUT_DIR = new Path(OUTPUT_DIR).makeQualified(new LocalFileSystem());
FileUtil.fullyDelete(new File(OUTPUT_DIR));
}
- @AfterClass
+ @AfterAll
public static void afterClass() throws Exception {
UTIL.shutdownMiniCluster();
}
@@ -89,8 +81,8 @@ public static void afterClass() throws Exception {
* Test CellCounter all data should print to output
*/
@Test
- public void testCellCounter() throws Exception {
- final TableName sourceTable = TableName.valueOf(name.getMethodName());
+ public void testCellCounter(TestInfo testInfo) throws Exception {
+ final TableName sourceTable = TableName.valueOf(testInfo.getTestMethod().get().getName());
byte[][] families = { FAMILY_A, FAMILY_B };
try (Table t = UTIL.createTable(sourceTable, families)) {
Put p = new Put(ROW1);
@@ -125,8 +117,8 @@ public void testCellCounter() throws Exception {
* Test CellCounter all data should print to output
*/
@Test
- public void testCellCounterPrefix() throws Exception {
- final TableName sourceTable = TableName.valueOf(name.getMethodName());
+ public void testCellCounterPrefix(TestInfo testInfo) throws Exception {
+ final TableName sourceTable = TableName.valueOf(testInfo.getTestMethod().get().getName());
byte[][] families = { FAMILY_A, FAMILY_B };
try (Table t = UTIL.createTable(sourceTable, families)) {
Put p = new Put(ROW1);
@@ -161,8 +153,8 @@ public void testCellCounterPrefix() throws Exception {
* Test CellCounter with time range all data should print to output
*/
@Test
- public void testCellCounterStartTimeRange() throws Exception {
- final TableName sourceTable = TableName.valueOf(name.getMethodName());
+ public void testCellCounterStartTimeRange(TestInfo testInfo) throws Exception {
+ final TableName sourceTable = TableName.valueOf(testInfo.getTestMethod().get().getName());
byte[][] families = { FAMILY_A, FAMILY_B };
try (Table t = UTIL.createTable(sourceTable, families)) {
Put p = new Put(ROW1);
@@ -198,8 +190,8 @@ public void testCellCounterStartTimeRange() throws Exception {
* Test CellCounter with time range all data should print to output
*/
@Test
- public void testCellCounteEndTimeRange() throws Exception {
- final TableName sourceTable = TableName.valueOf(name.getMethodName());
+ public void testCellCounteEndTimeRange(TestInfo testInfo) throws Exception {
+ final TableName sourceTable = TableName.valueOf(testInfo.getTestMethod().get().getName());
byte[][] families = { FAMILY_A, FAMILY_B };
try (Table t = UTIL.createTable(sourceTable, families)) {
Put p = new Put(ROW1);
@@ -235,8 +227,8 @@ public void testCellCounteEndTimeRange() throws Exception {
* Test CellCounter with time range all data should print to output
*/
@Test
- public void testCellCounteOutOfTimeRange() throws Exception {
- final TableName sourceTable = TableName.valueOf(name.getMethodName());
+ public void testCellCounteOutOfTimeRange(TestInfo testInfo) throws Exception {
+ final TableName sourceTable = TableName.valueOf(testInfo.getTestMethod().get().getName());
byte[][] families = { FAMILY_A, FAMILY_B };
try (Table t = UTIL.createTable(sourceTable, families)) {
Put p = new Put(ROW1);
@@ -308,8 +300,8 @@ public void testCellCounterMain() throws Exception {
* Test CellCounter for complete table all data should print to output
*/
@Test
- public void testCellCounterForCompleteTable() throws Exception {
- final TableName sourceTable = TableName.valueOf(name.getMethodName());
+ public void testCellCounterForCompleteTable(TestInfo testInfo) throws Exception {
+ final TableName sourceTable = TableName.valueOf(testInfo.getTestMethod().get().getName());
String outputPath = OUTPUT_DIR + sourceTable;
LocalFileSystem localFileSystem = new LocalFileSystem();
Path outputDir = new Path(outputPath).makeQualified(localFileSystem.getUri(),
@@ -361,7 +353,7 @@ public void testCellCounterForCompleteTable() throws Exception {
@Test
public void TestCellCounterWithoutOutputDir() throws Exception {
String[] args = new String[] { "tableName" };
- assertEquals("CellCounter should exit with -1 as output directory is not specified.", -1,
- ToolRunner.run(HBaseConfiguration.create(), new CellCounter(), args));
+ assertEquals(-1, ToolRunner.run(HBaseConfiguration.create(), new CellCounter(), args),
+ "CellCounter should exit with -1 as output directory is not specified.");
}
}
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestCopyTable.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestCopyTable.java
index 9992f28b70a4..e072420c0c4a 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestCopyTable.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestCopyTable.java
@@ -17,18 +17,17 @@
*/
package org.apache.hadoop.hbase.mapreduce;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertThrows;
-import static org.junit.Assert.assertTrue;
-import static org.junit.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.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.util.HashMap;
import java.util.Map;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.ColumnFamilyDescriptor;
@@ -45,35 +44,27 @@
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
import org.apache.hadoop.hbase.util.LauncherSecurityManager;
-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;
/**
* Basic test for the CopyTable M/R tool
*/
-@Category({ MapReduceTests.class, LargeTests.class })
+@Tag(MapReduceTests.TAG)
+@Tag(LargeTests.TAG)
public class TestCopyTable extends CopyTableTestBase {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestCopyTable.class);
-
private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
- @Rule
- public TestName name = new TestName();
-
- @BeforeClass
+ @BeforeAll
public static void beforeClass() throws Exception {
TEST_UTIL.startMiniCluster(3);
}
- @AfterClass
+ @AfterAll
public static void afterClass() throws Exception {
TEST_UTIL.shutdownMiniCluster();
}
@@ -107,45 +98,45 @@ protected String[] getPeerClusterOptions() throws Exception {
* Simple end-to-end test
*/
@Test
- public void testCopyTable() throws Exception {
- doCopyTableTest(TEST_UTIL.getConfiguration(), false);
+ public void testCopyTable(TestInfo testInfo) throws Exception {
+ doCopyTableTest(TEST_UTIL.getConfiguration(), false, testInfo);
}
/**
* Simple end-to-end test with bulkload.
*/
@Test
- public void testCopyTableWithBulkload() throws Exception {
- doCopyTableTest(TEST_UTIL.getConfiguration(), true);
+ public void testCopyTableWithBulkload(TestInfo testInfo) throws Exception {
+ doCopyTableTest(TEST_UTIL.getConfiguration(), true, testInfo);
}
/**
* Simple end-to-end test on table with MOB
*/
@Test
- public void testCopyTableWithMob() throws Exception {
- doCopyTableTestWithMob(TEST_UTIL.getConfiguration(), false);
+ public void testCopyTableWithMob(TestInfo testInfo) throws Exception {
+ doCopyTableTestWithMob(TEST_UTIL.getConfiguration(), false, testInfo);
}
/**
* Simple end-to-end test with bulkload on table with MOB.
*/
@Test
- public void testCopyTableWithBulkloadWithMob() throws Exception {
- doCopyTableTestWithMob(TEST_UTIL.getConfiguration(), true);
+ public void testCopyTableWithBulkloadWithMob(TestInfo testInfo) throws Exception {
+ doCopyTableTestWithMob(TEST_UTIL.getConfiguration(), true, testInfo);
}
@Test
- public void testStartStopRow() throws Exception {
- testStartStopRow(TEST_UTIL.getConfiguration());
+ public void testStartStopRow(TestInfo testInfo) throws Exception {
+ testStartStopRow(TEST_UTIL.getConfiguration(), testInfo);
}
/**
* Test copy of table from sourceTable to targetTable all rows from family a
*/
@Test
- public void testRenameFamily() throws Exception {
- testRenameFamily(TEST_UTIL.getConfiguration());
+ public void testRenameFamily(TestInfo testInfo) throws Exception {
+ testRenameFamily(TEST_UTIL.getConfiguration(), testInfo);
}
/**
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestCopyTableToPeerCluster.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestCopyTableToPeerCluster.java
index 8e8ef0913d2f..e5a029909247 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestCopyTableToPeerCluster.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestCopyTableToPeerCluster.java
@@ -17,42 +17,38 @@
*/
package org.apache.hadoop.hbase.mapreduce;
-import static org.junit.Assert.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertFalse;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Table;
import org.apache.hadoop.hbase.client.TableDescriptor;
import org.apache.hadoop.hbase.testclassification.LargeTests;
import org.apache.hadoop.hbase.testclassification.MapReduceTests;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
/**
* Test CopyTable between clusters
*/
-@Category({ MapReduceTests.class, LargeTests.class })
+@Tag(MapReduceTests.TAG)
+@Tag(LargeTests.TAG)
public class TestCopyTableToPeerCluster extends CopyTableTestBase {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestCopyTableToPeerCluster.class);
-
private static final HBaseTestingUtility UTIL1 = new HBaseTestingUtility();
private static final HBaseTestingUtility UTIL2 = new HBaseTestingUtility();
- @BeforeClass
+ @BeforeAll
public static void beforeClass() throws Exception {
UTIL1.startMiniCluster(3);
UTIL2.startMiniCluster(3);
}
- @AfterClass
+ @AfterAll
public static void afterClass() throws Exception {
UTIL1.shutdownMiniCluster();
UTIL2.shutdownMiniCluster();
@@ -87,35 +83,35 @@ protected String[] getPeerClusterOptions() throws Exception {
* Simple end-to-end test
*/
@Test
- public void testCopyTable() throws Exception {
- doCopyTableTest(UTIL1.getConfiguration(), false);
+ public void testCopyTable(TestInfo testInfo) throws Exception {
+ doCopyTableTest(UTIL1.getConfiguration(), false, testInfo);
}
/**
* Simple end-to-end test on table with MOB
*/
@Test
- public void testCopyTableWithMob() throws Exception {
- doCopyTableTestWithMob(UTIL1.getConfiguration(), false);
+ public void testCopyTableWithMob(TestInfo testInfo) throws Exception {
+ doCopyTableTestWithMob(UTIL1.getConfiguration(), false, testInfo);
}
@Test
- public void testStartStopRow() throws Exception {
- testStartStopRow(UTIL1.getConfiguration());
+ public void testStartStopRow(TestInfo testInfo) throws Exception {
+ testStartStopRow(UTIL1.getConfiguration(), testInfo);
}
/**
* Test copy of table from sourceTable to targetTable all rows from family a
*/
@Test
- public void testRenameFamily() throws Exception {
- testRenameFamily(UTIL1.getConfiguration());
+ public void testRenameFamily(TestInfo testInfo) throws Exception {
+ testRenameFamily(UTIL1.getConfiguration(), testInfo);
}
@Test
- public void testBulkLoadNotSupported() throws Exception {
- TableName tableName1 = TableName.valueOf(name.getMethodName() + "1");
- TableName tableName2 = TableName.valueOf(name.getMethodName() + "2");
+ public void testBulkLoadNotSupported(TestInfo testInfo) throws Exception {
+ TableName tableName1 = TableName.valueOf(testInfo.getTestMethod().get().getName() + "1");
+ TableName tableName2 = TableName.valueOf(testInfo.getTestMethod().get().getName() + "2");
try (Table t1 = UTIL1.createTable(tableName1, FAMILY_A);
Table t2 = UTIL2.createTable(tableName2, FAMILY_A)) {
assertFalse(runCopy(UTIL1.getConfiguration(),
@@ -128,9 +124,9 @@ public void testBulkLoadNotSupported() throws Exception {
}
@Test
- public void testSnapshotNotSupported() throws Exception {
- TableName tableName1 = TableName.valueOf(name.getMethodName() + "1");
- TableName tableName2 = TableName.valueOf(name.getMethodName() + "2");
+ public void testSnapshotNotSupported(TestInfo testInfo) throws Exception {
+ TableName tableName1 = TableName.valueOf(testInfo.getTestMethod().get().getName() + "1");
+ TableName tableName2 = TableName.valueOf(testInfo.getTestMethod().get().getName() + "2");
String snapshot = tableName1.getNameAsString() + "_snapshot";
try (Table t1 = UTIL1.createTable(tableName1, FAMILY_A);
Table t2 = UTIL2.createTable(tableName2, FAMILY_A)) {
@@ -143,6 +139,5 @@ public void testSnapshotNotSupported() throws Exception {
UTIL1.deleteTable(tableName1);
UTIL2.deleteTable(tableName2);
}
-
}
}
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestGroupingTableMapper.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestGroupingTableMapper.java
index 34d197be02fa..a850681e7997 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestGroupingTableMapper.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestGroupingTableMapper.java
@@ -23,7 +23,6 @@
import java.util.List;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.Cell;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
@@ -31,17 +30,13 @@
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.mapreduce.Mapper;
-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;
-@Category({ MapReduceTests.class, SmallTests.class })
+@Tag(MapReduceTests.TAG)
+@Tag(SmallTests.TAG)
public class TestGroupingTableMapper {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestGroupingTableMapper.class);
-
/**
* Test GroupingTableMapper class
*/
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestHBaseMRTestingUtility.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestHBaseMRTestingUtility.java
index 04dddfb8fa33..d5bd4732cace 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestHBaseMRTestingUtility.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestHBaseMRTestingUtility.java
@@ -17,25 +17,21 @@
*/
package org.apache.hadoop.hbase.mapreduce;
-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 java.io.IOException;
import java.util.HashMap;
import java.util.Map;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.testclassification.LargeTests;
import org.apache.hadoop.hbase.testclassification.MapReduceTests;
-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;
-@Category({ MapReduceTests.class, LargeTests.class })
+@Tag(MapReduceTests.TAG)
+@Tag(LargeTests.TAG)
public class TestHBaseMRTestingUtility {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestHBaseMRTestingUtility.class);
@Test
public void testMRYarnConfigsPopulation() throws IOException {
@@ -55,20 +51,18 @@ public void testMRYarnConfigsPopulation() throws IOException {
}
for (Map.Entry entry : dummyProps.entrySet()) {
- assertTrue(
+ assertTrue(hbt.getConfiguration().get(entry.getKey()).equals(entry.getValue()),
"The Configuration for key " + entry.getKey() + " and value: " + entry.getValue()
- + " is not populated correctly",
- hbt.getConfiguration().get(entry.getKey()).equals(entry.getValue()));
+ + " is not populated correctly");
}
hbt.startMiniMapReduceCluster();
// Confirm that MiniMapReduceCluster overwrites the mr properties and updates the Configuration
for (Map.Entry entry : dummyProps.entrySet()) {
- assertFalse(
+ assertFalse(hbt.getConfiguration().get(entry.getKey()).equals(entry.getValue()),
"The MR prop: " + entry.getValue() + " is not overwritten when map reduce mini"
- + "cluster is started",
- hbt.getConfiguration().get(entry.getKey()).equals(entry.getValue()));
+ + "cluster is started");
}
hbt.shutdownMiniMapReduceCluster();
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestHFileOutputFormat2.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestHFileOutputFormat2.java
index 40c03492f6d6..bfa2c36c864e 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestHFileOutputFormat2.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestHFileOutputFormat2.java
@@ -19,12 +19,12 @@
import static org.apache.hadoop.hbase.client.ConnectionFactory.createConnection;
import static org.apache.hadoop.hbase.regionserver.HStoreFile.BLOOM_FILTER_TYPE_KEY;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNotSame;
-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.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import java.io.IOException;
import java.lang.reflect.Field;
@@ -52,7 +52,6 @@
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.CompatibilitySingletonFactory;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HColumnDescriptor;
@@ -116,10 +115,8 @@
import org.apache.hadoop.mapreduce.TaskAttemptContext;
import org.apache.hadoop.mapreduce.lib.output.FileOutputCommitter;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
-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.Test;
import org.mockito.Mockito;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -129,14 +126,10 @@
* output. Creates a few inner classes to implement splits and an inputformat that emits keys and
* values like those of {@link PerformanceEvaluation}.
*/
-@Category({ VerySlowMapReduceTests.class, LargeTests.class })
-// TODO : Remove this in 3.0
+@org.junit.jupiter.api.Tag(VerySlowMapReduceTests.TAG)
+@org.junit.jupiter.api.Tag(LargeTests.TAG)
public class TestHFileOutputFormat2 {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestHFileOutputFormat2.class);
-
private final static int ROWSPERSPLIT = 1024;
public static final byte[] FAMILY_NAME = TestHRegionFileSystem.FAMILY_NAME;
@@ -300,7 +293,7 @@ private void setupRandomGeneratorMapper(Job job, boolean putSortReducer) {
* timestamp is {@link HConstants#LATEST_TIMESTAMP}.
* @see HBASE-2615
*/
- @Ignore("Goes zombie too frequently; needs work. See HBASE-14563")
+ @Disabled("Goes zombie too frequently; needs work. See HBASE-14563")
@Test
public void test_LATEST_TIMESTAMP_isReplaced() throws Exception {
Configuration conf = new Configuration(this.util.getConfiguration());
@@ -350,7 +343,7 @@ private TaskAttemptContext createTestTaskAttemptContext(final Job job) throws Ex
* Test that {@link HFileOutputFormat2} creates an HFile with TIMERANGE metadata used by
* time-restricted scans.
*/
- @Ignore("Goes zombie too frequently; needs work. See HBASE-14563")
+ @Disabled("Goes zombie too frequently; needs work. See HBASE-14563")
@Test
public void test_TIMERANGE() throws Exception {
Configuration conf = new Configuration(this.util.getConfiguration());
@@ -414,7 +407,7 @@ public void test_TIMERANGE() throws Exception {
/**
* Run small MR job.
*/
- @Ignore("Goes zombie too frequently; needs work. See HBASE-14563")
+ @Disabled("Goes zombie too frequently; needs work. See HBASE-14563")
@Test
public void testWritingPEData() throws Exception {
Configuration conf = util.getConfiguration();
@@ -467,10 +460,10 @@ public void testWritingPEData() throws Exception {
kvCount += reader.getEntries();
scanner.seekTo();
long perKVSize = scanner.getCell().getSerializedSize();
- assertTrue("Data size of each file should not be too large.",
- perKVSize * reader.getEntries() <= hregionMaxFilesize);
+ assertTrue(perKVSize * reader.getEntries() <= hregionMaxFilesize,
+ "Data size of each file should not be too large.");
}
- assertEquals("Should write expected data in output file.", ROWSPERSPLIT, kvCount);
+ assertEquals(ROWSPERSPLIT, kvCount, "Should write expected data in output file.");
}
}
@@ -523,7 +516,7 @@ public void test_WritingTagData() throws Exception {
}
}
- @Ignore("Goes zombie too frequently; needs work. See HBASE-14563")
+ @Disabled("Goes zombie too frequently; needs work. See HBASE-14563")
@Test
public void testJobConfiguration() throws Exception {
Configuration conf = new Configuration(this.util.getConfiguration());
@@ -536,7 +529,7 @@ public void testJobConfiguration() throws Exception {
setupMockStartKeys(regionLocator);
setupMockTableName(regionLocator);
HFileOutputFormat2.configureIncrementalLoad(job, table.getTableDescriptor(), regionLocator);
- assertEquals(job.getNumReduceTasks(), 4);
+ assertEquals(4, job.getNumReduceTasks());
}
private byte[][] generateRandomStartKeys(int numKeys) {
@@ -557,14 +550,14 @@ private byte[][] generateRandomSplitKeys(int numKeys) {
return ret;
}
- @Ignore("Goes zombie too frequently; needs work. See HBASE-14563")
+ @Disabled("Goes zombie too frequently; needs work. See HBASE-14563")
@Test
public void testMRIncrementalLoad() throws Exception {
LOG.info("\nStarting test testMRIncrementalLoad\n");
doIncrementalLoadTest(false, false, false, "testMRIncrementalLoad");
}
- @Ignore("Goes zombie too frequently; needs work. See HBASE-14563")
+ @Disabled("Goes zombie too frequently; needs work. See HBASE-14563")
@Test
public void testMRIncrementalLoadWithSplit() throws Exception {
LOG.info("\nStarting test testMRIncrementalLoadWithSplit\n");
@@ -579,7 +572,7 @@ public void testMRIncrementalLoadWithSplit() throws Exception {
* supports explicit hostnames parameter (just like MiniDFSCluster does), we could test region
* locality features more easily.
*/
- @Ignore("Goes zombie too frequently; needs work. See HBASE-14563")
+ @Disabled("Goes zombie too frequently; needs work. See HBASE-14563")
@Test
public void testMRIncrementalLoadWithLocality() throws Exception {
LOG.info("\nStarting test testMRIncrementalLoadWithLocality\n");
@@ -638,9 +631,9 @@ private void doIncrementalLoadTest(boolean shouldChangeRegions, boolean shouldKe
Table table = util.createTable(tableName, FAMILIES, splitKeys);
RegionLocator r = util.getConnection().getRegionLocator(tableName);
- assertEquals("Should start with empty table", 0, util.countRows(table));
+ assertEquals(0, util.countRows(table), "Should start with empty table");
int numRegions = r.getStartKeys().length;
- assertEquals("Should make " + regionNum + " regions", numRegions, regionNum);
+ assertEquals(numRegions, regionNum, "Should make " + regionNum + " regions");
allTables.put(tableStrSingle, table);
tableInfo.add(new HFileOutputFormat2.TableInfo(table.getTableDescriptor(), r));
@@ -651,7 +644,7 @@ private void doIncrementalLoadTest(boolean shouldChangeRegions, boolean shouldKe
for (Table tableSingle : allTables.values()) {
// This doesn't write into the table, just makes files
- assertEquals("HFOF should not touch actual table", 0, util.countRows(tableSingle));
+ assertEquals(0, util.countRows(tableSingle), "HFOF should not touch actual table");
}
int numTableDirs = 0;
for (FileStatus tf : testDir.getFileSystem(conf).listStatus(testDir)) {
@@ -675,10 +668,10 @@ private void doIncrementalLoadTest(boolean shouldChangeRegions, boolean shouldKe
}
}
}
- assertEquals("Column family not found in FS.", FAMILIES.length, dir);
+ assertEquals(FAMILIES.length, dir, "Column family not found in FS.");
}
if (writeMultipleTables) {
- assertEquals("Dir for all input tables not created", numTableDirs, allTables.size());
+ assertEquals(numTableDirs, allTables.size(), "Dir for all input tables not created");
}
Admin admin = util.getConnection().getAdmin();
@@ -721,12 +714,12 @@ private void doIncrementalLoadTest(boolean shouldChangeRegions, boolean shouldKe
int expectedRows = 0;
if (putSortReducer) {
// no rows should be extracted
- assertEquals("LoadIncrementalHFiles should put expected data in table", expectedRows,
- util.countRows(currentTable));
+ assertEquals(expectedRows, util.countRows(currentTable),
+ "LoadIncrementalHFiles should put expected data in table");
} else {
expectedRows = NMapInputFormat.getNumMapTasks(conf) * ROWSPERSPLIT;
- assertEquals("LoadIncrementalHFiles should put expected data in table", expectedRows,
- util.countRows(currentTable));
+ assertEquals(expectedRows, util.countRows(currentTable),
+ "LoadIncrementalHFiles should put expected data in table");
Scan scan = new Scan();
ResultScanner results = currentTable.getScanner(scan);
for (Result res : results) {
@@ -759,8 +752,8 @@ private void doIncrementalLoadTest(boolean shouldChangeRegions, boolean shouldKe
}
admin.enableTable(currentTableName);
util.waitTableAvailable(currentTableName);
- assertEquals("Data should remain after reopening of regions", tableDigestBefore,
- util.checksumRows(currentTable));
+ assertEquals(tableDigestBefore, util.checksumRows(currentTable),
+ "Data should remain after reopening of regions");
}
} finally {
for (HFileOutputFormat2.TableInfo tableInfoSingle : tableInfo) {
@@ -809,7 +802,7 @@ private void runIncrementalPELoad(Configuration conf,
* Test for {@link HFileOutputFormat2#createFamilyCompressionMap(Configuration)}. Tests that the
* family compression map is correctly serialized into and deserialized from configuration
*/
- @Ignore("Goes zombie too frequently; needs work. See HBASE-14563")
+ @Disabled("Goes zombie too frequently; needs work. See HBASE-14563")
@Test
public void testSerializeDeserializeFamilyCompressionMap() throws IOException {
for (int numCfs = 0; numCfs <= 3; numCfs++) {
@@ -829,8 +822,9 @@ public void testSerializeDeserializeFamilyCompressionMap() throws IOException {
// test that we have a value for all column families that matches with the
// used mock values
for (Entry entry : familyToCompression.entrySet()) {
- assertEquals("Compression configuration incorrect for column family:" + entry.getKey(),
- entry.getValue(), retrievedFamilyToCompressionMap.get(entry.getKey().getBytes("UTF-8")));
+ assertEquals(entry.getValue(),
+ retrievedFamilyToCompressionMap.get(Bytes.toBytes(entry.getKey())),
+ "Compression configuration incorrect for column family:" + entry.getKey());
}
}
}
@@ -871,7 +865,7 @@ private Map getMockColumnFamiliesForCompression(i
* Test for {@link HFileOutputFormat2#createFamilyBloomTypeMap(Configuration)}. Tests that the
* family bloom type map is correctly serialized into and deserialized from configuration
*/
- @Ignore("Goes zombie too frequently; needs work. See HBASE-14563")
+ @Disabled("Goes zombie too frequently; needs work. See HBASE-14563")
@Test
public void testSerializeDeserializeFamilyBloomTypeMap() throws IOException {
for (int numCfs = 0; numCfs <= 2; numCfs++) {
@@ -891,8 +885,9 @@ public void testSerializeDeserializeFamilyBloomTypeMap() throws IOException {
// test that we have a value for all column families that matches with the
// used mock values
for (Entry entry : familyToBloomType.entrySet()) {
- assertEquals("BloomType configuration incorrect for column family:" + entry.getKey(),
- entry.getValue(), retrievedFamilyToBloomTypeMap.get(entry.getKey().getBytes("UTF-8")));
+ assertEquals(entry.getValue(),
+ retrievedFamilyToBloomTypeMap.get(Bytes.toBytes(entry.getKey())),
+ "BloomType configuration incorrect for column family:" + entry.getKey());
}
}
}
@@ -930,7 +925,7 @@ private Map getMockColumnFamiliesForBloomType(int numCfs) {
* Test for {@link HFileOutputFormat2#createFamilyBlockSizeMap(Configuration)}. Tests that the
* family block size map is correctly serialized into and deserialized from configuration
*/
- @Ignore("Goes zombie too frequently; needs work. See HBASE-14563")
+ @Disabled("Goes zombie too frequently; needs work. See HBASE-14563")
@Test
public void testSerializeDeserializeFamilyBlockSizeMap() throws IOException {
for (int numCfs = 0; numCfs <= 3; numCfs++) {
@@ -950,8 +945,9 @@ public void testSerializeDeserializeFamilyBlockSizeMap() throws IOException {
// test that we have a value for all column families that matches with the
// used mock values
for (Entry entry : familyToBlockSize.entrySet()) {
- assertEquals("BlockSize configuration incorrect for column family:" + entry.getKey(),
- entry.getValue(), retrievedFamilyToBlockSizeMap.get(entry.getKey().getBytes("UTF-8")));
+ assertEquals(entry.getValue(),
+ retrievedFamilyToBlockSizeMap.get(entry.getKey().getBytes("UTF-8")),
+ "BlockSize configuration incorrect for column family:" + entry.getKey());
}
}
}
@@ -993,7 +989,7 @@ private Map getMockColumnFamiliesForBlockSize(int numCfs) {
* the family data block encoding map is correctly serialized into and deserialized from
* configuration
*/
- @Ignore("Goes zombie too frequently; needs work. See HBASE-14563")
+ @Disabled("Goes zombie too frequently; needs work. See HBASE-14563")
@Test
public void testSerializeDeserializeFamilyDataBlockEncodingMap() throws IOException {
for (int numCfs = 0; numCfs <= 3; numCfs++) {
@@ -1015,10 +1011,9 @@ public void testSerializeDeserializeFamilyDataBlockEncodingMap() throws IOExcept
// test that we have a value for all column families that matches with the
// used mock values
for (Entry entry : familyToDataBlockEncoding.entrySet()) {
- assertEquals(
- "DataBlockEncoding configuration incorrect for column family:" + entry.getKey(),
- entry.getValue(),
- retrievedFamilyToDataBlockEncodingMap.get(entry.getKey().getBytes("UTF-8")));
+ assertEquals(entry.getValue(),
+ retrievedFamilyToDataBlockEncodingMap.get(Bytes.toBytes(entry.getKey())),
+ "DataBlockEncoding configuration incorrect for column family:" + entry.getKey());
}
}
}
@@ -1070,7 +1065,7 @@ private void setupMockTableName(RegionLocator table) throws IOException {
* Test that {@link HFileOutputFormat2} RecordWriter uses compression and bloom filter settings
* from the column family descriptor
*/
- @Ignore("Goes zombie too frequently; needs work. See HBASE-14563")
+ @Disabled("Goes zombie too frequently; needs work. See HBASE-14563")
@Test
public void testColumnFamilySettings() throws Exception {
Configuration conf = new Configuration(this.util.getConfiguration());
@@ -1131,12 +1126,11 @@ public void testColumnFamilySettings() throws Exception {
byte[] bloomFilter = fileInfo.get(BLOOM_FILTER_TYPE_KEY);
if (bloomFilter == null) bloomFilter = Bytes.toBytes("NONE");
- assertEquals(
- "Incorrect bloom filter used for column family " + familyStr + "(reader: " + reader + ")",
- hcd.getBloomFilterType(), BloomType.valueOf(Bytes.toString(bloomFilter)));
- assertEquals(
- "Incorrect compression used for column family " + familyStr + "(reader: " + reader + ")",
- hcd.getCompressionType(), reader.getFileContext().getCompression());
+ assertEquals(hcd.getBloomFilterType(), BloomType.valueOf(Bytes.toString(bloomFilter)),
+ "Incorrect bloom filter used for column family " + familyStr + "(reader: " + reader
+ + ")");
+ assertEquals(hcd.getCompressionType(), reader.getFileContext().getCompression(),
+ "Incorrect compression used for column family " + familyStr + "(reader: " + reader + ")");
}
} finally {
dir.getFileSystem(conf).delete(dir, true);
@@ -1173,7 +1167,7 @@ private void writeRandomKeyValues(RecordWriter wri
* excluded from minor compaction. Without the fix of HBASE-6901, an
* ArrayIndexOutOfBoundsException will be thrown.
*/
- @Ignore("Flakey: See HBASE-9051")
+ @Disabled("Flakey: See HBASE-9051")
@Test
public void testExcludeAllFromMinorCompaction() throws Exception {
Configuration conf = util.getConfiguration();
@@ -1185,7 +1179,7 @@ public void testExcludeAllFromMinorCompaction() throws Exception {
Table table = util.createTable(TABLE_NAMES[0], FAMILIES);
RegionLocator locator = conn.getRegionLocator(TABLE_NAMES[0])) {
final FileSystem fs = util.getDFSCluster().getFileSystem();
- assertEquals("Should start with empty table", 0, util.countRows(table));
+ assertEquals(0, util.countRows(table), "Should start with empty table");
// deep inspection: get the StoreFile dir
final Path storePath =
@@ -1209,8 +1203,8 @@ public void testExcludeAllFromMinorCompaction() throws Exception {
// Ensure data shows up
int expectedRows = 2 * NMapInputFormat.getNumMapTasks(conf) * ROWSPERSPLIT;
- assertEquals("LoadIncrementalHFiles should put expected data in table", expectedRows,
- util.countRows(table));
+ assertEquals(expectedRows, util.countRows(table),
+ "BulkLoadHFiles should put expected data in table");
// should have a second StoreFile now
assertEquals(2, fs.listStatus(storePath).length);
@@ -1255,7 +1249,7 @@ public Boolean call() throws Exception {
}
}
- @Ignore("Goes zombie too frequently; needs work. See HBASE-14563")
+ @Disabled("Goes zombie too frequently; needs work. See HBASE-14563")
@Test
public void testExcludeMinorCompaction() throws Exception {
Configuration conf = util.getConfiguration();
@@ -1268,7 +1262,7 @@ public void testExcludeMinorCompaction() throws Exception {
Path testDir = util.getDataTestDirOnTestFS("testExcludeMinorCompaction");
final FileSystem fs = util.getDFSCluster().getFileSystem();
Table table = util.createTable(TABLE_NAMES[0], FAMILIES);
- assertEquals("Should start with empty table", 0, util.countRows(table));
+ assertEquals(0, util.countRows(table), "Should start with empty table");
// deep inspection: get the StoreFile dir
final Path storePath =
@@ -1303,8 +1297,8 @@ public Boolean call() throws Exception {
// Ensure data shows up
int expectedRows = NMapInputFormat.getNumMapTasks(conf) * ROWSPERSPLIT;
- assertEquals("LoadIncrementalHFiles should put expected data in table", expectedRows + 1,
- util.countRows(table));
+ assertEquals(expectedRows + 1, util.countRows(table),
+ "LoadIncrementalHFiles should put expected data in table");
// should have a second StoreFile now
assertEquals(2, fs.listStatus(storePath).length);
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestHFileOutputFormat2WithSecurity.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestHFileOutputFormat2WithSecurity.java
index b4cb6a8355fc..06c362ce2a7f 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestHFileOutputFormat2WithSecurity.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestHFileOutputFormat2WithSecurity.java
@@ -18,8 +18,8 @@
package org.apache.hadoop.hbase.mapreduce;
import static org.apache.hadoop.security.UserGroupInformation.loginUserFromKeytab;
-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.Closeable;
import java.io.File;
@@ -27,7 +27,6 @@
import java.util.List;
import org.apache.commons.io.IOUtils;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.TableName;
@@ -41,20 +40,17 @@
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.minikdc.MiniKdc;
import org.apache.hadoop.security.UserGroupInformation;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
/**
* Tests for {@link HFileOutputFormat2} with secure mode.
*/
-@Category({ VerySlowMapReduceTests.class, LargeTests.class })
+@Tag(VerySlowMapReduceTests.TAG)
+@Tag(LargeTests.TAG)
public class TestHFileOutputFormat2WithSecurity {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestHFileOutputFormat2WithSecurity.class);
private static final byte[] FAMILIES = Bytes.toBytes("test_cf");
@@ -70,7 +66,7 @@ public class TestHFileOutputFormat2WithSecurity {
private List clusters = new ArrayList<>();
- @Before
+ @BeforeEach
public void setupSecurityClusters() throws Exception {
utilA = new HBaseTestingUtility();
confA = utilA.getConfiguration();
@@ -92,7 +88,7 @@ public void setupSecurityClusters() throws Exception {
clusters.add(utilB.startSecureMiniCluster(kdc, userPrincipal, HTTP_PRINCIPAL));
}
- @After
+ @AfterEach
public void teardownSecurityClusters() {
IOUtils.closeQuietly(clusters);
clusters.clear();
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestHRegionPartitioner.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestHRegionPartitioner.java
index 3408ae43034b..d600418ff0f6 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestHRegionPartitioner.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestHRegionPartitioner.java
@@ -17,42 +17,33 @@
*/
package org.apache.hadoop.hbase.mapreduce;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
import org.apache.hadoop.hbase.testclassification.MapReduceTests;
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.util.Bytes;
-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;
-
-@Category({ MapReduceTests.class, MediumTests.class })
+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;
+
+@Tag(MapReduceTests.TAG)
+@Tag(MediumTests.TAG)
public class TestHRegionPartitioner {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestHRegionPartitioner.class);
-
private static final HBaseTestingUtility UTIL = new HBaseTestingUtility();
- @Rule
- public TestName name = new TestName();
-
- @BeforeClass
+ @BeforeAll
public static void beforeClass() throws Exception {
UTIL.startMiniCluster();
}
- @AfterClass
+ @AfterAll
public static void afterClass() throws Exception {
UTIL.shutdownMiniCluster();
}
@@ -61,16 +52,17 @@ public static void afterClass() throws Exception {
* Test HRegionPartitioner
*/
@Test
- public void testHRegionPartitioner() throws Exception {
+ public void testHRegionPartitioner(TestInfo testInfo) throws Exception {
byte[][] families = { Bytes.toBytes("familyA"), Bytes.toBytes("familyB") };
- UTIL.createTable(TableName.valueOf(name.getMethodName()), families, 1, Bytes.toBytes("aa"),
+ String tableName = testInfo.getTestMethod().get().getName();
+ UTIL.createTable(TableName.valueOf(tableName), families, 1, Bytes.toBytes("aa"),
Bytes.toBytes("cc"), 3);
HRegionPartitioner partitioner = new HRegionPartitioner<>();
Configuration configuration = UTIL.getConfiguration();
- configuration.set(TableOutputFormat.OUTPUT_TABLE, name.getMethodName());
+ configuration.set(TableOutputFormat.OUTPUT_TABLE, tableName);
partitioner.setConf(configuration);
ImmutableBytesWritable writable = new ImmutableBytesWritable(Bytes.toBytes("bb"));
@@ -79,10 +71,11 @@ public void testHRegionPartitioner() throws Exception {
}
@Test
- public void testHRegionPartitionerMoreRegions() throws Exception {
+ public void testHRegionPartitionerMoreRegions(TestInfo testInfo) throws Exception {
byte[][] families = { Bytes.toBytes("familyA"), Bytes.toBytes("familyB") };
- TableName tableName = TableName.valueOf(name.getMethodName());
+ String tableNameStr = testInfo.getTestMethod().get().getName();
+ TableName tableName = TableName.valueOf(tableNameStr);
UTIL.createTable(tableName, families, 1, Bytes.toBytes("aa"), Bytes.toBytes("cc"), 5);
Configuration configuration = UTIL.getConfiguration();
@@ -90,7 +83,7 @@ public void testHRegionPartitionerMoreRegions() throws Exception {
assertEquals(5, numberOfRegions);
HRegionPartitioner partitioner = new HRegionPartitioner<>();
- configuration.set(TableOutputFormat.OUTPUT_TABLE, name.getMethodName());
+ configuration.set(TableOutputFormat.OUTPUT_TABLE, tableNameStr);
partitioner.setConf(configuration);
// Get some rowKey for the lastRegion
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestHashTable.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestHashTable.java
index da48b0028b71..395cb05caf7d 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestHashTable.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestHashTable.java
@@ -17,14 +17,14 @@
*/
package org.apache.hadoop.hbase.mapreduce;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
import java.util.HashMap;
import java.util.Map;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Put;
@@ -33,14 +33,11 @@
import org.apache.hadoop.hbase.testclassification.LargeTests;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.io.MapFile;
-import org.junit.AfterClass;
-import org.junit.Assert;
-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.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -50,32 +47,26 @@
/**
* Basic test for the HashTable M/R tool
*/
-@Category(LargeTests.class)
+@Tag(LargeTests.TAG)
public class TestHashTable {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestHashTable.class);
private static final Logger LOG = LoggerFactory.getLogger(TestHashTable.class);
private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
- @Rule
- public TestName name = new TestName();
-
- @BeforeClass
+ @BeforeAll
public static void beforeClass() throws Exception {
TEST_UTIL.startMiniCluster(3);
}
- @AfterClass
+ @AfterAll
public static void afterClass() throws Exception {
TEST_UTIL.shutdownMiniCluster();
}
@Test
- public void testHashTable() throws Exception {
- final TableName tableName = TableName.valueOf(name.getMethodName());
+ public void testHashTable(TestInfo testInfo) throws Exception {
+ final TableName tableName = TableName.valueOf(testInfo.getTestMethod().get().getName());
final byte[] family = Bytes.toBytes("family");
final byte[] column1 = Bytes.toBytes("c1");
final byte[] column2 = Bytes.toBytes("c2");
@@ -110,7 +101,7 @@ public void testHashTable() throws Exception {
int code =
hashTable.run(new String[] { "--batchsize=" + batchSize, "--numhashfiles=" + numHashFiles,
"--scanbatch=2", tableName.getNameAsString(), testDir.toString() });
- assertEquals("test job failed", 0, code);
+ assertEquals(0, code, "test job failed");
FileSystem fs = TEST_UTIL.getTestFileSystem();
@@ -165,7 +156,7 @@ ImmutableMap. builder()
intKey = Bytes.toInt(key.get(), key.getOffset(), key.getLength());
}
if (actualHashes.containsKey(intKey)) {
- Assert.fail("duplicate key in data files: " + intKey);
+ fail("duplicate key in data files: " + intKey);
}
actualHashes.put(intKey, new ImmutableBytesWritable(hash.copyBytes()));
}
@@ -185,7 +176,7 @@ ImmutableMap. builder()
if (!expectedHashes.equals(actualHashes)) {
LOG.error("Diff: " + Maps.difference(expectedHashes, actualHashes));
}
- Assert.assertEquals(expectedHashes, actualHashes);
+ assertEquals(expectedHashes, actualHashes);
TEST_UTIL.deleteTable(tableName);
TEST_UTIL.cleanupDataTestDirOnTestFS();
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestImportTSVWithOperationAttributes.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestImportTSVWithOperationAttributes.java
index 936cf90372b5..e7bc36740f14 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestImportTSVWithOperationAttributes.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestImportTSVWithOperationAttributes.java
@@ -17,8 +17,8 @@
*/
package org.apache.hadoop.hbase.mapreduce;
-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.IOException;
import java.util.ArrayList;
@@ -32,7 +32,6 @@
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellUtil;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.TableName;
@@ -55,23 +54,18 @@
import org.apache.hadoop.hbase.wal.WALEdit;
import org.apache.hadoop.util.Tool;
import org.apache.hadoop.util.ToolRunner;
-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.slf4j.Logger;
import org.slf4j.LoggerFactory;
-@Category({ MapReduceTests.class, LargeTests.class })
+@Tag(MapReduceTests.TAG)
+@Tag(LargeTests.TAG)
public class TestImportTSVWithOperationAttributes implements Configurable {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestImportTSVWithOperationAttributes.class);
-
private static final Logger LOG =
LoggerFactory.getLogger(TestImportTSVWithOperationAttributes.class);
protected static final String NAME = TestImportTsv.class.getSimpleName();
@@ -93,9 +87,6 @@ public class TestImportTSVWithOperationAttributes implements Configurable {
private final String FAMILY = "FAM";
- @Rule
- public TestName name = new TestName();
-
@Override
public Configuration getConf() {
return util.getConfiguration();
@@ -106,7 +97,7 @@ public void setConf(Configuration conf) {
throw new IllegalArgumentException("setConf not supported");
}
- @BeforeClass
+ @BeforeAll
public static void provisionCluster() throws Exception {
conf = util.getConfiguration();
conf.set("hbase.coprocessor.master.classes", OperationAttributesTestController.class.getName());
@@ -114,14 +105,15 @@ public static void provisionCluster() throws Exception {
util.startMiniCluster();
}
- @AfterClass
+ @AfterAll
public static void releaseCluster() throws Exception {
util.shutdownMiniCluster();
}
@Test
- public void testMROnTable() throws Exception {
- final TableName tableName = TableName.valueOf(name.getMethodName() + util.getRandomUUID());
+ public void testMROnTable(TestInfo testInfo) throws Exception {
+ final TableName tableName =
+ TableName.valueOf(testInfo.getTestMethod().get().getName() + util.getRandomUUID());
// Prepare the arguments required for the test.
String[] args = new String[] {
@@ -136,8 +128,9 @@ public void testMROnTable() throws Exception {
}
@Test
- public void testMROnTableWithInvalidOperationAttr() throws Exception {
- final TableName tableName = TableName.valueOf(name.getMethodName() + util.getRandomUUID());
+ public void testMROnTableWithInvalidOperationAttr(TestInfo testInfo) throws Exception {
+ final TableName tableName =
+ TableName.valueOf(testInfo.getTestMethod().get().getName() + util.getRandomUUID());
// Prepare the arguments required for the test.
String[] args = new String[] {
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestImportTSVWithTTLs.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestImportTSVWithTTLs.java
index 4d6ffd8cca04..be38bbe90a76 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestImportTSVWithTTLs.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestImportTSVWithTTLs.java
@@ -17,7 +17,7 @@
*/
package org.apache.hadoop.hbase.mapreduce;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.IOException;
import java.util.ArrayList;
@@ -29,7 +29,6 @@
import org.apache.hadoop.fs.FSDataOutputStream;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Durability;
@@ -45,23 +44,18 @@
import org.apache.hadoop.hbase.wal.WALEdit;
import org.apache.hadoop.util.Tool;
import org.apache.hadoop.util.ToolRunner;
-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.slf4j.Logger;
import org.slf4j.LoggerFactory;
-@Category({ MapReduceTests.class, LargeTests.class })
+@Tag(MapReduceTests.TAG)
+@Tag(LargeTests.TAG)
public class TestImportTSVWithTTLs implements Configurable {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestImportTSVWithTTLs.class);
-
protected static final Logger LOG = LoggerFactory.getLogger(TestImportTSVWithTTLs.class);
protected static final String NAME = TestImportTsv.class.getSimpleName();
protected static HBaseTestingUtility util = new HBaseTestingUtility();
@@ -79,9 +73,6 @@ public class TestImportTSVWithTTLs implements Configurable {
private final String FAMILY = "FAM";
private static Configuration conf;
- @Rule
- public TestName name = new TestName();
-
@Override
public Configuration getConf() {
return util.getConfiguration();
@@ -92,7 +83,7 @@ public void setConf(Configuration conf) {
throw new IllegalArgumentException("setConf not supported");
}
- @BeforeClass
+ @BeforeAll
public static void provisionCluster() throws Exception {
conf = util.getConfiguration();
// We don't check persistence in HFiles in this test, but if we ever do we will
@@ -102,14 +93,15 @@ public static void provisionCluster() throws Exception {
util.startMiniCluster();
}
- @AfterClass
+ @AfterAll
public static void releaseCluster() throws Exception {
util.shutdownMiniCluster();
}
@Test
- public void testMROnTable() throws Exception {
- final TableName tableName = TableName.valueOf(name.getMethodName() + util.getRandomUUID());
+ public void testMROnTable(TestInfo testInfo) throws Exception {
+ final TableName tableName =
+ TableName.valueOf(testInfo.getTestMethod().get().getName() + util.getRandomUUID());
// Prepare the arguments required for the test.
String[] args = new String[] {
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestImportTSVWithVisibilityLabels.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestImportTSVWithVisibilityLabels.java
index 2009b5c4bca8..c471c53e44f2 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestImportTSVWithVisibilityLabels.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestImportTSVWithVisibilityLabels.java
@@ -17,8 +17,8 @@
*/
package org.apache.hadoop.hbase.mapreduce;
-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.IOException;
import java.security.PrivilegedExceptionAction;
@@ -35,7 +35,6 @@
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellUtil;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.TableName;
@@ -65,23 +64,18 @@
import org.apache.hadoop.mapred.Utils.OutputFileUtils.OutputFilesFilter;
import org.apache.hadoop.util.Tool;
import org.apache.hadoop.util.ToolRunner;
-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.slf4j.Logger;
import org.slf4j.LoggerFactory;
-@Category({ MapReduceTests.class, LargeTests.class })
+@Tag(MapReduceTests.TAG)
+@Tag(LargeTests.TAG)
public class TestImportTSVWithVisibilityLabels implements Configurable {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestImportTSVWithVisibilityLabels.class);
-
private static final Logger LOG =
LoggerFactory.getLogger(TestImportTSVWithVisibilityLabels.class);
protected static final String NAME = TestImportTsv.class.getSimpleName();
@@ -106,9 +100,6 @@ public class TestImportTSVWithVisibilityLabels implements Configurable {
private static User SUPERUSER;
private static Configuration conf;
- @Rule
- public TestName name = new TestName();
-
@Override
public Configuration getConf() {
return util.getConfiguration();
@@ -119,7 +110,7 @@ public void setConf(Configuration conf) {
throw new IllegalArgumentException("setConf not supported");
}
- @BeforeClass
+ @BeforeAll
public static void provisionCluster() throws Exception {
conf = util.getConfiguration();
SUPERUSER = User.createUserForTesting(conf, "admin", new String[] { "supergroup" });
@@ -152,14 +143,15 @@ public VisibilityLabelsResponse run() throws Exception {
SUPERUSER.runAs(action);
}
- @AfterClass
+ @AfterAll
public static void releaseCluster() throws Exception {
util.shutdownMiniCluster();
}
@Test
- public void testMROnTable() throws Exception {
- final TableName tableName = TableName.valueOf(name.getMethodName() + util.getRandomUUID());
+ public void testMROnTable(TestInfo testInfo) throws Exception {
+ final TableName tableName =
+ TableName.valueOf(testInfo.getTestMethod().get().getName() + util.getRandomUUID());
// Prepare the arguments required for the test.
String[] args = new String[] {
@@ -173,8 +165,9 @@ public void testMROnTable() throws Exception {
}
@Test
- public void testMROnTableWithDeletes() throws Exception {
- final TableName tableName = TableName.valueOf(name.getMethodName() + util.getRandomUUID());
+ public void testMROnTableWithDeletes(TestInfo testInfo) throws Exception {
+ final TableName tableName =
+ TableName.valueOf(testInfo.getTestMethod().get().getName() + util.getRandomUUID());
// Prepare the arguments required for the test.
String[] args = new String[] {
@@ -225,8 +218,9 @@ private void issueDeleteAndVerifyData(TableName tableName) throws IOException {
}
@Test
- public void testMROnTableWithBulkload() throws Exception {
- final TableName tableName = TableName.valueOf(name.getMethodName() + util.getRandomUUID());
+ public void testMROnTableWithBulkload(TestInfo testInfo) throws Exception {
+ final TableName tableName =
+ TableName.valueOf(testInfo.getTestMethod().get().getName() + util.getRandomUUID());
Path hfiles = new Path(util.getDataTestDirOnTestFS(tableName.getNameAsString()), "hfiles");
// Prepare the arguments required for the test.
String[] args = new String[] { "-D" + ImportTsv.BULK_OUTPUT_CONF_KEY + "=" + hfiles.toString(),
@@ -239,8 +233,9 @@ public void testMROnTableWithBulkload() throws Exception {
}
@Test
- public void testBulkOutputWithTsvImporterTextMapper() throws Exception {
- final TableName table = TableName.valueOf(name.getMethodName() + util.getRandomUUID());
+ public void testBulkOutputWithTsvImporterTextMapper(TestInfo testInfo) throws Exception {
+ final TableName table =
+ TableName.valueOf(testInfo.getTestMethod().get().getName() + util.getRandomUUID());
String FAMILY = "FAM";
Path bulkOutputPath = new Path(util.getDataTestDirOnTestFS(table.getNameAsString()), "hfiles");
// Prepare the arguments required for the test.
@@ -256,8 +251,9 @@ public void testBulkOutputWithTsvImporterTextMapper() throws Exception {
}
@Test
- public void testMRWithOutputFormat() throws Exception {
- final TableName tableName = TableName.valueOf(name.getMethodName() + util.getRandomUUID());
+ public void testMRWithOutputFormat(TestInfo testInfo) throws Exception {
+ final TableName tableName =
+ TableName.valueOf(testInfo.getTestMethod().get().getName() + util.getRandomUUID());
Path hfiles = new Path(util.getDataTestDirOnTestFS(tableName.getNameAsString()), "hfiles");
// Prepare the arguments required for the test.
String[] args = new String[] {
@@ -272,8 +268,9 @@ public void testMRWithOutputFormat() throws Exception {
}
@Test
- public void testBulkOutputWithInvalidLabels() throws Exception {
- final TableName tableName = TableName.valueOf(name.getMethodName() + util.getRandomUUID());
+ public void testBulkOutputWithInvalidLabels(TestInfo testInfo) throws Exception {
+ final TableName tableName =
+ TableName.valueOf(testInfo.getTestMethod().get().getName() + util.getRandomUUID());
Path hfiles = new Path(util.getDataTestDirOnTestFS(tableName.getNameAsString()), "hfiles");
// Prepare the arguments required for the test.
String[] args = new String[] { "-D" + ImportTsv.BULK_OUTPUT_CONF_KEY + "=" + hfiles.toString(),
@@ -289,8 +286,10 @@ public void testBulkOutputWithInvalidLabels() throws Exception {
}
@Test
- public void testBulkOutputWithTsvImporterTextMapperWithInvalidLabels() throws Exception {
- final TableName tableName = TableName.valueOf(name.getMethodName() + util.getRandomUUID());
+ public void testBulkOutputWithTsvImporterTextMapperWithInvalidLabels(TestInfo testInfo)
+ throws Exception {
+ final TableName tableName =
+ TableName.valueOf(testInfo.getTestMethod().get().getName() + util.getRandomUUID());
Path hfiles = new Path(util.getDataTestDirOnTestFS(tableName.getNameAsString()), "hfiles");
// Prepare the arguments required for the test.
String[] args = new String[] {
@@ -390,22 +389,22 @@ private static void validateHFiles(FileSystem fs, String outputPath, String fami
String[] elements = cfStatus.getPath().toString().split(Path.SEPARATOR);
String cf = elements[elements.length - 1];
foundFamilies.add(cf);
- assertTrue(String.format(
- "HFile ouput contains a column family (%s) not present in input families (%s)", cf,
- configFamilies), configFamilies.contains(cf));
+ assertTrue(configFamilies.contains(cf),
+ String.format(
+ "HFile ouput contains a column family (%s) not present in input families (%s)", cf,
+ configFamilies));
for (FileStatus hfile : fs.listStatus(cfStatus.getPath())) {
- assertTrue(String.format("HFile %s appears to contain no data.", hfile.getPath()),
- hfile.getLen() > 0);
+ assertTrue(hfile.getLen() > 0,
+ String.format("HFile %s appears to contain no data.", hfile.getPath()));
if (expectedKVCount > -1) {
actualKVCount += getKVCountFromHfile(fs, hfile.getPath());
}
}
}
if (expectedKVCount > -1) {
- assertTrue(
+ assertTrue(actualKVCount == expectedKVCount,
String.format("KV count in output hfile=<%d> doesn't match with expected KV count=<%d>",
- actualKVCount, expectedKVCount),
- actualKVCount == expectedKVCount);
+ actualKVCount, expectedKVCount));
}
}
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestImportTsv.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestImportTsv.java
index 8a30e404cff3..aa24195f53be 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestImportTsv.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestImportTsv.java
@@ -17,9 +17,10 @@
*/
package org.apache.hadoop.hbase.mapreduce;
-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.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
import java.util.Arrays;
@@ -37,7 +38,6 @@
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellUtil;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.TableName;
@@ -61,24 +61,18 @@
import org.apache.hadoop.mapreduce.lib.output.NullOutputFormat;
import org.apache.hadoop.util.Tool;
import org.apache.hadoop.util.ToolRunner;
-import org.junit.AfterClass;
-import org.junit.Before;
-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.ExpectedException;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-@Category({ VerySlowMapReduceTests.class, LargeTests.class })
+@Tag(VerySlowMapReduceTests.TAG)
+@Tag(LargeTests.TAG)
public class TestImportTsv implements Configurable {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestImportTsv.class);
-
private static final Logger LOG = LoggerFactory.getLogger(TestImportTsv.class);
protected static final String NAME = TestImportTsv.class.getSimpleName();
protected static HBaseTestingUtility util = new HBaseTestingUtility();
@@ -95,9 +89,6 @@ public class TestImportTsv implements Configurable {
private TableName tn;
private Map args;
- @Rule
- public ExpectedException exception = ExpectedException.none();
-
public Configuration getConf() {
return util.getConfiguration();
}
@@ -106,17 +97,17 @@ public void setConf(Configuration conf) {
throw new IllegalArgumentException("setConf not supported");
}
- @BeforeClass
+ @BeforeAll
public static void provisionCluster() throws Exception {
util.startMiniCluster();
}
- @AfterClass
+ @AfterAll
public static void releaseCluster() throws Exception {
util.shutdownMiniCluster();
}
- @Before
+ @BeforeEach
public void setup() throws Exception {
tn = TableName.valueOf("test-" + util.getRandomUUID());
args = new HashMap<>();
@@ -198,17 +189,16 @@ public void testJobConfigurationsWithTsvImporterTextMapper() throws Exception {
"-D" + ImportTsv.SEPARATOR_CONF_KEY + "=,",
"-D" + ImportTsv.BULK_OUTPUT_CONF_KEY + "=" + bulkOutputPath.toString(), tn.getNameAsString(),
INPUT_FILE };
- assertEquals("running test job configuration failed.", 0,
- ToolRunner.run(new Configuration(util.getConfiguration()), new ImportTsv() {
- @Override
- public int run(String[] args) throws Exception {
- Job job = createSubmittableJob(getConf(), args);
- assertTrue(job.getMapperClass().equals(TsvImporterTextMapper.class));
- assertTrue(job.getReducerClass().equals(TextSortReducer.class));
- assertTrue(job.getMapOutputValueClass().equals(Text.class));
- return 0;
- }
- }, args));
+ assertEquals(0, ToolRunner.run(new Configuration(util.getConfiguration()), new ImportTsv() {
+ @Override
+ public int run(String[] args) throws Exception {
+ Job job = createSubmittableJob(getConf(), args);
+ assertTrue(job.getMapperClass().equals(TsvImporterTextMapper.class));
+ assertTrue(job.getReducerClass().equals(TextSortReducer.class));
+ assertTrue(job.getMapOutputValueClass().equals(Text.class));
+ return 0;
+ }
+ }, args), "running test job configuration failed.");
// Delete table created by createSubmittableJob.
util.deleteTable(tn);
}
@@ -231,15 +221,15 @@ public void testWithoutAnExistingTableAndCreateTableSetToNo() throws Exception {
conf.set(ImportTsv.COLUMNS_CONF_KEY, "HBASE_ROW_KEY,FAM:A");
conf.set(ImportTsv.BULK_OUTPUT_CONF_KEY, "/output");
conf.set(ImportTsv.CREATE_TABLE_CONF_KEY, "no");
- exception.expect(TableNotFoundException.class);
- assertEquals("running test job configuration failed.", 0,
+ assertThrows(TableNotFoundException.class, () -> {
ToolRunner.run(new Configuration(util.getConfiguration()), new ImportTsv() {
@Override
public int run(String[] args) throws Exception {
createSubmittableJob(getConf(), args);
return 0;
}
- }, args));
+ }, args);
+ }, "running test job configuration failed.");
}
@Test
@@ -250,15 +240,15 @@ public void testMRNoMatchedColumnFamily() throws Exception {
"-D" + ImportTsv.COLUMNS_CONF_KEY
+ "=HBASE_ROW_KEY,FAM:A,FAM01_ERROR:A,FAM01_ERROR:B,FAM02_ERROR:C",
tn.getNameAsString(), "/inputFile" };
- exception.expect(NoSuchColumnFamilyException.class);
- assertEquals("running test job configuration failed.", 0,
+ assertThrows(NoSuchColumnFamilyException.class, () -> {
ToolRunner.run(new Configuration(util.getConfiguration()), new ImportTsv() {
@Override
public int run(String[] args) throws Exception {
createSubmittableJob(getConf(), args);
return 0;
}
- }, args));
+ }, args);
+ }, "running test job configuration failed.");
util.deleteTable(tn);
}
@@ -267,15 +257,15 @@ public int run(String[] args) throws Exception {
public void testMRWithoutAnExistingTable() throws Exception {
String[] args = new String[] { tn.getNameAsString(), "/inputFile" };
- exception.expect(TableNotFoundException.class);
- assertEquals("running test job configuration failed.", 0,
+ assertThrows(TableNotFoundException.class, () -> {
ToolRunner.run(new Configuration(util.getConfiguration()), new ImportTsv() {
@Override
public int run(String[] args) throws Exception {
createSubmittableJob(getConf(), args);
return 0;
}
- }, args));
+ }, args);
+ }, "running test job configuration failed.");
}
@Test
@@ -288,15 +278,14 @@ public void testJobConfigurationsWithDryMode() throws Exception {
"-D" + ImportTsv.SEPARATOR_CONF_KEY + "=,",
"-D" + ImportTsv.BULK_OUTPUT_CONF_KEY + "=" + bulkOutputPath.toString(),
"-D" + ImportTsv.DRY_RUN_CONF_KEY + "=true", tn.getNameAsString(), INPUT_FILE };
- assertEquals("running test job configuration failed.", 0,
- ToolRunner.run(new Configuration(util.getConfiguration()), new ImportTsv() {
- @Override
- public int run(String[] args) throws Exception {
- Job job = createSubmittableJob(getConf(), args);
- assertTrue(job.getOutputFormatClass().equals(NullOutputFormat.class));
- return 0;
- }
- }, argsArray));
+ assertEquals(0, ToolRunner.run(new Configuration(util.getConfiguration()), new ImportTsv() {
+ @Override
+ public int run(String[] args) throws Exception {
+ Job job = createSubmittableJob(getConf(), args);
+ assertTrue(job.getOutputFormatClass().equals(NullOutputFormat.class));
+ return 0;
+ }
+ }, argsArray), "running test job configuration failed.");
// Delete table created by createSubmittableJob.
util.deleteTable(tn);
}
@@ -317,8 +306,7 @@ public void testDryModeWithoutBulkOutputAndTableExists() throws Exception {
@Test
public void testDryModeWithoutBulkOutputAndTableDoesNotExists() throws Exception {
args.put(ImportTsv.DRY_RUN_CONF_KEY, "true");
- exception.expect(TableNotFoundException.class);
- doMROnTableTest(null, 1);
+ assertThrows(TableNotFoundException.class, () -> doMROnTableTest(null, 1));
}
@Test
@@ -345,8 +333,7 @@ public void testDryModeWithBulkOutputAndTableDoesNotExistsCreateTableSetToNo() t
args.put(ImportTsv.BULK_OUTPUT_CONF_KEY, hfiles.toString());
args.put(ImportTsv.DRY_RUN_CONF_KEY, "true");
args.put(ImportTsv.CREATE_TABLE_CONF_KEY, "no");
- exception.expect(TableNotFoundException.class);
- doMROnTableTest(null, 1);
+ assertThrows(TableNotFoundException.class, () -> doMROnTableTest(null, 1));
}
@Test
@@ -358,8 +345,7 @@ public void testDryModeWithBulkModeAndTableDoesNotExistsCreateTableSetToYes() th
args.put(ImportTsv.CREATE_TABLE_CONF_KEY, "yes");
doMROnTableTest(null, 1);
// Verify temporary table was deleted.
- exception.expect(TableNotFoundException.class);
- util.deleteTable(tn);
+ assertThrows(TableNotFoundException.class, () -> util.deleteTable(tn));
}
/**
@@ -453,8 +439,8 @@ protected static Tool doMROnTableTest(HBaseTestingUtility util, TableName table,
&& "true".equalsIgnoreCase(args.get(ImportTsv.DRY_RUN_CONF_KEY));
if (args.containsKey(ImportTsv.BULK_OUTPUT_CONF_KEY)) {
if (isDryRun) {
- assertFalse(String.format("Dry run mode, %s should not have been created.",
- ImportTsv.BULK_OUTPUT_CONF_KEY), fs.exists(new Path(ImportTsv.BULK_OUTPUT_CONF_KEY)));
+ assertFalse(fs.exists(new Path(ImportTsv.BULK_OUTPUT_CONF_KEY)), String.format(
+ "Dry run mode, %s should not have been created.", ImportTsv.BULK_OUTPUT_CONF_KEY));
} else {
validateHFiles(fs, args.get(ImportTsv.BULK_OUTPUT_CONF_KEY), family, expectedKVCount);
}
@@ -536,25 +522,25 @@ private static void validateHFiles(FileSystem fs, String outputPath, String fami
String[] elements = cfStatus.getPath().toString().split(Path.SEPARATOR);
String cf = elements[elements.length - 1];
foundFamilies.add(cf);
- assertTrue(String.format(
- "HFile output contains a column family (%s) not present in input families (%s)", cf,
- configFamilies), configFamilies.contains(cf));
+ assertTrue(configFamilies.contains(cf),
+ String.format(
+ "HFile output contains a column family (%s) not present in input families (%s)", cf,
+ configFamilies));
for (FileStatus hfile : fs.listStatus(cfStatus.getPath())) {
- assertTrue(String.format("HFile %s appears to contain no data.", hfile.getPath()),
- hfile.getLen() > 0);
+ assertTrue(hfile.getLen() > 0,
+ String.format("HFile %s appears to contain no data.", hfile.getPath()));
// count the number of KVs from all the hfiles
if (expectedKVCount > -1) {
actualKVCount += getKVCountFromHfile(fs, hfile.getPath());
}
}
}
- assertTrue(String.format("HFile output does not contain the input family '%s'.", family),
- foundFamilies.contains(family));
+ assertTrue(foundFamilies.contains(family),
+ String.format("HFile output does not contain the input family '%s'.", family));
if (expectedKVCount > -1) {
- assertTrue(
+ assertTrue(actualKVCount == expectedKVCount,
String.format("KV count in ouput hfile=<%d> doesn't match with expected KV count=<%d>",
- actualKVCount, expectedKVCount),
- actualKVCount == expectedKVCount);
+ actualKVCount, expectedKVCount));
}
}
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestImportTsvParser.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestImportTsvParser.java
index adb0589c9805..5e608db6aa6a 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestImportTsvParser.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestImportTsvParser.java
@@ -17,14 +17,14 @@
*/
package org.apache.hadoop.hbase.mapreduce;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import java.util.ArrayList;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.mapreduce.ImportTsv.TsvParser;
import org.apache.hadoop.hbase.mapreduce.ImportTsv.TsvParser.BadTsvLineException;
@@ -33,9 +33,8 @@
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.Pair;
-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.apache.hbase.thirdparty.com.google.common.base.Joiner;
import org.apache.hbase.thirdparty.com.google.common.base.Splitter;
@@ -44,11 +43,9 @@
/**
* Tests for {@link TsvParser}.
*/
-@Category({ MapReduceTests.class, SmallTests.class })
+@Tag(MapReduceTests.TAG)
+@Tag(SmallTests.TAG)
public class TestImportTsvParser {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestImportTsvParser.class);
private void assertBytesEquals(byte[] a, byte[] b) {
assertEquals(Bytes.toStringBinary(a), Bytes.toStringBinary(b));
@@ -171,50 +168,50 @@ public void testTsvParserWithTimestamp() throws BadTsvLineException {
/**
* Test cases that throw BadTsvLineException
*/
- @Test(expected = BadTsvLineException.class)
+ @Test
public void testTsvParserBadTsvLineExcessiveColumns() throws BadTsvLineException {
TsvParser parser = new TsvParser("HBASE_ROW_KEY,col_a", "\t");
byte[] line = Bytes.toBytes("val_a\tval_b\tval_c");
- parser.parse(line, line.length);
+ assertThrows(BadTsvLineException.class, () -> parser.parse(line, line.length));
}
- @Test(expected = BadTsvLineException.class)
+ @Test
public void testTsvParserBadTsvLineZeroColumn() throws BadTsvLineException {
TsvParser parser = new TsvParser("HBASE_ROW_KEY,col_a", "\t");
byte[] line = Bytes.toBytes("");
- parser.parse(line, line.length);
+ assertThrows(BadTsvLineException.class, () -> parser.parse(line, line.length));
}
- @Test(expected = BadTsvLineException.class)
+ @Test
public void testTsvParserBadTsvLineOnlyKey() throws BadTsvLineException {
TsvParser parser = new TsvParser("HBASE_ROW_KEY,col_a", "\t");
byte[] line = Bytes.toBytes("key_only");
- parser.parse(line, line.length);
+ assertThrows(BadTsvLineException.class, () -> parser.parse(line, line.length));
}
- @Test(expected = BadTsvLineException.class)
+ @Test
public void testTsvParserBadTsvLineNoRowKey() throws BadTsvLineException {
TsvParser parser = new TsvParser("col_a,HBASE_ROW_KEY", "\t");
byte[] line = Bytes.toBytes("only_cola_data_and_no_row_key");
- parser.parse(line, line.length);
+ assertThrows(BadTsvLineException.class, () -> parser.parse(line, line.length));
}
- @Test(expected = BadTsvLineException.class)
+ @Test
public void testTsvParserInvalidTimestamp() throws BadTsvLineException {
TsvParser parser = new TsvParser("HBASE_ROW_KEY,HBASE_TS_KEY,col_a,", "\t");
assertEquals(1, parser.getTimestampKeyColumnIndex());
byte[] line = Bytes.toBytes("rowkey\ttimestamp\tval_a");
ParsedLine parsed = parser.parse(line, line.length);
- assertEquals(-1, parsed.getTimestamp(-1));
+ assertThrows(BadTsvLineException.class, () -> parsed.getTimestamp(-1));
checkParsing(parsed, Splitter.on("\t").split(Bytes.toString(line)));
}
- @Test(expected = BadTsvLineException.class)
+ @Test
public void testTsvParserNoTimestampValue() throws BadTsvLineException {
TsvParser parser = new TsvParser("HBASE_ROW_KEY,col_a,HBASE_TS_KEY", "\t");
assertEquals(2, parser.getTimestampKeyColumnIndex());
byte[] line = Bytes.toBytes("rowkey\tval_a");
- parser.parse(line, line.length);
+ assertThrows(BadTsvLineException.class, () -> parser.parse(line, line.length));
}
@Test
@@ -225,30 +222,24 @@ public void testTsvParserParseRowKey() throws BadTsvLineException {
Pair rowKeyOffsets = parser.parseRowKey(line, line.length);
assertEquals(0, rowKeyOffsets.getFirst().intValue());
assertEquals(6, rowKeyOffsets.getSecond().intValue());
- try {
- line = Bytes.toBytes("\t\tval_a\t1234");
- parser.parseRowKey(line, line.length);
- fail("Should get BadTsvLineException on empty rowkey.");
- } catch (BadTsvLineException ignored) {
- }
- parser = new TsvParser("col_a,HBASE_ROW_KEY,HBASE_TS_KEY", "\t");
- assertEquals(1, parser.getRowKeyColumnIndex());
+ byte[] line2 = Bytes.toBytes("\t\tval_a\t1234");
+ assertThrows(BadTsvLineException.class, () -> parser.parseRowKey(line2, line2.length));
+
+ TsvParser parser2 = new TsvParser("col_a,HBASE_ROW_KEY,HBASE_TS_KEY", "\t");
+ assertEquals(1, parser2.getRowKeyColumnIndex());
line = Bytes.toBytes("val_a\trowkey\t1234");
- rowKeyOffsets = parser.parseRowKey(line, line.length);
+ rowKeyOffsets = parser2.parseRowKey(line, line.length);
assertEquals(6, rowKeyOffsets.getFirst().intValue());
assertEquals(6, rowKeyOffsets.getSecond().intValue());
- try {
- line = Bytes.toBytes("val_a");
- rowKeyOffsets = parser.parseRowKey(line, line.length);
- fail("Should get BadTsvLineException when number of columns less than rowkey position.");
- } catch (BadTsvLineException ignored) {
- }
- parser = new TsvParser("col_a,HBASE_TS_KEY,HBASE_ROW_KEY", "\t");
- assertEquals(2, parser.getRowKeyColumnIndex());
+ byte[] line3 = Bytes.toBytes("val_a");
+ assertThrows(BadTsvLineException.class, () -> parser2.parseRowKey(line3, line3.length));
+
+ TsvParser parser3 = new TsvParser("col_a,HBASE_TS_KEY,HBASE_ROW_KEY", "\t");
+ assertEquals(2, parser3.getRowKeyColumnIndex());
line = Bytes.toBytes("val_a\t1234\trowkey");
- rowKeyOffsets = parser.parseRowKey(line, line.length);
+ rowKeyOffsets = parser3.parseRowKey(line, line.length);
assertEquals(11, rowKeyOffsets.getFirst().intValue());
assertEquals(6, rowKeyOffsets.getSecond().intValue());
}
@@ -263,27 +254,21 @@ public void testTsvParseAttributesKey() throws BadTsvLineException {
assertEquals(3, parser.getAttributesKeyColumnIndex());
String[] attributes = parse.getIndividualAttributes();
assertEquals("key=>value", attributes[0]);
- try {
- line = Bytes.toBytes("rowkey\tval_a\t1234");
- parser.parse(line, line.length);
- fail("Should get BadTsvLineException on empty rowkey.");
- } catch (BadTsvLineException ignored) {
- }
+ byte[] line2 = Bytes.toBytes("rowkey\tval_a\t1234");
+ TsvParser finalParser = parser;
+ assertThrows(BadTsvLineException.class, () -> finalParser.parse(line2, line2.length));
- parser = new TsvParser("HBASE_ATTRIBUTES_KEY,col_a,HBASE_ROW_KEY,HBASE_TS_KEY", "\t");
- assertEquals(2, parser.getRowKeyColumnIndex());
+ TsvParser parser2 =
+ new TsvParser("HBASE_ATTRIBUTES_KEY,col_a,HBASE_ROW_KEY,HBASE_TS_KEY", "\t");
+ assertEquals(2, parser2.getRowKeyColumnIndex());
line = Bytes.toBytes("key=>value\tval_a\trowkey\t1234");
- parse = parser.parse(line, line.length);
+ parse = parser2.parse(line, line.length);
assertEquals(0, parse.getAttributeKeyOffset());
- assertEquals(0, parser.getAttributesKeyColumnIndex());
+ assertEquals(0, parser2.getAttributesKeyColumnIndex());
attributes = parse.getIndividualAttributes();
assertEquals("key=>value", attributes[0]);
- try {
- line = Bytes.toBytes("val_a");
- ParsedLine parse2 = parser.parse(line, line.length);
- fail("Should get BadTsvLineException when number of columns less than rowkey position.");
- } catch (BadTsvLineException ignored) {
- }
+ byte[] line3 = Bytes.toBytes("val_a");
+ assertThrows(BadTsvLineException.class, () -> parser2.parse(line3, line3.length));
parser = new TsvParser("col_a,HBASE_ATTRIBUTES_KEY,HBASE_TS_KEY,HBASE_ROW_KEY", "\t");
assertEquals(3, parser.getRowKeyColumnIndex());
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestJarFinder.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestJarFinder.java
index 87461c2735f0..810920f3779a 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestJarFinder.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestJarFinder.java
@@ -17,6 +17,9 @@
*/
package org.apache.hadoop.hbase.mapreduce;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
@@ -30,30 +33,23 @@
import java.util.jar.JarInputStream;
import java.util.jar.JarOutputStream;
import java.util.jar.Manifest;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
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.slf4j.LoggerFactory;
/**
* This file was forked from hadoop/common/branches/branch-2@1350012.
*/
-@Category(SmallTests.class)
+@Tag(SmallTests.TAG)
public class TestJarFinder {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestJarFinder.class);
-
@Test
public void testJar() throws Exception {
// picking a class that is for sure in a JAR in the classpath
String jar = JarFinder.getJar(LoggerFactory.class);
- Assert.assertTrue(new File(jar).exists());
+ assertTrue(new File(jar).exists());
}
private static void delete(File file) throws IOException {
@@ -82,7 +78,7 @@ public void testExpandedClasspath() throws Exception {
// picking a class that is for sure in a directory in the classpath
// in this case the JAR is created on the fly
String jar = JarFinder.getJar(TestJarFinder.class);
- Assert.assertTrue(new File(jar).exists());
+ assertTrue(new File(jar).exists());
}
@Test
@@ -108,7 +104,7 @@ public void testExistingManifest() throws Exception {
JarOutputStream zos = new JarOutputStream(baos);
JarFinder.jarDir(dir, "", zos);
JarInputStream jis = new JarInputStream(new ByteArrayInputStream(baos.toByteArray()));
- Assert.assertNotNull(jis.getManifest());
+ assertNotNull(jis.getManifest());
jis.close();
}
@@ -126,7 +122,7 @@ public void testNoManifest() throws Exception {
JarOutputStream zos = new JarOutputStream(baos);
JarFinder.jarDir(dir, "", zos);
JarInputStream jis = new JarInputStream(new ByteArrayInputStream(baos.toByteArray()));
- Assert.assertNotNull(jis.getManifest());
+ assertNotNull(jis.getManifest());
jis.close();
}
}
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestMultiTableInputFormat.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestMultiTableInputFormat.java
index e4a6cda8cab8..dd7b6fe7ae7c 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestMultiTableInputFormat.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestMultiTableInputFormat.java
@@ -19,28 +19,23 @@
import java.io.IOException;
import java.util.List;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
import org.apache.hadoop.hbase.testclassification.LargeTests;
import org.apache.hadoop.hbase.testclassification.VerySlowMapReduceTests;
import org.apache.hadoop.mapreduce.Job;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
/**
* Tests various scan start and stop row scenarios. This is set in a scan and tested in a MapReduce
* job to see if that is handed over and done properly too.
*/
-@Category({ VerySlowMapReduceTests.class, LargeTests.class })
+@Tag(VerySlowMapReduceTests.TAG)
+@Tag(LargeTests.TAG)
public class TestMultiTableInputFormat extends MultiTableInputFormatTestBase {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestMultiTableInputFormat.class);
-
- @BeforeClass
+ @BeforeAll
public static void setupLogging() {
TEST_UTIL.enableDebug(MultiTableInputFormat.class);
}
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestMultiTableInputFormatBase.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestMultiTableInputFormatBase.java
index 32da37f1f4ff..44695fe419b5 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestMultiTableInputFormatBase.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestMultiTableInputFormatBase.java
@@ -18,6 +18,8 @@
package org.apache.hadoop.hbase.mapreduce;
import static org.apache.hadoop.hbase.client.Scan.SCAN_ATTRIBUTES_TABLE_NAME;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
import java.util.ArrayList;
@@ -27,7 +29,6 @@
import java.util.concurrent.ExecutorService;
import java.util.concurrent.atomic.AtomicInteger;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.HRegionLocation;
@@ -53,12 +54,9 @@
import org.apache.hadoop.mapreduce.JobContext;
import org.apache.hadoop.mapreduce.RecordReader;
import org.apache.hadoop.mapreduce.TaskAttemptContext;
-import org.junit.Assert;
-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.Tag;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
import org.mockito.Mockito;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
@@ -66,23 +64,16 @@
/**
* Tests of MultiTableInputFormatBase.
*/
-@Category({ SmallTests.class })
+@Tag(SmallTests.TAG)
public class TestMultiTableInputFormatBase {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestMultiTableInputFormatBase.class);
-
- @Rule
- public final TestName name = new TestName();
-
/**
* Test getSplits only puts up one Connection. In past it has put up many Connections. Each
* Connection setup comes with a fresh new cache so we have to do fresh hit on hbase:meta. Should
* only do one Connection when doing getSplits even if a MultiTableInputFormat.
*/
@Test
- public void testMRSplitsConnectionCount() throws IOException {
+ public void testMRSplitsConnectionCount(TestInfo testInfo) throws IOException {
// Make instance of MTIFB.
MultiTableInputFormatBase mtif = new MultiTableInputFormatBase() {
@Override
@@ -102,17 +93,17 @@ public RecordReader createRecordReader(InputSpli
List scans = new ArrayList<>();
for (int i = 0; i < 10; i++) {
Scan scan = new Scan();
- String tableName = this.name.getMethodName() + i;
+ String tableName = testInfo.getTestMethod().get().getName() + i;
scan.setAttribute(SCAN_ATTRIBUTES_TABLE_NAME, Bytes.toBytes(tableName));
scans.add(scan);
}
mtif.setScans(scans);
// Get splits. Assert that that more than one.
List splits = mtif.getSplits(mockedJobContext);
- Assert.assertTrue(splits.size() > 0);
+ assertTrue(splits.size() > 0);
// Assert only one Connection was made (see the static counter we have in the mocked
// Connection MRSplitsConnection Constructor.
- Assert.assertEquals(1, MRSplitsConnection.creations.get());
+ assertEquals(1, MRSplitsConnection.creations.get());
}
/**
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestMultiTableSnapshotInputFormat.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestMultiTableSnapshotInputFormat.java
index 023b8404bcbe..d8adecd6e798 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestMultiTableSnapshotInputFormat.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestMultiTableSnapshotInputFormat.java
@@ -23,7 +23,6 @@
import java.util.List;
import java.util.Map;
import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
@@ -33,25 +32,21 @@
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.CommonFSUtils;
import org.apache.hadoop.mapreduce.Job;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-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.apache.hbase.thirdparty.com.google.common.base.Function;
import org.apache.hbase.thirdparty.com.google.common.collect.ImmutableList;
import org.apache.hbase.thirdparty.com.google.common.collect.Multimaps;
-@Category({ VerySlowMapReduceTests.class, LargeTests.class })
+@Tag(VerySlowMapReduceTests.TAG)
+@Tag(LargeTests.TAG)
public class TestMultiTableSnapshotInputFormat extends MultiTableInputFormatTestBase {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestMultiTableSnapshotInputFormat.class);
-
protected Path restoreDir;
- @BeforeClass
+ @BeforeAll
public static void setUpSnapshots() throws Exception {
TEST_UTIL.enableDebug(MultiTableSnapshotInputFormat.class);
TEST_UTIL.enableDebug(MultiTableSnapshotInputFormatImpl.class);
@@ -65,7 +60,7 @@ public static void setUpSnapshots() throws Exception {
}
}
- @Before
+ @BeforeEach
public void setUp() throws Exception {
this.restoreDir = TEST_UTIL.getRandomDir();
}
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestMultiTableSnapshotInputFormatImpl.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestMultiTableSnapshotInputFormatImpl.java
index adf6744406d8..bcb27bbc484e 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestMultiTableSnapshotInputFormatImpl.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestMultiTableSnapshotInputFormatImpl.java
@@ -17,7 +17,7 @@
*/
package org.apache.hadoop.hbase.mapreduce;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doNothing;
@@ -30,15 +30,13 @@
import java.util.Objects;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.CommonFSUtils;
-import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.apache.hbase.thirdparty.com.google.common.collect.ImmutableList;
@@ -46,20 +44,16 @@
import org.apache.hbase.thirdparty.com.google.common.collect.Lists;
import org.apache.hbase.thirdparty.com.google.common.collect.Maps;
-@Category({ SmallTests.class })
+@Tag(SmallTests.TAG)
public class TestMultiTableSnapshotInputFormatImpl {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestMultiTableSnapshotInputFormatImpl.class);
-
private MultiTableSnapshotInputFormatImpl subject;
private Map> snapshotScans;
private Path restoreDir;
private Configuration conf;
private Path rootDir;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
this.subject = Mockito.spy(new MultiTableSnapshotInputFormatImpl());
@@ -172,8 +166,8 @@ public void testSetInputCreatesRestoreDirectoriesUnderRootRestoreDir() throws Ex
Map restoreDirs = subject.getSnapshotDirs(conf);
for (Path snapshotDir : restoreDirs.values()) {
- assertEquals("Expected " + snapshotDir + " to be a child of " + restoreDir, restoreDir,
- snapshotDir.getParent());
+ assertEquals(restoreDir, snapshotDir.getParent(),
+ "Expected " + snapshotDir + " to be a child of " + restoreDir);
}
}
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestMultithreadedTableMapper.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestMultithreadedTableMapper.java
index 3c8e5b6f16c5..9c6c73dd31ec 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestMultithreadedTableMapper.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestMultithreadedTableMapper.java
@@ -17,8 +17,8 @@
*/
package org.apache.hadoop.hbase.mapreduce;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import java.io.File;
import java.io.IOException;
@@ -29,7 +29,6 @@
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellUtil;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.TableName;
@@ -44,11 +43,10 @@
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -57,13 +55,10 @@
* simple - take every row in the table, reverse the value of a particular cell, and write it back
* to the table.
*/
-@Category({ MapReduceTests.class, LargeTests.class })
+@Tag(MapReduceTests.TAG)
+@Tag(LargeTests.TAG)
public class TestMultithreadedTableMapper {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestMultithreadedTableMapper.class);
-
private static final Logger LOG = LoggerFactory.getLogger(TestMultithreadedTableMapper.class);
private static final HBaseTestingUtility UTIL = new HBaseTestingUtility();
static final TableName MULTI_REGION_TABLE_NAME = TableName.valueOf("mrtest");
@@ -71,7 +66,7 @@ public class TestMultithreadedTableMapper {
static final byte[] OUTPUT_FAMILY = Bytes.toBytes("text");
static final int NUMBER_OF_THREADS = 10;
- @BeforeClass
+ @BeforeAll
public static void beforeClass() throws Exception {
// Up the handlers; this test needs more than usual.
UTIL.getConfiguration().setInt(HConstants.REGION_SERVER_HIGH_PRIORITY_HANDLER_COUNT, 10);
@@ -82,7 +77,7 @@ public static void beforeClass() throws Exception {
UTIL.waitUntilAllRegionsAssigned(MULTI_REGION_TABLE_NAME);
}
- @AfterClass
+ @AfterAll
public static void afterClass() throws Exception {
UTIL.shutdownMiniCluster();
}
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestRegionSizeCalculator.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestRegionSizeCalculator.java
index 5b25d91ade3c..8acca22fb816 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestRegionSizeCalculator.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestRegionSizeCalculator.java
@@ -18,7 +18,7 @@
package org.apache.hadoop.hbase.mapreduce;
import static org.apache.hadoop.hbase.HConstants.DEFAULT_REGIONSERVER_PORT;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.when;
import java.io.IOException;
@@ -27,7 +27,6 @@
import java.util.Collections;
import java.util.List;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HRegionInfo;
import org.apache.hadoop.hbase.HRegionLocation;
import org.apache.hadoop.hbase.RegionMetrics;
@@ -39,18 +38,14 @@
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.mockito.Mockito;
-@Category({ MiscTests.class, SmallTests.class })
+@Tag(MiscTests.TAG)
+@Tag(SmallTests.TAG)
public class TestRegionSizeCalculator {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestRegionSizeCalculator.class);
-
private Configuration configuration = new Configuration();
private final long megabyte = 1024L * 1024L;
private final ServerName sn =
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestRoundRobinTableInputFormat.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestRoundRobinTableInputFormat.java
index 34bd76937d33..0eef2b15b1fb 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestRoundRobinTableInputFormat.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestRoundRobinTableInputFormat.java
@@ -17,9 +17,9 @@
*/
package org.apache.hadoop.hbase.mapreduce;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+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 java.io.IOException;
import java.util.ArrayList;
@@ -28,7 +28,6 @@
import java.util.Comparator;
import java.util.List;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Scan;
@@ -36,19 +35,15 @@
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.mapreduce.InputSplit;
import org.apache.hadoop.mapreduce.JobContext;
-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.mockito.Mockito;
/**
* Basic test of {@link RoundRobinTableInputFormat}; i.e. RRTIF.
*/
-@Category({ SmallTests.class })
+@Tag(SmallTests.TAG)
public class TestRoundRobinTableInputFormat {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestRoundRobinTableInputFormat.class);
private static final int SERVERS_COUNT = 5;
private static final String[] KEYS = { "aa", "ab", "ac", "ad", "ae", "ba", "bb", "bc", "bd", "be",
@@ -127,7 +122,7 @@ private void assertLengthDescending(List list)
long previousLength = Long.MAX_VALUE;
for (InputSplit is : list) {
long length = is.getLength();
- assertTrue(previousLength + " " + length, previousLength > length);
+ assertTrue(previousLength > length, previousLength + " " + length);
previousLength = length;
}
}
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestRowCounter.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestRowCounter.java
index 559bdd3e2633..ed464f86ddec 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestRowCounter.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestRowCounter.java
@@ -17,9 +17,9 @@
*/
package org.apache.hadoop.hbase.mapreduce;
-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 java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -27,7 +27,6 @@
import java.util.ArrayList;
import java.util.Arrays;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Delete;
@@ -41,24 +40,20 @@
import org.apache.hadoop.mapreduce.Counter;
import org.apache.hadoop.mapreduce.Counters;
import org.apache.hadoop.mapreduce.Job;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Test the rowcounter map reduce job.
*/
-@Category({ MapReduceTests.class, LargeTests.class })
+@Tag(MapReduceTests.TAG)
+@Tag(LargeTests.TAG)
public class TestRowCounter {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestRowCounter.class);
-
private static final Logger LOG = LoggerFactory.getLogger(TestRowCounter.class);
private final static HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
private final static String TABLE_NAME = "testRowCounter";
@@ -73,7 +68,7 @@ public class TestRowCounter {
/**
* @throws java.lang.Exception
*/
- @BeforeClass
+ @BeforeAll
public static void setUpBeforeClass() throws Exception {
TEST_UTIL.startMiniCluster();
Table table = TEST_UTIL.createTable(TableName.valueOf(TABLE_NAME), Bytes.toBytes(COL_FAM));
@@ -84,7 +79,7 @@ public static void setUpBeforeClass() throws Exception {
/**
* @throws java.lang.Exception
*/
- @AfterClass
+ @AfterAll
public static void tearDownAfterClass() throws Exception {
TEST_UTIL.shutdownMiniCluster();
}
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestSimpleTotalOrderPartitioner.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestSimpleTotalOrderPartitioner.java
index 61911670ac9f..3c67cecd5be4 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestSimpleTotalOrderPartitioner.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestSimpleTotalOrderPartitioner.java
@@ -17,30 +17,25 @@
*/
package org.apache.hadoop.hbase.mapreduce;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
import org.apache.hadoop.hbase.testclassification.MapReduceTests;
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;
/**
* Test of simple partitioner.
*/
-@Category({ MapReduceTests.class, SmallTests.class })
+@Tag(MapReduceTests.TAG)
+@Tag(SmallTests.TAG)
public class TestSimpleTotalOrderPartitioner {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestSimpleTotalOrderPartitioner.class);
-
protected final static HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
Configuration conf = TEST_UTIL.getConfiguration();
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestSyncTable.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestSyncTable.java
index 732d9d8ff88b..2faeb24fa729 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestSyncTable.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestSyncTable.java
@@ -17,9 +17,9 @@
*/
package org.apache.hadoop.hbase.mapreduce;
-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 java.util.Arrays;
import java.util.function.BooleanSupplier;
@@ -29,7 +29,6 @@
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellUtil;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Put;
@@ -43,24 +42,20 @@
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
import org.apache.hadoop.mapreduce.Counters;
-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.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Basic test for the SyncTable M/R tool
*/
-@Category({ MapReduceTests.class, LargeTests.class })
+@Tag(MapReduceTests.TAG)
+@Tag(LargeTests.TAG)
public class TestSyncTable {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestSyncTable.class);
private static final Logger LOG = LoggerFactory.getLogger(TestSyncTable.class);
@@ -68,16 +63,13 @@ public class TestSyncTable {
private static final HBaseTestingUtility UTIL2 = new HBaseTestingUtility();
- @Rule
- public TestName name = new TestName();
-
- @BeforeClass
+ @BeforeAll
public static void beforeClass() throws Exception {
UTIL1.startMiniCluster(3);
UTIL2.startMiniCluster(3);
}
- @AfterClass
+ @AfterAll
public static void afterClass() throws Exception {
UTIL2.shutdownMiniCluster();
UTIL1.shutdownMiniCluster();
@@ -91,11 +83,13 @@ private static byte[][] generateSplits(int numRows, int numRegions) {
return splitRows;
}
- private void testSyncTable(HBaseTestingUtility source, HBaseTestingUtility target,
- String... options) throws Exception {
- final TableName sourceTableName = TableName.valueOf(name.getMethodName() + "_source");
- final TableName targetTableName = TableName.valueOf(name.getMethodName() + "_target");
- Path testDir = source.getDataTestDirOnTestFS(name.getMethodName());
+ private void testSyncTable(TestInfo testInfo, HBaseTestingUtility source,
+ HBaseTestingUtility target, String... options) throws Exception {
+ final TableName sourceTableName =
+ TableName.valueOf(testInfo.getTestMethod().get().getName() + "_source");
+ final TableName targetTableName =
+ TableName.valueOf(testInfo.getTestMethod().get().getName() + "_target");
+ Path testDir = source.getDataTestDirOnTestFS(testInfo.getTestMethod().get().getName());
writeTestData(source, sourceTableName, target, targetTableName);
hashSourceTable(source, sourceTableName, testDir);
@@ -115,26 +109,28 @@ private void testSyncTable(HBaseTestingUtility source, HBaseTestingUtility targe
}
@Test
- public void testSyncTable() throws Exception {
- testSyncTable(UTIL1, UTIL1);
+ public void testSyncTable(TestInfo testInfo) throws Exception {
+ testSyncTable(testInfo, UTIL1, UTIL1);
}
@Test
- public void testSyncTableToPeerCluster() throws Exception {
- testSyncTable(UTIL1, UTIL2, "--sourcezkcluster=" + UTIL1.getClusterKey());
+ public void testSyncTableToPeerCluster(TestInfo testInfo) throws Exception {
+ testSyncTable(testInfo, UTIL1, UTIL2, "--sourcezkcluster=" + UTIL1.getClusterKey());
}
@Test
- public void testSyncTableFromSourceToPeerCluster() throws Exception {
- testSyncTable(UTIL2, UTIL1, "--sourcezkcluster=" + UTIL2.getClusterKey(),
+ public void testSyncTableFromSourceToPeerCluster(TestInfo testInfo) throws Exception {
+ testSyncTable(testInfo, UTIL2, UTIL1, "--sourcezkcluster=" + UTIL2.getClusterKey(),
"--targetzkcluster=" + UTIL1.getClusterKey());
}
@Test
- public void testSyncTableDoDeletesFalse() throws Exception {
- final TableName sourceTableName = TableName.valueOf(name.getMethodName() + "_source");
- final TableName targetTableName = TableName.valueOf(name.getMethodName() + "_target");
- Path testDir = UTIL1.getDataTestDirOnTestFS(name.getMethodName());
+ public void testSyncTableDoDeletesFalse(TestInfo testInfo) throws Exception {
+ final TableName sourceTableName =
+ TableName.valueOf(testInfo.getTestMethod().get().getName() + "_source");
+ final TableName targetTableName =
+ TableName.valueOf(testInfo.getTestMethod().get().getName() + "_target");
+ Path testDir = UTIL1.getDataTestDirOnTestFS(testInfo.getTestMethod().get().getName());
writeTestData(UTIL1, sourceTableName, UTIL1, targetTableName);
hashSourceTable(UTIL1, sourceTableName, testDir);
@@ -154,10 +150,12 @@ public void testSyncTableDoDeletesFalse() throws Exception {
}
@Test
- public void testSyncTableDoPutsFalse() throws Exception {
- final TableName sourceTableName = TableName.valueOf(name.getMethodName() + "_source");
- final TableName targetTableName = TableName.valueOf(name.getMethodName() + "_target");
- Path testDir = UTIL2.getDataTestDirOnTestFS(name.getMethodName());
+ public void testSyncTableDoPutsFalse(TestInfo testInfo) throws Exception {
+ final TableName sourceTableName =
+ TableName.valueOf(testInfo.getTestMethod().get().getName() + "_source");
+ final TableName targetTableName =
+ TableName.valueOf(testInfo.getTestMethod().get().getName() + "_target");
+ Path testDir = UTIL2.getDataTestDirOnTestFS(testInfo.getTestMethod().get().getName());
writeTestData(UTIL2, sourceTableName, UTIL2, targetTableName);
hashSourceTable(UTIL2, sourceTableName, testDir);
@@ -177,10 +175,12 @@ public void testSyncTableDoPutsFalse() throws Exception {
}
@Test
- public void testSyncTableIgnoreTimestampsTrue() throws Exception {
- final TableName sourceTableName = TableName.valueOf(name.getMethodName() + "_source");
- final TableName targetTableName = TableName.valueOf(name.getMethodName() + "_target");
- Path testDir = UTIL1.getDataTestDirOnTestFS(name.getMethodName());
+ public void testSyncTableIgnoreTimestampsTrue(TestInfo testInfo) throws Exception {
+ final TableName sourceTableName =
+ TableName.valueOf(testInfo.getTestMethod().get().getName() + "_source");
+ final TableName targetTableName =
+ TableName.valueOf(testInfo.getTestMethod().get().getName() + "_target");
+ Path testDir = UTIL1.getDataTestDirOnTestFS(testInfo.getTestMethod().get().getName());
long current = EnvironmentEdgeManager.currentTime();
writeTestData(UTIL1, sourceTableName, UTIL2, targetTableName, current - 1000, current);
hashSourceTable(UTIL1, sourceTableName, testDir, "--ignoreTimestamps=true");
@@ -200,18 +200,18 @@ public void testSyncTableIgnoreTimestampsTrue() throws Exception {
}
private void assertCellEquals(Cell sourceCell, Cell targetCell, BooleanSupplier checkTimestamp) {
- assertTrue("Rows don't match, source: " + sourceCell + ", target: " + targetCell,
- CellUtil.matchingRows(sourceCell, targetCell));
- assertTrue("Families don't match, source: " + sourceCell + ", target: " + targetCell,
- CellUtil.matchingFamily(sourceCell, targetCell));
- assertTrue("Qualifiers don't match, source: " + sourceCell + ", target: " + targetCell,
- CellUtil.matchingQualifier(sourceCell, targetCell));
+ assertTrue(CellUtil.matchingRows(sourceCell, targetCell),
+ "Rows don't match, source: " + sourceCell + ", target: " + targetCell);
+ assertTrue(CellUtil.matchingFamily(sourceCell, targetCell),
+ "Families don't match, source: " + sourceCell + ", target: " + targetCell);
+ assertTrue(CellUtil.matchingQualifier(sourceCell, targetCell),
+ "Qualifiers don't match, source: " + sourceCell + ", target: " + targetCell);
if (checkTimestamp.getAsBoolean()) {
- assertTrue("Timestamps don't match, source: " + sourceCell + ", target: " + targetCell,
- CellUtil.matchingTimestamp(sourceCell, targetCell));
+ assertTrue(CellUtil.matchingTimestamp(sourceCell, targetCell),
+ "Timestamps don't match, source: " + sourceCell + ", target: " + targetCell);
}
- assertTrue("Values don't match, source: " + sourceCell + ", target: " + targetCell,
- CellUtil.matchingValue(sourceCell, targetCell));
+ assertTrue(CellUtil.matchingValue(sourceCell, targetCell),
+ "Values don't match, source: " + sourceCell + ", target: " + targetCell);
}
private void assertEqualTables(int expectedRows, HBaseTestingUtility sourceCluster,
@@ -314,7 +314,7 @@ private void assertTargetDoDeletesFalse(int expectedRows, HBaseTestingUtility so
targetRow = targetScanner.next();
sourceRow = sourceScanner.next();
}
- assertEquals("Target expected rows does not match.", expectedRows, rowsCount);
+ assertEquals(expectedRows, rowsCount, "Target expected rows does not match.");
}
}
@@ -384,7 +384,7 @@ private void assertTargetDoPutsFalse(int expectedRows, HBaseTestingUtility sourc
targetRow = targetScanner.next();
sourceRow = sourceScanner.next();
}
- assertEquals("Target expected rows does not match.", expectedRows, rowsCount);
+ assertEquals(expectedRows, rowsCount, "Target expected rows does not match.");
}
}
@@ -396,7 +396,7 @@ private Counters syncTables(Configuration conf, TableName sourceTableName,
args[options.length + 1] = sourceTableName.getNameAsString();
args[options.length + 2] = targetTableName.getNameAsString();
int code = syncTable.run(args);
- assertEquals("sync table job failed", 0, code);
+ assertEquals(0, code, "sync table job failed");
LOG.info("Sync tables completed");
return syncTable.counters;
@@ -415,7 +415,7 @@ private void hashSourceTable(HBaseTestingUtility sourceCluster, TableName source
args[options.length + 3] = sourceTableName.getNameAsString();
args[options.length + 4] = testDir.toString();
int code = hashTable.run(args);
- assertEquals("hash table job failed", 0, code);
+ assertEquals(0, code, "hash table job failed");
FileSystem fs = sourceCluster.getTestFileSystem();
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableInputFormat.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableInputFormat.java
index abcd23b9d513..e022472de9eb 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableInputFormat.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableInputFormat.java
@@ -17,9 +17,10 @@
*/
package org.apache.hadoop.hbase.mapreduce;
-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.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.*;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
@@ -31,7 +32,6 @@
import java.util.Map;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CompareOperator;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.NotServingRegionException;
@@ -57,12 +57,11 @@
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.JobContext;
import org.apache.hadoop.mapreduce.lib.output.NullOutputFormat;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.slf4j.Logger;
@@ -71,13 +70,9 @@
/**
* This tests the TableInputFormat and its recovery semantics
*/
-@Category(LargeTests.class)
+@Tag(LargeTests.TAG)
public class TestTableInputFormat {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestTableInputFormat.class);
-
private static final Logger LOG = LoggerFactory.getLogger(TestTableInputFormat.class);
private final static HBaseTestingUtility UTIL = new HBaseTestingUtility();
@@ -86,17 +81,17 @@ public class TestTableInputFormat {
private static final byte[][] columns = new byte[][] { FAMILY };
- @BeforeClass
+ @BeforeAll
public static void beforeClass() throws Exception {
UTIL.startMiniCluster();
}
- @AfterClass
+ @AfterAll
public static void afterClass() throws Exception {
UTIL.shutdownMiniCluster();
}
- @Before
+ @BeforeEach
public void before() throws IOException {
LOG.info("before");
UTIL.ensureSomeRegionServersAvailable(1);
@@ -266,11 +261,11 @@ public void testTableRecordReaderScannerFailMapreduce() throws IOException, Inte
/**
* Run test assuming Scanner IOException failure using newer mapreduce api
*/
- @Test(expected = IOException.class)
+ @Test
public void testTableRecordReaderScannerFailMapreduceTwice()
throws IOException, InterruptedException {
Table htable = createIOEScannerTable("table3-mr".getBytes(), 2);
- runTestMapreduce(htable);
+ assertThrows(IOException.class, () -> runTestMapreduce(htable));
}
/**
@@ -286,11 +281,12 @@ public void testTableRecordReaderScannerTimeoutMapreduce()
/**
* Run test assuming NotServingRegionException using newer mapreduce api
*/
- @Test(expected = org.apache.hadoop.hbase.NotServingRegionException.class)
+ @Test
public void testTableRecordReaderScannerTimeoutMapreduceTwice()
throws IOException, InterruptedException {
Table htable = createDNRIOEScannerTable("table5-mr".getBytes(), 2);
- runTestMapreduce(htable);
+ assertThrows(org.apache.hadoop.hbase.NotServingRegionException.class,
+ () -> runTestMapreduce(htable));
}
/**
@@ -334,19 +330,25 @@ void testInputFormat(Class extends InputFormat> clazz)
job.setNumReduceTasks(0);
LOG.debug("submitting job.");
- assertTrue("job failed!", job.waitForCompletion(true));
- assertEquals("Saw the wrong number of instances of the filtered-for row.", 2, job.getCounters()
- .findCounter(TestTableInputFormat.class.getName() + ":row", "aaa").getValue());
- assertEquals("Saw any instances of the filtered out row.", 0, job.getCounters()
- .findCounter(TestTableInputFormat.class.getName() + ":row", "bbb").getValue());
- assertEquals("Saw the wrong number of instances of columnA.", 1, job.getCounters()
- .findCounter(TestTableInputFormat.class.getName() + ":family", "columnA").getValue());
- assertEquals("Saw the wrong number of instances of columnB.", 1, job.getCounters()
- .findCounter(TestTableInputFormat.class.getName() + ":family", "columnB").getValue());
- assertEquals("Saw the wrong count of values for the filtered-for row.", 2, job.getCounters()
- .findCounter(TestTableInputFormat.class.getName() + ":value", "value aaa").getValue());
- assertEquals("Saw the wrong count of values for the filtered-out row.", 0, job.getCounters()
- .findCounter(TestTableInputFormat.class.getName() + ":value", "value bbb").getValue());
+ assertTrue(job.waitForCompletion(true), "job failed!");
+ assertEquals(2, job.getCounters()
+ .findCounter(TestTableInputFormat.class.getName() + ":row", "aaa").getValue(),
+ "Saw the wrong number of instances of the filtered-for row.");
+ assertEquals(0, job.getCounters()
+ .findCounter(TestTableInputFormat.class.getName() + ":row", "bbb").getValue(),
+ "Saw any instances of the filtered out row.");
+ assertEquals(1, job.getCounters()
+ .findCounter(TestTableInputFormat.class.getName() + ":family", "columnA").getValue(),
+ "Saw the wrong number of instances of columnA.");
+ assertEquals(1, job.getCounters()
+ .findCounter(TestTableInputFormat.class.getName() + ":family", "columnB").getValue(),
+ "Saw the wrong number of instances of columnB.");
+ assertEquals(2, job.getCounters()
+ .findCounter(TestTableInputFormat.class.getName() + ":value", "value aaa").getValue(),
+ "Saw the wrong count of values for the filtered-for row.");
+ assertEquals(0, job.getCounters()
+ .findCounter(TestTableInputFormat.class.getName() + ":value", "value bbb").getValue(),
+ "Saw the wrong count of values for the filtered-out row.");
}
public static class ExampleVerifier extends TableMapper {
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableInputFormatBase.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableInputFormatBase.java
index 38157c5cb0a2..ccedd9dd1ce5 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableInputFormatBase.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableInputFormatBase.java
@@ -17,9 +17,9 @@
*/
package org.apache.hadoop.hbase.mapreduce;
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.any;
-import static org.mockito.Mockito.anyBoolean;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -31,7 +31,6 @@
import java.util.TreeMap;
import java.util.concurrent.ExecutorService;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.HRegionLocation;
@@ -52,20 +51,15 @@
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.Pair;
import org.apache.hadoop.mapreduce.JobContext;
-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.mockito.Mockito;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
-@Category({ SmallTests.class })
+@Tag(SmallTests.TAG)
public class TestTableInputFormatBase {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestTableInputFormatBase.class);
-
@Test
public void testReuseRegionSizeCalculator() throws IOException {
JobContext context = mock(JobContext.class);
@@ -109,8 +103,8 @@ public void testTableInputFormatBaseReverseDNSForIPv6() throws UnknownHostExcept
}
System.out.println("Should retrun the hostname for this host " + localhost + " addr : " + addr);
String actualHostName = inputFormat.reverseDNS(addr);
- assertEquals("Should retrun the hostname for this host. Expected : " + localhost + " Actual : "
- + actualHostName, localhost, actualHostName);
+ assertEquals(localhost, actualHostName, "Should retrun the hostname for this host. Expected : "
+ + localhost + " Actual : " + actualHostName);
}
@Test
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableInputFormatScan.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableInputFormatScan.java
index aeea1dffbf51..3cf0004018e9 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableInputFormatScan.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableInputFormatScan.java
@@ -18,20 +18,15 @@
package org.apache.hadoop.hbase.mapreduce;
import java.io.IOException;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.testclassification.LargeTests;
import org.apache.hadoop.hbase.testclassification.MapReduceTests;
-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;
-@Category({ MapReduceTests.class, LargeTests.class })
+@Tag(MapReduceTests.TAG)
+@Tag(LargeTests.TAG)
public class TestTableInputFormatScan extends TestTableInputFormatScanBase {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestTableInputFormatScan.class);
-
/**
* Tests a MR scan using specific number of mappers. The test table has 26 regions,
*/
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableInputFormatScanBase.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableInputFormatScanBase.java
index 63a0b7fd4959..caf1a2d83262 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableInputFormatScanBase.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableInputFormatScanBase.java
@@ -17,9 +17,9 @@
*/
package org.apache.hadoop.hbase.mapreduce;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
import java.util.ArrayList;
@@ -44,9 +44,8 @@
import org.apache.hadoop.mapreduce.TaskCounter;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.apache.hadoop.mapreduce.lib.output.NullOutputFormat;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.BeforeClass;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -66,7 +65,7 @@ public abstract class TestTableInputFormatScanBase {
private static Table table = null;
- @BeforeClass
+ @BeforeAll
public static void setUpBeforeClass() throws Exception {
// start mini hbase cluster
TEST_UTIL.startMiniCluster(3);
@@ -75,7 +74,7 @@ public static void setUpBeforeClass() throws Exception {
TEST_UTIL.loadTable(table, INPUT_FAMILYS, null, false);
}
- @AfterClass
+ @AfterAll
public static void tearDownAfterClass() throws Exception {
TEST_UTIL.shutdownMiniCluster();
}
@@ -238,15 +237,15 @@ protected void testNumOfSplits(int splitsPerRegion, int expectedNumOfSplits)
ImmutableBytesWritable.class, ImmutableBytesWritable.class, job);
TableInputFormat tif = new TableInputFormat();
tif.setConf(job.getConfiguration());
- Assert.assertEquals(TABLE_NAME, table.getName());
+ assertEquals(TABLE_NAME, table.getName());
List splits = tif.getSplits(job);
for (InputSplit split : splits) {
TableSplit tableSplit = (TableSplit) split;
// In table input format, we do no store the scanner at the split level
// because we use the scan object from the map-reduce job conf itself.
- Assert.assertTrue(tableSplit.getScanAsString().isEmpty());
+ assertTrue(tableSplit.getScanAsString().isEmpty());
}
- Assert.assertEquals(expectedNumOfSplits, splits.size());
+ assertEquals(expectedNumOfSplits, splits.size());
}
/**
@@ -269,11 +268,12 @@ protected void testNumOfSplitsMR(int splitsPerRegion, int expectedNumOfSplits)
job.setReducerClass(ScanReducer.class);
job.setNumReduceTasks(1);
job.setOutputFormatClass(NullOutputFormat.class);
- assertTrue("job failed!", job.waitForCompletion(true));
+ assertTrue(job.waitForCompletion(true), "job failed!");
// for some reason, hbase does not expose JobCounter.TOTAL_LAUNCHED_MAPS,
// we use TaskCounter.SHUFFLED_MAPS to get total launched maps
- assertEquals("Saw the wrong count of mappers per region", expectedNumOfSplits,
- job.getCounters().findCounter(TaskCounter.SHUFFLED_MAPS).getValue());
+ assertEquals(expectedNumOfSplits,
+ job.getCounters().findCounter(TaskCounter.SHUFFLED_MAPS).getValue(),
+ "Saw the wrong count of mappers per region");
}
/**
@@ -292,14 +292,14 @@ protected void testAutobalanceNumOfSplit() throws IOException {
TableInputFormat tif = new TableInputFormat();
List res = tif.calculateAutoBalancedSplits(splits, 1073741824);
- assertEquals("Saw the wrong number of splits", 5, res.size());
+ assertEquals(5, res.size(), "Saw the wrong number of splits");
TableSplit ts1 = (TableSplit) res.get(0);
- assertEquals("The first split end key should be", 2, Bytes.toInt(ts1.getEndRow()));
+ assertEquals(2, Bytes.toInt(ts1.getEndRow()), "The first split end key should be");
TableSplit ts2 = (TableSplit) res.get(1);
- assertEquals("The second split regionsize should be", 20 * 1048576, ts2.getLength());
+ assertEquals(20 * 1048576, ts2.getLength(), "The second split regionsize should be");
TableSplit ts3 = (TableSplit) res.get(2);
- assertEquals("The third split start key should be", 3, Bytes.toInt(ts3.getStartRow()));
+ assertEquals(3, Bytes.toInt(ts3.getStartRow()), "The third split start key should be");
TableSplit ts4 = (TableSplit) res.get(4);
- assertNotEquals("The seventh split start key should not be", 4, Bytes.toInt(ts4.getStartRow()));
+ assertNotEquals(4, Bytes.toInt(ts4.getStartRow()), "The seventh split start key should not be");
}
}
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableInputFormatScanEmptyToAPP.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableInputFormatScanEmptyToAPP.java
index addcdc898c8e..885bfb5ab44c 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableInputFormatScanEmptyToAPP.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableInputFormatScanEmptyToAPP.java
@@ -18,20 +18,15 @@
package org.apache.hadoop.hbase.mapreduce;
import java.io.IOException;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.testclassification.MapReduceTests;
import org.apache.hadoop.hbase.testclassification.MediumTests;
-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;
-@Category({ MapReduceTests.class, MediumTests.class })
+@Tag(MapReduceTests.TAG)
+@Tag(MediumTests.TAG)
public class TestTableInputFormatScanEmptyToAPP extends TestTableInputFormatScanBase {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestTableInputFormatScanEmptyToAPP.class);
-
/**
* Tests a MR scan using specific start and stop rows.
*/
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableInputFormatScanEmptyToBBA.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableInputFormatScanEmptyToBBA.java
index e395b36e2a70..2a0357e5a46d 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableInputFormatScanEmptyToBBA.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableInputFormatScanEmptyToBBA.java
@@ -18,20 +18,15 @@
package org.apache.hadoop.hbase.mapreduce;
import java.io.IOException;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.testclassification.MapReduceTests;
import org.apache.hadoop.hbase.testclassification.MediumTests;
-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;
-@Category({ MapReduceTests.class, MediumTests.class })
+@Tag(MapReduceTests.TAG)
+@Tag(MediumTests.TAG)
public class TestTableInputFormatScanEmptyToBBA extends TestTableInputFormatScanBase {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestTableInputFormatScanEmptyToBBA.class);
-
/**
* Tests a MR scan using specific start and stop rows.
*/
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableInputFormatScanEmptyToBBB.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableInputFormatScanEmptyToBBB.java
index f86578712ae8..9107c0efb6e6 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableInputFormatScanEmptyToBBB.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableInputFormatScanEmptyToBBB.java
@@ -18,20 +18,15 @@
package org.apache.hadoop.hbase.mapreduce;
import java.io.IOException;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.testclassification.MapReduceTests;
import org.apache.hadoop.hbase.testclassification.MediumTests;
-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;
-@Category({ MapReduceTests.class, MediumTests.class })
+@Tag(MapReduceTests.TAG)
+@Tag(MediumTests.TAG)
public class TestTableInputFormatScanEmptyToBBB extends TestTableInputFormatScanBase {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestTableInputFormatScanEmptyToBBB.class);
-
/**
* Tests a MR scan using specific start and stop rows.
*/
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableInputFormatScanEmptyToEmpty.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableInputFormatScanEmptyToEmpty.java
index ef7b38b21be1..c4e73a945bb3 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableInputFormatScanEmptyToEmpty.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableInputFormatScanEmptyToEmpty.java
@@ -18,20 +18,15 @@
package org.apache.hadoop.hbase.mapreduce;
import java.io.IOException;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.testclassification.MapReduceTests;
import org.apache.hadoop.hbase.testclassification.MediumTests;
-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;
-@Category({ MapReduceTests.class, MediumTests.class })
+@Tag(MapReduceTests.TAG)
+@Tag(MediumTests.TAG)
public class TestTableInputFormatScanEmptyToEmpty extends TestTableInputFormatScanBase {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestTableInputFormatScanEmptyToEmpty.class);
-
/**
* Tests a MR scan using specific start and stop rows.
*/
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableInputFormatScanEmptyToOPP.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableInputFormatScanEmptyToOPP.java
index f20d8113f780..d88e9c57205a 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableInputFormatScanEmptyToOPP.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableInputFormatScanEmptyToOPP.java
@@ -18,20 +18,15 @@
package org.apache.hadoop.hbase.mapreduce;
import java.io.IOException;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.testclassification.MapReduceTests;
import org.apache.hadoop.hbase.testclassification.MediumTests;
-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;
-@Category({ MapReduceTests.class, MediumTests.class })
+@Tag(MapReduceTests.TAG)
+@Tag(MediumTests.TAG)
public class TestTableInputFormatScanEmptyToOPP extends TestTableInputFormatScanBase {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestTableInputFormatScanEmptyToOPP.class);
-
/**
* Tests a MR scan using specific start and stop rows.
*/
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableInputFormatScanOBBToOPP.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableInputFormatScanOBBToOPP.java
index fe3d703a289b..0eb16e3ff236 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableInputFormatScanOBBToOPP.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableInputFormatScanOBBToOPP.java
@@ -18,20 +18,15 @@
package org.apache.hadoop.hbase.mapreduce;
import java.io.IOException;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.testclassification.LargeTests;
import org.apache.hadoop.hbase.testclassification.MapReduceTests;
-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;
-@Category({ MapReduceTests.class, LargeTests.class })
+@Tag(MapReduceTests.TAG)
+@Tag(LargeTests.TAG)
public class TestTableInputFormatScanOBBToOPP extends TestTableInputFormatScanBase {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestTableInputFormatScanOBBToOPP.class);
-
/**
* Tests a MR scan using specific start and stop rows.
*/
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableInputFormatScanOBBToQPP.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableInputFormatScanOBBToQPP.java
index f6985a3fd773..1c32ce6e2227 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableInputFormatScanOBBToQPP.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableInputFormatScanOBBToQPP.java
@@ -18,20 +18,15 @@
package org.apache.hadoop.hbase.mapreduce;
import java.io.IOException;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.testclassification.MapReduceTests;
import org.apache.hadoop.hbase.testclassification.MediumTests;
-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;
-@Category({ MapReduceTests.class, MediumTests.class })
+@Tag(MapReduceTests.TAG)
+@Tag(MediumTests.TAG)
public class TestTableInputFormatScanOBBToQPP extends TestTableInputFormatScanBase {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestTableInputFormatScanOBBToQPP.class);
-
/**
* Tests a MR scan using specific start and stop rows.
*/
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableInputFormatScanOPPToEmpty.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableInputFormatScanOPPToEmpty.java
index e57051dfd192..7543cc39537f 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableInputFormatScanOPPToEmpty.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableInputFormatScanOPPToEmpty.java
@@ -18,20 +18,15 @@
package org.apache.hadoop.hbase.mapreduce;
import java.io.IOException;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.testclassification.MapReduceTests;
import org.apache.hadoop.hbase.testclassification.MediumTests;
-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;
-@Category({ MapReduceTests.class, MediumTests.class })
+@Tag(MapReduceTests.TAG)
+@Tag(MediumTests.TAG)
public class TestTableInputFormatScanOPPToEmpty extends TestTableInputFormatScanBase {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestTableInputFormatScanOPPToEmpty.class);
-
/**
* Tests a MR scan using specific start and stop rows.
*/
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableInputFormatScanYYXToEmpty.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableInputFormatScanYYXToEmpty.java
index c8b3394e54b4..a01fc83caa79 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableInputFormatScanYYXToEmpty.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableInputFormatScanYYXToEmpty.java
@@ -18,20 +18,15 @@
package org.apache.hadoop.hbase.mapreduce;
import java.io.IOException;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.testclassification.MapReduceTests;
import org.apache.hadoop.hbase.testclassification.MediumTests;
-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;
-@Category({ MapReduceTests.class, MediumTests.class })
+@Tag(MapReduceTests.TAG)
+@Tag(MediumTests.TAG)
public class TestTableInputFormatScanYYXToEmpty extends TestTableInputFormatScanBase {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestTableInputFormatScanYYXToEmpty.class);
-
/**
* Tests a MR scan using specific start and stop rows.
*/
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableInputFormatScanYYYToEmpty.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableInputFormatScanYYYToEmpty.java
index 175d10e1f755..c01477cffae3 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableInputFormatScanYYYToEmpty.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableInputFormatScanYYYToEmpty.java
@@ -18,20 +18,15 @@
package org.apache.hadoop.hbase.mapreduce;
import java.io.IOException;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.testclassification.MapReduceTests;
import org.apache.hadoop.hbase.testclassification.MediumTests;
-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;
-@Category({ MapReduceTests.class, MediumTests.class })
+@Tag(MapReduceTests.TAG)
+@Tag(MediumTests.TAG)
public class TestTableInputFormatScanYYYToEmpty extends TestTableInputFormatScanBase {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestTableInputFormatScanYYYToEmpty.class);
-
/**
* Tests a MR scan using specific start and stop rows.
*/
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableInputFormatScanYZYToEmpty.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableInputFormatScanYZYToEmpty.java
index 9ce2f0782b2f..68d1ecc8c439 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableInputFormatScanYZYToEmpty.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableInputFormatScanYZYToEmpty.java
@@ -18,20 +18,15 @@
package org.apache.hadoop.hbase.mapreduce;
import java.io.IOException;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.testclassification.MapReduceTests;
import org.apache.hadoop.hbase.testclassification.MediumTests;
-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;
-@Category({ MapReduceTests.class, MediumTests.class })
+@Tag(MapReduceTests.TAG)
+@Tag(MediumTests.TAG)
public class TestTableInputFormatScanYZYToEmpty extends TestTableInputFormatScanBase {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestTableInputFormatScanYZYToEmpty.class);
-
/**
* Tests a MR scan using specific start and stop rows.
*/
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableMapReduce.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableMapReduce.java
index 99606050667a..523ed5e670d5 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableMapReduce.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableMapReduce.java
@@ -17,9 +17,9 @@
*/
package org.apache.hadoop.hbase.mapreduce;
-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.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.File;
import java.io.IOException;
@@ -27,7 +27,6 @@
import java.util.NavigableMap;
import org.apache.hadoop.fs.FileUtil;
import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.TableNotEnabledException;
import org.apache.hadoop.hbase.TableNotFoundException;
@@ -44,9 +43,8 @@
import org.apache.hadoop.mapreduce.Counters;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
-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.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -56,13 +54,10 @@
* to the table.
*/
-@Category({ VerySlowMapReduceTests.class, LargeTests.class })
+@Tag(VerySlowMapReduceTests.TAG)
+@Tag(LargeTests.TAG)
public class TestTableMapReduce extends TestTableMapReduceBase {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestTableMapReduce.class);
-
private static final Logger LOG = LoggerFactory.getLogger(TestTableMapReduce.class);
@Override
@@ -142,27 +137,27 @@ private void verifyJobCountersAreEmitted(Job job) throws IOException {
Counters counters = job.getCounters();
Counter counter =
counters.findCounter(TableRecordReaderImpl.HBASE_COUNTER_GROUP_NAME, "RPC_CALLS");
- assertNotNull("Unable to find Job counter for HBase scan metrics, RPC_CALLS", counter);
- assertTrue("Counter value for RPC_CALLS should be larger than 0", counter.getValue() > 0);
+ assertNotNull(counter, "Unable to find Job counter for HBase scan metrics, RPC_CALLS");
+ assertTrue(counter.getValue() > 0, "Counter value for RPC_CALLS should be larger than 0");
}
- @Test(expected = TableNotEnabledException.class)
+ @Test
public void testWritingToDisabledTable() throws IOException {
-
- try (Admin admin = UTIL.getConnection().getAdmin();
- Table table = UTIL.getConnection().getTable(TABLE_FOR_NEGATIVE_TESTS)) {
- admin.disableTable(table.getName());
- runTestOnTable(table);
- fail("Should not have reached here, should have thrown an exception");
- }
+ assertThrows(TableNotEnabledException.class, () -> {
+ try (Admin admin = UTIL.getConnection().getAdmin();
+ Table table = UTIL.getConnection().getTable(TABLE_FOR_NEGATIVE_TESTS)) {
+ admin.disableTable(table.getName());
+ runTestOnTable(table);
+ }
+ });
}
- @Test(expected = TableNotFoundException.class)
+ @Test
public void testWritingToNonExistentTable() throws IOException {
-
- try (Table table = UTIL.getConnection().getTable(TableName.valueOf("table-does-not-exist"))) {
- runTestOnTable(table);
- fail("Should not have reached here, should have thrown an exception");
- }
+ assertThrows(TableNotFoundException.class, () -> {
+ try (Table table = UTIL.getConnection().getTable(TableName.valueOf("table-does-not-exist"))) {
+ runTestOnTable(table);
+ }
+ });
}
}
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableMapReduceBase.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableMapReduceBase.java
index 3ff8bafea484..e4c50f1b631c 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableMapReduceBase.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableMapReduceBase.java
@@ -17,8 +17,8 @@
*/
package org.apache.hadoop.hbase.mapreduce;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import java.io.IOException;
import java.util.Iterator;
@@ -37,9 +37,9 @@
import org.apache.hadoop.hbase.client.Table;
import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
import org.apache.hadoop.hbase.util.Bytes;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
/**
@@ -67,7 +67,7 @@ public abstract class TestTableMapReduceBase {
*/
protected abstract void runTestOnTable(Table table) throws IOException;
- @BeforeClass
+ @BeforeAll
public static void beforeClass() throws Exception {
UTIL.startMiniCluster();
Table table = UTIL.createMultiRegionTable(MULTI_REGION_TABLE_NAME,
@@ -76,7 +76,7 @@ public static void beforeClass() throws Exception {
UTIL.createTable(TABLE_FOR_NEGATIVE_TESTS, new byte[][] { INPUT_FAMILY, OUTPUT_FAMILY });
}
- @AfterClass
+ @AfterAll
public static void afterClass() throws Exception {
UTIL.deleteTable(TABLE_FOR_NEGATIVE_TESTS);
UTIL.shutdownMiniCluster();
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableMapReduceUtil.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableMapReduceUtil.java
index 9fac63ba5171..8d1ee99bf2cc 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableMapReduceUtil.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableMapReduceUtil.java
@@ -18,15 +18,14 @@
package org.apache.hadoop.hbase.mapreduce;
import static org.apache.hadoop.security.UserGroupInformation.loginUserFromKeytab;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+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 java.io.Closeable;
import java.io.File;
import java.util.Collection;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.security.provider.SaslClientAuthenticationProviders;
@@ -43,23 +42,19 @@
import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.security.token.Token;
import org.apache.hadoop.security.token.TokenIdentifier;
-import org.junit.After;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
/**
* Test different variants of initTableMapperJob method
*/
-@Category({ MapReduceTests.class, LargeTests.class })
+@Tag(MapReduceTests.TAG)
+@Tag(LargeTests.TAG)
public class TestTableMapReduceUtil {
private static final String HTTP_PRINCIPAL = "HTTP/localhost";
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestTableMapReduceUtil.class);
-
- @After
+ @AfterEach
public void after() {
SaslClientAuthenticationProviders.reset();
}
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableOutputFormat.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableOutputFormat.java
index 9170b26564de..9becfdd89831 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableOutputFormat.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableOutputFormat.java
@@ -17,10 +17,11 @@
*/
package org.apache.hadoop.hbase.mapreduce;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
import java.io.IOException;
import javax.validation.constraints.Null;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Delete;
@@ -33,24 +34,19 @@
import org.apache.hadoop.mapreduce.OutputCommitter;
import org.apache.hadoop.mapreduce.RecordWriter;
import org.apache.hadoop.mapreduce.TaskAttemptContext;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
/**
* Simple Tests to check whether the durability of the Mutation is changed or not, for
* {@link TableOutputFormat} if {@link TableOutputFormat#WAL_PROPERTY} is set to false.
*/
-@Category(MediumTests.class)
+@Tag(MediumTests.TAG)
public class TestTableOutputFormat {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestTableOutputFormat.class);
private static final HBaseTestingUtility util = new HBaseTestingUtility();
private static final TableName TABLE_NAME = TableName.valueOf("TEST_TABLE");
@@ -60,7 +56,7 @@ public class TestTableOutputFormat {
private static TaskAttemptContext context;
private static TableOutputFormat tableOutputFormat;
- @BeforeClass
+ @BeforeAll
public static void setUp() throws Exception {
util.startMiniCluster();
util.createTable(TABLE_NAME, columnFamily);
@@ -71,12 +67,12 @@ public static void setUp() throws Exception {
conf.set(TableOutputFormat.OUTPUT_TABLE, "TEST_TABLE");
}
- @AfterClass
+ @AfterAll
public static void tearDown() throws Exception {
util.shutdownMiniCluster();
}
- @After
+ @AfterEach
public void close() throws IOException, InterruptedException {
if (writer != null && context != null) {
writer.close(context);
@@ -96,14 +92,14 @@ public void testTableOutputFormatWhenWalIsOFFForPut() throws IOException, Interr
put.addColumn(columnFamily, Bytes.toBytes("aa"), Bytes.toBytes("value"));
// verifying whether durability of mutation is USE_DEFAULT or not, before commiting write.
- Assert.assertEquals("Durability of the mutation should be USE_DEFAULT", Durability.USE_DEFAULT,
- put.getDurability());
+ assertEquals(Durability.USE_DEFAULT, put.getDurability(),
+ "Durability of the mutation should be USE_DEFAULT");
writer.write(null, put);
// verifying whether durability of mutation got changed to the SKIP_WAL or not.
- Assert.assertEquals("Durability of the mutation should be SKIP_WAL", Durability.SKIP_WAL,
- put.getDurability());
+ assertEquals(Durability.SKIP_WAL, put.getDurability(),
+ "Durability of the mutation should be SKIP_WAL");
}
@Test
@@ -120,14 +116,14 @@ public void testTableOutputFormatWhenWalIsOFFForDelete()
delete.addColumn(columnFamily, Bytes.toBytes("aa"));
// verifying whether durability of mutation is USE_DEFAULT or not, before commiting write.
- Assert.assertEquals("Durability of the mutation should be USE_DEFAULT", Durability.USE_DEFAULT,
- delete.getDurability());
+ assertEquals(Durability.USE_DEFAULT, delete.getDurability(),
+ "Durability of the mutation should be USE_DEFAULT");
writer.write(null, delete);
// verifying whether durability of mutation got changed from USE_DEFAULT to the SKIP_WAL or not.
- Assert.assertEquals("Durability of the mutation should be SKIP_WAL", Durability.SKIP_WAL,
- delete.getDurability());
+ assertEquals(Durability.SKIP_WAL, delete.getDurability(),
+ "Durability of the mutation should be SKIP_WAL");
}
@Test
@@ -135,14 +131,14 @@ public void testOutputCommitterConfiguration() throws IOException, InterruptedEx
// 1. Verify it returns the default committer when the property is not set.
conf.unset(TableOutputFormat.OUTPUT_COMMITTER_CLASS);
tableOutputFormat.setConf(conf);
- Assert.assertEquals("Should use default committer", TableOutputCommitter.class,
- tableOutputFormat.getOutputCommitter(context).getClass());
+ assertEquals(TableOutputCommitter.class,
+ tableOutputFormat.getOutputCommitter(context).getClass(), "Should use default committer");
// 2. Verify it returns the custom committer when the property is set.
conf.set(TableOutputFormat.OUTPUT_COMMITTER_CLASS, DummyCommitter.class.getName());
tableOutputFormat.setConf(conf);
- Assert.assertEquals("Should use custom committer", DummyCommitter.class,
- tableOutputFormat.getOutputCommitter(context).getClass());
+ assertEquals(DummyCommitter.class, tableOutputFormat.getOutputCommitter(context).getClass(),
+ "Should use custom committer");
}
// Simple dummy committer for testing
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableRecordReader.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableRecordReader.java
index 5dd9ca43d526..c2a300597c69 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableRecordReader.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableRecordReader.java
@@ -17,13 +17,12 @@
*/
package org.apache.hadoop.hbase.mapreduce;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.HTestConst;
@@ -37,20 +36,15 @@
import org.apache.hadoop.hbase.regionserver.StoreScanner;
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.util.Bytes;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
-@Category(MediumTests.class)
+@Tag(MediumTests.TAG)
public class TestTableRecordReader {
private final static HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestTableRecordReader.class);
-
private static TableName TABLE_NAME = TableName.valueOf("TestTableRecordReader");
private static int NUM_ROWS = 5;
@@ -70,7 +64,7 @@ public class TestTableRecordReader {
private static final int TIMEOUT = 4000;
- @BeforeClass
+ @BeforeAll
public static void setUpBeforeClass() throws Exception {
Configuration conf = TEST_UTIL.getConfiguration();
@@ -105,7 +99,7 @@ private static List createPuts(byte[][] rows, byte[][] families, byte[][] q
return puts;
}
- @AfterClass
+ @AfterAll
public static void tearDownAfterClass() throws Exception {
TEST_UTIL.shutdownMiniCluster();
}
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableSnapshotInputFormat.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableSnapshotInputFormat.java
index 9909ce15af9c..bb1c384f12f1 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableSnapshotInputFormat.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableSnapshotInputFormat.java
@@ -23,7 +23,9 @@
import static org.apache.hadoop.hbase.mapreduce.TableSnapshotInputFormatImpl.SNAPSHOT_INPUTFORMAT_LOCALITY_ENABLED_KEY;
import static org.apache.hadoop.hbase.mapreduce.TableSnapshotInputFormatImpl.SNAPSHOT_INPUTFORMAT_ROW_LIMIT_PER_INPUTSPLIT;
import static org.apache.hadoop.hbase.mapreduce.TableSnapshotInputFormatImpl.SNAPSHOT_INPUTFORMAT_SCANNER_READTYPE;
-import static org.junit.Assert.assertEquals;
+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.mock;
import static org.mockito.Mockito.when;
@@ -33,7 +35,6 @@
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.HDFSBlocksDistribution;
@@ -60,24 +61,19 @@
import org.apache.hadoop.mapreduce.Reducer;
import org.apache.hadoop.mapreduce.TaskAttemptContext;
import org.apache.hadoop.mapreduce.lib.output.NullOutputFormat;
-import org.junit.Assert;
-import org.junit.ClassRule;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.rules.TestName;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.hbase.thirdparty.com.google.common.collect.Lists;
-@Category({ VerySlowMapReduceTests.class, LargeTests.class })
+@Tag(VerySlowMapReduceTests.TAG)
+@Tag(LargeTests.TAG)
public class TestTableSnapshotInputFormat extends TableSnapshotInputFormatTestBase {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestTableSnapshotInputFormat.class);
-
private static final Logger LOG = LoggerFactory.getLogger(TestTableSnapshotInputFormat.class);
private static final byte[] bbb = Bytes.toBytes("bbb");
@@ -85,8 +81,12 @@ public class TestTableSnapshotInputFormat extends TableSnapshotInputFormatTestBa
private static final byte[] bbc = Bytes.toBytes("bbc");
private static final byte[] yya = Bytes.toBytes("yya");
- @Rule
- public TestName name = new TestName();
+ private String name;
+
+ @BeforeEach
+ public void setUp(TestInfo testInfo) throws Exception {
+ name = testInfo.getTestMethod().get().getName();
+ }
@Override
protected byte[] getStartRow() {
@@ -104,19 +104,18 @@ public void testGetBestLocations() throws IOException {
Configuration conf = UTIL.getConfiguration();
HDFSBlocksDistribution blockDistribution = new HDFSBlocksDistribution();
- Assert.assertEquals(null,
- TableSnapshotInputFormatImpl.getBestLocations(conf, blockDistribution));
+ assertEquals(null, TableSnapshotInputFormatImpl.getBestLocations(conf, blockDistribution));
blockDistribution.addHostsAndBlockWeight(new String[] { "h1" }, 1);
- Assert.assertEquals(Lists.newArrayList("h1"),
+ assertEquals(Lists.newArrayList("h1"),
TableSnapshotInputFormatImpl.getBestLocations(conf, blockDistribution));
blockDistribution.addHostsAndBlockWeight(new String[] { "h1" }, 1);
- Assert.assertEquals(Lists.newArrayList("h1"),
+ assertEquals(Lists.newArrayList("h1"),
TableSnapshotInputFormatImpl.getBestLocations(conf, blockDistribution));
blockDistribution.addHostsAndBlockWeight(new String[] { "h2" }, 1);
- Assert.assertEquals(Lists.newArrayList("h1"),
+ assertEquals(Lists.newArrayList("h1"),
TableSnapshotInputFormatImpl.getBestLocations(conf, blockDistribution));
blockDistribution = new HDFSBlocksDistribution();
@@ -124,21 +123,21 @@ public void testGetBestLocations() throws IOException {
blockDistribution.addHostsAndBlockWeight(new String[] { "h2" }, 7);
blockDistribution.addHostsAndBlockWeight(new String[] { "h3" }, 5);
blockDistribution.addHostsAndBlockWeight(new String[] { "h4" }, 1);
- Assert.assertEquals(Lists.newArrayList("h1"),
+ assertEquals(Lists.newArrayList("h1"),
TableSnapshotInputFormatImpl.getBestLocations(conf, blockDistribution));
blockDistribution.addHostsAndBlockWeight(new String[] { "h2" }, 2);
- Assert.assertEquals(Lists.newArrayList("h1", "h2"),
+ assertEquals(Lists.newArrayList("h1", "h2"),
TableSnapshotInputFormatImpl.getBestLocations(conf, blockDistribution));
blockDistribution.addHostsAndBlockWeight(new String[] { "h2" }, 3);
- Assert.assertEquals(Lists.newArrayList("h2", "h1"),
+ assertEquals(Lists.newArrayList("h2", "h1"),
TableSnapshotInputFormatImpl.getBestLocations(conf, blockDistribution));
blockDistribution.addHostsAndBlockWeight(new String[] { "h3" }, 6);
blockDistribution.addHostsAndBlockWeight(new String[] { "h4" }, 9);
- Assert.assertEquals(Lists.newArrayList("h2", "h3", "h4"),
+ assertEquals(Lists.newArrayList("h2", "h3", "h4"),
TableSnapshotInputFormatImpl.getBestLocations(conf, blockDistribution));
}
@@ -176,7 +175,7 @@ protected void cleanup(Context context) throws IOException, InterruptedException
@Test
public void testInitTableSnapshotMapperJobConfig() throws Exception {
- final TableName tableName = TableName.valueOf(name.getMethodName());
+ final TableName tableName = TableName.valueOf(name);
String snapshotName = "foo";
try {
@@ -190,11 +189,11 @@ public void testInitTableSnapshotMapperJobConfig() throws Exception {
// TODO: would be better to examine directly the cache instance that results from this
// config. Currently this is not possible because BlockCache initialization is static.
- Assert.assertEquals("Snapshot job should be configured for default LruBlockCache.",
- HConstants.HFILE_BLOCK_CACHE_SIZE_DEFAULT,
- job.getConfiguration().getFloat(HConstants.HFILE_BLOCK_CACHE_SIZE_KEY, -1), 0.01);
- Assert.assertEquals("Snapshot job should not use BucketCache.", 0,
- job.getConfiguration().getFloat("hbase.bucketcache.size", -1), 0.01);
+ assertEquals(HConstants.HFILE_BLOCK_CACHE_SIZE_DEFAULT,
+ job.getConfiguration().getFloat(HConstants.HFILE_BLOCK_CACHE_SIZE_KEY, -1), 0.01,
+ "Snapshot job should be configured for default LruBlockCache.");
+ assertEquals(0, job.getConfiguration().getFloat("hbase.bucketcache.size", -1), 0.01,
+ "Snapshot job should not use BucketCache.");
} finally {
UTIL.getAdmin().deleteSnapshot(snapshotName);
UTIL.deleteTable(tableName);
@@ -206,7 +205,7 @@ public void testWithMockedMapReduceSingleRegionByRegionLocation() throws Excepti
Configuration conf = UTIL.getConfiguration();
conf.setBoolean(SNAPSHOT_INPUTFORMAT_LOCALITY_BY_REGION_LOCATION, true);
try {
- testWithMockedMapReduce(UTIL, name.getMethodName() + "Snapshot", 1, 1, 1, true);
+ testWithMockedMapReduce(UTIL, name + "Snapshot", 1, 1, 1, true);
} finally {
conf.unset(SNAPSHOT_INPUTFORMAT_LOCALITY_BY_REGION_LOCATION);
}
@@ -224,7 +223,7 @@ public void testRestoreSnapshotDoesNotCreateBackRefLinksInit(TableName tableName
@Override
public void testWithMockedMapReduce(HBaseTestingUtility util, String snapshotName, int numRegions,
int numSplitsPerRegion, int expectedNumSplits, boolean setLocalityEnabledTo) throws Exception {
- final TableName tableName = TableName.valueOf(name.getMethodName());
+ final TableName tableName = TableName.valueOf(name);
try {
createTableAndSnapshot(util, tableName, snapshotName, getStartRow(), getEndRow(), numRegions);
@@ -257,7 +256,7 @@ public void testWithMockedMapReduce(HBaseTestingUtility util, String snapshotNam
@Test
public void testWithMockedMapReduceWithSplitsPerRegion() throws Exception {
String snapshotName = "testWithMockedMapReduceMultiRegion";
- final TableName tableName = TableName.valueOf(name.getMethodName());
+ final TableName tableName = TableName.valueOf(name);
try {
createTableAndSnapshot(UTIL, tableName, snapshotName, getStartRow(), getEndRow(), 10);
@@ -282,7 +281,7 @@ public void testWithMockedMapReduceWithSplitsPerRegion() throws Exception {
@Test
public void testWithMockedMapReduceWithNoStartRowStopRow() throws Exception {
String snapshotName = "testWithMockedMapReduceMultiRegion";
- final TableName tableName = TableName.valueOf(name.getMethodName());
+ final TableName tableName = TableName.valueOf(name);
try {
createTableAndSnapshot(UTIL, tableName, snapshotName, getStartRow(), getEndRow(), 10);
@@ -308,7 +307,7 @@ public void testWithMockedMapReduceWithNoStartRowStopRow() throws Exception {
@Test
public void testScanLimit() throws Exception {
- final TableName tableName = TableName.valueOf(name.getMethodName());
+ final TableName tableName = TableName.valueOf(name);
final String snapshotName = tableName + "Snapshot";
Table table = null;
try {
@@ -341,8 +340,8 @@ public void testScanLimit() throws Exception {
TableMapReduceUtil.initTableSnapshotMapperJob(snapshotName, scan,
RowCounter.RowCounterMapper.class, NullWritable.class, NullWritable.class, job, true,
tmpTableDir);
- Assert.assertTrue(job.waitForCompletion(true));
- Assert.assertEquals(10 * regionNum,
+ assertTrue(job.waitForCompletion(true));
+ assertEquals(10 * regionNum,
job.getCounters().findCounter(RowCounter.RowCounterMapper.Counters.ROWS).getValue());
} finally {
if (table != null) {
@@ -439,7 +438,7 @@ private void verifyWithMockedMapReduce(Job job, int numRegions, int expectedNumS
TableSnapshotInputFormat tsif = new TableSnapshotInputFormat();
List splits = tsif.getSplits(job);
- Assert.assertEquals(expectedNumSplits, splits.size());
+ assertEquals(expectedNumSplits, splits.size());
HBaseTestingUtility.SeenRowTracker rowTracker = new HBaseTestingUtility.SeenRowTracker(startRow,
stopRow.length > 0 ? stopRow : Bytes.toBytes("\uffff"));
@@ -453,38 +452,35 @@ private void verifyWithMockedMapReduce(Job job, int numRegions, int expectedNumS
for (int i = 0; i < splits.size(); i++) {
// validate input split
InputSplit split = splits.get(i);
- Assert.assertTrue(split instanceof TableSnapshotRegionSplit);
+ assertTrue(split instanceof TableSnapshotRegionSplit);
TableSnapshotRegionSplit snapshotRegionSplit = (TableSnapshotRegionSplit) split;
if (localityEnabled) {
- Assert.assertTrue(split.getLocations() != null && split.getLocations().length != 0);
+ assertTrue(split.getLocations() != null && split.getLocations().length != 0);
if (byRegionLoc) {
// When it uses region location from meta, the hostname will be "localhost",
// the location from hdfs block location is "127.0.0.1".
- Assert.assertEquals(1, split.getLocations().length);
- Assert.assertTrue("Not using region location!",
- split.getLocations()[0].equals("localhost"));
+ assertEquals(1, split.getLocations().length);
+ assertTrue(split.getLocations()[0].equals("localhost"), "Not using region location!");
} else {
- Assert.assertTrue("Not using region location!",
- split.getLocations()[0].equals("127.0.0.1"));
+ assertTrue(split.getLocations()[0].equals("127.0.0.1"), "Not using region location!");
}
} else {
- Assert.assertTrue(split.getLocations() != null && split.getLocations().length == 0);
+ assertTrue(split.getLocations() != null && split.getLocations().length == 0);
}
Scan scan =
TableMapReduceUtil.convertStringToScan(snapshotRegionSplit.getDelegate().getScan());
if (startRow.length > 0) {
- Assert.assertTrue(
- Bytes.toStringBinary(startRow) + " should <= " + Bytes.toStringBinary(scan.getStartRow()),
- Bytes.compareTo(startRow, scan.getStartRow()) <= 0);
+ assertTrue(Bytes.compareTo(startRow, scan.getStartRow()) <= 0,
+ Bytes.toStringBinary(startRow) + " should <= "
+ + Bytes.toStringBinary(scan.getStartRow()));
}
if (stopRow.length > 0) {
- Assert.assertTrue(
- Bytes.toStringBinary(stopRow) + " should >= " + Bytes.toStringBinary(scan.getStopRow()),
- Bytes.compareTo(stopRow, scan.getStopRow()) >= 0);
+ assertTrue(Bytes.compareTo(stopRow, scan.getStopRow()) >= 0,
+ Bytes.toStringBinary(stopRow) + " should >= " + Bytes.toStringBinary(scan.getStopRow()));
}
- Assert.assertTrue("startRow should < stopRow",
- Bytes.compareTo(scan.getStartRow(), scan.getStopRow()) < 0);
+ assertTrue(Bytes.compareTo(scan.getStartRow(), scan.getStopRow()) < 0,
+ "startRow should < stopRow");
// validate record reader
TaskAttemptContext taskAttemptContext = mock(TaskAttemptContext.class);
@@ -553,7 +549,7 @@ public static void doTestWithMapReduce(HBaseTestingUtility util, TableName table
job.setNumReduceTasks(1);
job.setOutputFormatClass(NullOutputFormat.class);
- Assert.assertTrue(job.waitForCompletion(true));
+ assertTrue(job.waitForCompletion(true));
} finally {
if (!shutdownCluster) {
util.getAdmin().deleteSnapshot(snapshotName);
@@ -580,9 +576,9 @@ public void testCleanRestoreDir() throws Exception {
FileSystem fs = workingDir.getFileSystem(job.getConfiguration());
Path restorePath =
new Path(job.getConfiguration().get("hbase.TableSnapshotInputFormat.restore.dir"));
- Assert.assertTrue(fs.exists(restorePath));
+ assertTrue(fs.exists(restorePath));
TableSnapshotInputFormat.cleanRestoreDir(job, snapshotName);
- Assert.assertFalse(fs.exists(restorePath));
+ assertFalse(fs.exists(restorePath));
}
/**
@@ -596,7 +592,7 @@ public void testCleanRestoreDir() throws Exception {
*/
@Test
public void testReadFromRestoredSnapshotViaMR() throws Exception {
- final TableName tableName = TableName.valueOf(name.getMethodName());
+ final TableName tableName = TableName.valueOf(name);
final String snapshotName = tableName + "_snapshot";
try {
if (UTIL.getAdmin().tableExists(tableName)) {
@@ -619,7 +615,7 @@ public void testReadFromRestoredSnapshotViaMR() throws Exception {
Path tempRestoreDir = UTIL.getDataTestDirOnTestFS("restore_" + snapshotName);
RestoreSnapshotHelper.copySnapshotForScanner(UTIL.getConfiguration(), fs, rootDir,
tempRestoreDir, snapshotName);
- Assert.assertTrue("Restore directory should exist", fs.exists(tempRestoreDir));
+ assertTrue(fs.exists(tempRestoreDir), "Restore directory should exist");
Job job = Job.getInstance(UTIL.getConfiguration());
job.setJarByClass(TestTableSnapshotInputFormat.class);
@@ -637,13 +633,12 @@ public void testReadFromRestoredSnapshotViaMR() throws Exception {
scan, TestTableSnapshotMapper.class, ImmutableBytesWritable.class, NullWritable.class, job,
false, false, TableSnapshotInputFormat.class);
TableMapReduceUtil.resetCacheConfig(conf);
- Assert.assertTrue(job.waitForCompletion(true));
- Assert.assertTrue(job.isSuccessful());
+ assertTrue(job.waitForCompletion(true));
+ assertTrue(job.isSuccessful());
// Now verify that job fails when restore directory is deleted
- Assert.assertTrue(fs.delete(tempRestoreDir, true));
- Assert.assertFalse("Restore directory should not exist after deletion",
- fs.exists(tempRestoreDir));
+ assertTrue(fs.delete(tempRestoreDir, true));
+ assertFalse(fs.exists(tempRestoreDir), "Restore directory should not exist after deletion");
Job failureJob = Job.getInstance(UTIL.getConfiguration());
failureJob.setJarByClass(TestTableSnapshotInputFormat.class);
TableMapReduceUtil.addDependencyJarsForClasses(failureJob.getConfiguration(),
@@ -662,12 +657,12 @@ public void testReadFromRestoredSnapshotViaMR() throws Exception {
TableSnapshotInputFormat.class);
TableMapReduceUtil.resetCacheConfig(failureConf);
- Assert.assertFalse("Restore directory should not exist before job execution",
- fs.exists(tempRestoreDir));
+ assertFalse(fs.exists(tempRestoreDir),
+ "Restore directory should not exist before job execution");
failureJob.waitForCompletion(true);
- Assert.assertFalse("Job should fail since the restored snapshot directory is deleted",
- failureJob.isSuccessful());
+ assertFalse(failureJob.isSuccessful(),
+ "Job should fail since the restored snapshot directory is deleted");
} finally {
try {
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableSplit.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableSplit.java
index c33f761d17e0..2d8797cc4b86 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableSplit.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableSplit.java
@@ -17,37 +17,28 @@
*/
package org.apache.hadoop.hbase.mapreduce;
-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.HashSet;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.testclassification.MapReduceTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.util.ReflectionUtils;
-import org.junit.Assert;
-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.Tag;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
-@Category({ MapReduceTests.class, SmallTests.class })
+@Tag(MapReduceTests.TAG)
+@Tag(SmallTests.TAG)
public class TestTableSplit {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestTableSplit.class);
-
- @Rule
- public TestName name = new TestName();
@Test
- public void testHashCode() {
- TableSplit split1 = new TableSplit(TableName.valueOf(name.getMethodName()),
+ public void testHashCode(TestInfo testInfo) {
+ TableSplit split1 = new TableSplit(TableName.valueOf(testInfo.getTestMethod().get().getName()),
"row-start".getBytes(), "row-end".getBytes(), "location");
- TableSplit split2 = new TableSplit(TableName.valueOf(name.getMethodName()),
+ TableSplit split2 = new TableSplit(TableName.valueOf(testInfo.getTestMethod().get().getName()),
"row-start".getBytes(), "row-end".getBytes(), "location");
assertEquals(split1, split2);
assertTrue(split1.hashCode() == split2.hashCode());
@@ -61,10 +52,10 @@ public void testHashCode() {
* length of region should not influence hashcode
*/
@Test
- public void testHashCode_length() {
- TableSplit split1 = new TableSplit(TableName.valueOf(name.getMethodName()),
+ public void testHashCode_length(TestInfo testInfo) {
+ TableSplit split1 = new TableSplit(TableName.valueOf(testInfo.getTestMethod().get().getName()),
"row-start".getBytes(), "row-end".getBytes(), "location", 1984);
- TableSplit split2 = new TableSplit(TableName.valueOf(name.getMethodName()),
+ TableSplit split2 = new TableSplit(TableName.valueOf(testInfo.getTestMethod().get().getName()),
"row-start".getBytes(), "row-end".getBytes(), "location", 1982);
assertEquals(split1, split2);
@@ -79,39 +70,40 @@ public void testHashCode_length() {
* Length of region need to be properly serialized.
*/
@Test
- public void testLengthIsSerialized() throws Exception {
- TableSplit split1 = new TableSplit(TableName.valueOf(name.getMethodName()),
+ public void testLengthIsSerialized(TestInfo testInfo) throws Exception {
+ TableSplit split1 = new TableSplit(TableName.valueOf(testInfo.getTestMethod().get().getName()),
"row-start".getBytes(), "row-end".getBytes(), "location", 666);
- TableSplit deserialized = new TableSplit(TableName.valueOf(name.getMethodName()),
- "row-start2".getBytes(), "row-end2".getBytes(), "location1");
+ TableSplit deserialized =
+ new TableSplit(TableName.valueOf(testInfo.getTestMethod().get().getName()),
+ "row-start2".getBytes(), "row-end2".getBytes(), "location1");
ReflectionUtils.copy(new Configuration(), split1, deserialized);
- Assert.assertEquals(666, deserialized.getLength());
+ assertEquals(666, deserialized.getLength());
}
@Test
- public void testToString() {
- TableSplit split = new TableSplit(TableName.valueOf(name.getMethodName()),
+ public void testToString(TestInfo testInfo) {
+ TableSplit split = new TableSplit(TableName.valueOf(testInfo.getTestMethod().get().getName()),
"row-start".getBytes(), "row-end".getBytes(), "location");
- String str = "Split(tablename=" + name.getMethodName() + ", startrow=row-start, "
- + "endrow=row-end, regionLocation=location, " + "regionname=)";
- Assert.assertEquals(str, split.toString());
+ String str = "Split(tablename=" + testInfo.getTestMethod().get().getName()
+ + ", startrow=row-start, " + "endrow=row-end, regionLocation=location, " + "regionname=)";
+ assertEquals(str, split.toString());
- split = new TableSplit(TableName.valueOf(name.getMethodName()), null, "row-start".getBytes(),
- "row-end".getBytes(), "location", "encoded-region-name", 1000L);
- str = "Split(tablename=" + name.getMethodName() + ", startrow=row-start, "
+ split = new TableSplit(TableName.valueOf(testInfo.getTestMethod().get().getName()), null,
+ "row-start".getBytes(), "row-end".getBytes(), "location", "encoded-region-name", 1000L);
+ str = "Split(tablename=" + testInfo.getTestMethod().get().getName() + ", startrow=row-start, "
+ "endrow=row-end, regionLocation=location, " + "regionname=encoded-region-name)";
- Assert.assertEquals(str, split.toString());
+ assertEquals(str, split.toString());
split = new TableSplit(null, null, null, null);
str = "Split(tablename=null, startrow=null, " + "endrow=null, regionLocation=null, "
+ "regionname=)";
- Assert.assertEquals(str, split.toString());
+ assertEquals(str, split.toString());
split = new TableSplit(null, null, null, null, null, null, 1000L);
str = "Split(tablename=null, startrow=null, " + "endrow=null, regionLocation=null, "
+ "regionname=null)";
- Assert.assertEquals(str, split.toString());
+ assertEquals(str, split.toString());
}
}
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTimeRangeMapRed.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTimeRangeMapRed.java
index 4a29eadb9c04..ae6c2a2052cf 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTimeRangeMapRed.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTimeRangeMapRed.java
@@ -17,6 +17,8 @@
*/
package org.apache.hadoop.hbase.mapreduce;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
@@ -29,7 +31,6 @@
import org.apache.hadoop.fs.FileUtil;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellUtil;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HTableDescriptor;
@@ -51,22 +52,18 @@
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.output.NullOutputFormat;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-@Category({ MapReduceTests.class, LargeTests.class })
+@Tag(MapReduceTests.TAG)
+@Tag(LargeTests.TAG)
public class TestTimeRangeMapRed {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestTimeRangeMapRed.class);
-
private final static Logger log = LoggerFactory.getLogger(TestTimeRangeMapRed.class);
private static final HBaseTestingUtility UTIL = new HBaseTestingUtility();
private Admin admin;
@@ -89,17 +86,17 @@ public class TestTimeRangeMapRed {
static final byte[] FAMILY_NAME = Bytes.toBytes("text");
static final byte[] COLUMN_NAME = Bytes.toBytes("input");
- @BeforeClass
+ @BeforeAll
public static void beforeClass() throws Exception {
UTIL.startMiniCluster();
}
- @AfterClass
+ @AfterAll
public static void afterClass() throws Exception {
UTIL.shutdownMiniCluster();
}
- @Before
+ @BeforeEach
public void before() throws Exception {
this.admin = UTIL.getAdmin();
}
@@ -199,8 +196,7 @@ private void verify(final Table table) throws IOException {
log.debug(Bytes.toString(r.getRow()) + "\t" + Bytes.toString(CellUtil.cloneFamily(kv))
+ "\t" + Bytes.toString(CellUtil.cloneQualifier(kv)) + "\t" + kv.getTimestamp() + "\t"
+ Bytes.toBoolean(CellUtil.cloneValue(kv)));
- org.junit.Assert.assertEquals(TIMESTAMP.get(kv.getTimestamp()),
- Bytes.toBoolean(CellUtil.cloneValue(kv)));
+ assertEquals(TIMESTAMP.get(kv.getTimestamp()), Bytes.toBoolean(CellUtil.cloneValue(kv)));
}
}
scanner.close();
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestWALInputFormat.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestWALInputFormat.java
index 70602a371668..edd04a25f30e 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestWALInputFormat.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestWALInputFormat.java
@@ -17,27 +17,32 @@
*/
package org.apache.hadoop.hbase.mapreduce;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.ArrayList;
import java.util.List;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.LocatedFileStatus;
import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
+import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.testclassification.MapReduceTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
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.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
-@Category({ MapReduceTests.class, SmallTests.class })
+@Tag(MapReduceTests.TAG)
+@Tag(SmallTests.TAG)
public class TestWALInputFormat {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestWALInputFormat.class);
+ private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
+
+ @BeforeAll
+ public static void setupClass() throws Exception {
+ TEST_UTIL.startMiniCluster();
+ TEST_UTIL.createWALRootDir();
+ }
/**
* Test the primitive start/end time filtering.
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestWALPlayer.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestWALPlayer.java
index 872b6971e89f..052ca6864183 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestWALPlayer.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestWALPlayer.java
@@ -21,9 +21,9 @@
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.MatcherAssert.assertThat;
-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 static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
@@ -39,7 +39,6 @@
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellUtil;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.KeyValue;
@@ -66,25 +65,20 @@
import org.apache.hadoop.mapreduce.Mapper;
import org.apache.hadoop.mapreduce.Mapper.Context;
import org.apache.hadoop.util.ToolRunner;
-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.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
/**
* Basic test for the WALPlayer M/R tool
*/
-@Category({ MapReduceTests.class, LargeTests.class })
-// TODO : Remove this in 3.0
+@Tag(MapReduceTests.TAG)
+@Tag(LargeTests.TAG)
public class TestWALPlayer {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestWALPlayer.class);
private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
private static MiniHBaseCluster cluster;
@@ -94,10 +88,7 @@ public class TestWALPlayer {
private static FileSystem logFs;
private static Configuration conf;
- @Rule
- public TestName name = new TestName();
-
- @BeforeClass
+ @BeforeAll
public static void beforeClass() throws Exception {
conf = TEST_UTIL.getConfiguration();
rootDir = TEST_UTIL.createRootDir();
@@ -107,7 +98,7 @@ public static void beforeClass() throws Exception {
cluster = TEST_UTIL.startMiniCluster();
}
- @AfterClass
+ @AfterAll
public static void afterClass() throws Exception {
TEST_UTIL.shutdownMiniCluster();
fs.delete(rootDir, true);
@@ -144,8 +135,8 @@ public void testPlayingRecoveredEdit() throws Exception {
* the resulting bulkloaded HFiles. See HBASE-27649
*/
@Test
- public void testWALPlayerBulkLoadWithOverriddenTimestamps() throws Exception {
- final TableName tableName = TableName.valueOf(name.getMethodName() + "1");
+ public void testWALPlayerBulkLoadWithOverriddenTimestamps(TestInfo testInfo) throws Exception {
+ final TableName tableName = TableName.valueOf(testInfo.getTestMethod().get().getName() + "1");
final byte[] family = Bytes.toBytes("family");
final byte[] column1 = Bytes.toBytes("c1");
final byte[] column2 = Bytes.toBytes("c2");
@@ -183,7 +174,7 @@ public void testWALPlayerBulkLoadWithOverriddenTimestamps() throws Exception {
HConstants.HREGION_LOGDIR_NAME).toString();
Configuration configuration = new Configuration(TEST_UTIL.getConfiguration());
- String outPath = "/tmp/" + name.getMethodName();
+ String outPath = "/tmp/" + testInfo.getTestMethod().get().getName();
configuration.set(WALPlayer.BULK_OUTPUT_CONF_KEY, outPath);
WALPlayer player = new WALPlayer(configuration);
@@ -214,9 +205,9 @@ public void testWALPlayerBulkLoadWithOverriddenTimestamps() throws Exception {
* Simple end-to-end test
*/
@Test
- public void testWALPlayer() throws Exception {
- final TableName tableName1 = TableName.valueOf(name.getMethodName() + "1");
- final TableName tableName2 = TableName.valueOf(name.getMethodName() + "2");
+ public void testWALPlayer(TestInfo testInfo) throws Exception {
+ final TableName tableName1 = TableName.valueOf(testInfo.getTestMethod().get().getName() + "1");
+ final TableName tableName2 = TableName.valueOf(testInfo.getTestMethod().get().getName() + "2");
final byte[] FAMILY = Bytes.toBytes("family");
final byte[] COLUMN1 = Bytes.toBytes("c1");
final byte[] COLUMN2 = Bytes.toBytes("c2");
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestWALRecordReader.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestWALRecordReader.java
index cfe67e087a11..e77d47efdb36 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestWALRecordReader.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestWALRecordReader.java
@@ -17,10 +17,11 @@
*/
package org.apache.hadoop.hbase.mapreduce;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import java.io.IOException;
import java.util.List;
@@ -30,7 +31,6 @@
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.Cell;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.KeyValue;
@@ -55,25 +55,21 @@
import org.apache.hadoop.hbase.wal.WALKeyImpl;
import org.apache.hadoop.mapreduce.InputSplit;
import org.apache.hadoop.mapreduce.MapReduceTestUtil;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* JUnit tests for the WALRecordReader
*/
-@Category({ MapReduceTests.class, MediumTests.class })
+@Tag(MapReduceTests.TAG)
+@Tag(MediumTests.TAG)
public class TestWALRecordReader {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestWALRecordReader.class);
-
private static final Logger LOG = LoggerFactory.getLogger(TestWALRecordReader.class);
private final static HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
private static Configuration conf;
@@ -101,14 +97,14 @@ private static String getServerName() {
return serverName.toString();
}
- @Before
+ @BeforeEach
public void setUp() throws Exception {
fs.delete(hbaseDir, true);
walFs.delete(walRootDir, true);
mvcc = new MultiVersionConcurrencyControl();
}
- @BeforeClass
+ @BeforeAll
public static void setUpBeforeClass() throws Exception {
// Make block sizes small.
conf = TEST_UTIL.getConfiguration();
@@ -125,7 +121,7 @@ public static void setUpBeforeClass() throws Exception {
logDir = new Path(walRootDir, HConstants.HREGION_LOGDIR_NAME);
}
- @AfterClass
+ @AfterAll
public static void tearDownAfterClass() throws Exception {
fs.delete(hbaseDir, true);
walFs.delete(walRootDir, true);
@@ -273,10 +269,8 @@ private void testSplit(InputSplit split, byte[]... columns) throws Exception {
!Bytes.equals(column, 0, column.length, cell.getQualifierArray(), cell.getQualifierOffset(),
cell.getQualifierLength())
) {
- assertTrue(
- "expected [" + Bytes.toString(column) + "], actual [" + Bytes.toString(
- cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength()) + "]",
- false);
+ fail("expected [" + Bytes.toString(column) + "], actual [" + Bytes.toString(
+ cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength()) + "]");
}
}
assertFalse(reader.nextKeyValue());
@@ -297,10 +291,8 @@ private void testSplitWithMovingWAL(InputSplit split, byte[] col1, byte[] col2)
!Bytes.equals(col1, 0, col1.length, cell.getQualifierArray(), cell.getQualifierOffset(),
cell.getQualifierLength())
) {
- assertTrue(
- "expected [" + Bytes.toString(col1) + "], actual [" + Bytes.toString(
- cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength()) + "]",
- false);
+ fail("expected [" + Bytes.toString(col1) + "], actual [" + Bytes.toString(
+ cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength()) + "]");
}
// Move log file to archive directory
// While WAL record reader is open
@@ -321,10 +313,8 @@ private void testSplitWithMovingWAL(InputSplit split, byte[] col1, byte[] col2)
!Bytes.equals(col2, 0, col2.length, cell.getQualifierArray(), cell.getQualifierOffset(),
cell.getQualifierLength())
) {
- assertTrue(
- "expected [" + Bytes.toString(col2) + "], actual [" + Bytes.toString(
- cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength()) + "]",
- false);
+ fail("expected [" + Bytes.toString(col2) + "], actual [" + Bytes.toString(
+ cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength()) + "]");
}
reader.close();
}
@@ -334,5 +324,4 @@ private Path getWALArchiveDir(Configuration conf) throws IOException {
String archiveDir = AbstractFSWALProvider.getWALArchiveDirectoryName(conf, getServerName());
return new Path(rootDir, archiveDir);
}
-
}
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/regionserver/TestCompactionTool.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/regionserver/TestCompactionTool.java
index 71614a292779..cb37d7e0b034 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/regionserver/TestCompactionTool.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/regionserver/TestCompactionTool.java
@@ -17,13 +17,12 @@
*/
package org.apache.hadoop.hbase.regionserver;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.TableName;
@@ -33,19 +32,15 @@
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.CommonFSUtils;
import org.apache.hadoop.util.ToolRunner;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
-@Category({ MediumTests.class, RegionServerTests.class })
+@Tag(MediumTests.TAG)
+@Tag(RegionServerTests.TAG)
public class TestCompactionTool {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestCompactionTool.class);
-
private final HBaseTestingUtility testUtil = new HBaseTestingUtility();
private HRegion region;
@@ -53,7 +48,7 @@ public class TestCompactionTool {
private Path rootDir;
private final TableName tableName = TableName.valueOf(getClass().getSimpleName());
- @Before
+ @BeforeEach
public void setUp() throws Exception {
this.testUtil.startMiniCluster();
testUtil.createTable(tableName, HBaseTestingUtility.fam1);
@@ -61,7 +56,7 @@ public void setUp() throws Exception {
this.region = testUtil.getMiniHBaseCluster().getRegions(tableName).get(0);
}
- @After
+ @AfterEach
public void tearDown() throws Exception {
this.testUtil.shutdownMiniCluster();
testUtil.cleanupTestDir();
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/regionserver/TestCompactionToolNpeFix.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/regionserver/TestCompactionToolNpeFix.java
index ce711ff7a6cd..02356d5ce5b8 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/regionserver/TestCompactionToolNpeFix.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/regionserver/TestCompactionToolNpeFix.java
@@ -17,14 +17,13 @@
*/
package org.apache.hadoop.hbase.regionserver;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.IOException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.TableName;
@@ -34,21 +33,17 @@
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.CommonFSUtils;
import org.apache.hadoop.util.ToolRunner;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-@Category({ MediumTests.class, RegionServerTests.class })
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+
+@Tag(MediumTests.TAG)
+@Tag(RegionServerTests.TAG)
public class TestCompactionToolNpeFix {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestCompactionToolNpeFix.class);
-
private static final HBaseTestingUtility TESTUTIL = new HBaseTestingUtility();
private HRegion region;
@@ -56,7 +51,7 @@ public class TestCompactionToolNpeFix {
private static Path rootDir;
private final TableName tableName = TableName.valueOf(getClass().getSimpleName());
- @BeforeClass
+ @BeforeAll
public static void setUpAfterClass() throws Exception {
TESTUTIL.getConfiguration().setBoolean(MemStoreLAB.USEMSLAB_KEY, false);
TESTUTIL.startMiniCluster();
@@ -65,7 +60,7 @@ public static void setUpAfterClass() throws Exception {
}
- @AfterClass
+ @AfterAll
public static void tearDown() throws Exception {
TESTUTIL.shutdownMiniMapReduceCluster();
TESTUTIL.shutdownMiniCluster();
@@ -73,13 +68,13 @@ public static void tearDown() throws Exception {
}
- @Before
+ @BeforeEach
public void setUp() throws IOException {
TESTUTIL.createTable(tableName, HBaseTestingUtility.fam1);
this.region = TESTUTIL.getMiniHBaseCluster().getRegions(tableName).get(0);
}
- @After
+ @AfterEach
public void after() throws IOException {
TESTUTIL.deleteTable(tableName);
}
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/replication/TestVerifyReplication.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/replication/TestVerifyReplication.java
index 4ccba1578d9a..fec86c4b263b 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/replication/TestVerifyReplication.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/replication/TestVerifyReplication.java
@@ -17,11 +17,11 @@
*/
package org.apache.hadoop.hbase.replication;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-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.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import java.io.IOException;
import java.util.ArrayList;
@@ -32,7 +32,6 @@
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellUtil;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.TableName;
@@ -58,42 +57,33 @@
import org.apache.hadoop.hbase.util.CommonFSUtils;
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
import org.apache.hadoop.mapreduce.Job;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.rules.TestName;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-@Category({ ReplicationTests.class, LargeTests.class })
+@Tag(ReplicationTests.TAG)
+@Tag(LargeTests.TAG)
public class TestVerifyReplication extends TestReplicationBase {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestVerifyReplication.class);
-
private static final Logger LOG = LoggerFactory.getLogger(TestVerifyReplication.class);
private static final String PEER_ID = "2";
private static final TableName peerTableName = TableName.valueOf("peerTest");
private static Table htable3;
- @Rule
- public TestName name = new TestName();
-
- @Before
+ @BeforeEach
public void setUp() throws Exception {
cleanUp();
UTIL2.deleteTableData(peerTableName);
}
- @BeforeClass
+ @BeforeAll
public static void setUpBeforeClass() throws Exception {
- TestReplicationBase.setUpBeforeClass();
TableDescriptor peerTable =
TableDescriptorBuilder.newBuilder(peerTableName)
@@ -157,10 +147,10 @@ public void testVerifyRepJob() throws Exception {
* delete marker is replicated, run verify replication with and without raw to check the results.
*/
@Test
- public void testVerifyRepJobWithRawOptions() throws Exception {
- LOG.info(name.getMethodName());
+ public void testVerifyRepJobWithRawOptions(TestInfo testInfo) throws Exception {
+ LOG.info(testInfo.getTestMethod().get().getName());
- final TableName tableName = TableName.valueOf(name.getMethodName());
+ final TableName tableName = TableName.valueOf(testInfo.getTestMethod().get().getName());
byte[] familyname = Bytes.toBytes("fam_raw");
byte[] row = Bytes.toBytes("row_raw");
@@ -447,7 +437,7 @@ public void testVerifyRepJobWithPeerTableNameAndSnapshotSupport() throws Excepti
checkRestoreTmpDir(CONF2, tmpPath2, 2);
}
- @AfterClass
+ @AfterAll
public static void tearDownAfterClass() throws Exception {
htable3.close();
TestReplicationBase.tearDownAfterClass();
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/replication/TestVerifyReplicationAdjunct.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/replication/TestVerifyReplicationAdjunct.java
index 1a715392b275..077660aec0e4 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/replication/TestVerifyReplicationAdjunct.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/replication/TestVerifyReplicationAdjunct.java
@@ -17,16 +17,15 @@
*/
package org.apache.hadoop.hbase.replication;
-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 org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellUtil;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Admin;
@@ -48,14 +47,11 @@
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.CommonFSUtils;
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.rules.TestName;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -65,31 +61,24 @@
* We moved some of {@link TestVerifyReplication}'s tests here because it could take too long to
* complete. In here we have miscellaneous.
*/
-@Category({ ReplicationTests.class, LargeTests.class })
+@Tag(ReplicationTests.TAG)
+@Tag(LargeTests.TAG)
public class TestVerifyReplicationAdjunct extends TestReplicationBase {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestVerifyReplicationAdjunct.class);
-
private static final Logger LOG = LoggerFactory.getLogger(TestVerifyReplicationAdjunct.class);
private static final String PEER_ID = "2";
private static final TableName peerTableName = TableName.valueOf("peerTest");
private static Table htable3;
- @Rule
- public TestName name = new TestName();
-
- @Before
+ @BeforeEach
public void setUp() throws Exception {
cleanUp();
UTIL2.deleteTableData(peerTableName);
}
- @BeforeClass
+ @BeforeAll
public static void setUpBeforeClass() throws Exception {
- TestReplicationBase.setUpBeforeClass();
TableDescriptor peerTable =
TableDescriptorBuilder.newBuilder(peerTableName)
.setColumnFamily(
@@ -253,31 +242,31 @@ public void testVerifyReplicationPrefixFiltering() throws Exception {
public void testVerifyReplicationSnapshotArguments() {
String[] args =
new String[] { "--sourceSnapshotName=snapshot1", "2", tableName.getNameAsString() };
- assertFalse(Lists.newArrayList(args).toString(), new VerifyReplication().doCommandLine(args));
+ assertFalse(new VerifyReplication().doCommandLine(args), Lists.newArrayList(args).toString());
args = new String[] { "--sourceSnapshotTmpDir=tmp", "2", tableName.getNameAsString() };
- assertFalse(Lists.newArrayList(args).toString(), new VerifyReplication().doCommandLine(args));
+ assertFalse(new VerifyReplication().doCommandLine(args), Lists.newArrayList(args).toString());
args = new String[] { "--sourceSnapshotName=snapshot1", "--sourceSnapshotTmpDir=tmp", "2",
tableName.getNameAsString() };
- assertTrue(Lists.newArrayList(args).toString(), new VerifyReplication().doCommandLine(args));
+ assertTrue(new VerifyReplication().doCommandLine(args), Lists.newArrayList(args).toString());
args = new String[] { "--peerSnapshotName=snapshot1", "2", tableName.getNameAsString() };
- assertFalse(Lists.newArrayList(args).toString(), new VerifyReplication().doCommandLine(args));
+ assertFalse(new VerifyReplication().doCommandLine(args), Lists.newArrayList(args).toString());
args = new String[] { "--peerSnapshotTmpDir=/tmp/", "2", tableName.getNameAsString() };
- assertFalse(Lists.newArrayList(args).toString(), new VerifyReplication().doCommandLine(args));
+ assertFalse(new VerifyReplication().doCommandLine(args), Lists.newArrayList(args).toString());
args = new String[] { "--peerSnapshotName=snapshot1", "--peerSnapshotTmpDir=/tmp/",
"--peerFSAddress=tempfs", "--peerHBaseRootAddress=hdfs://tempfs:50070/hbase/", "2",
tableName.getNameAsString() };
- assertTrue(Lists.newArrayList(args).toString(), new VerifyReplication().doCommandLine(args));
+ assertTrue(new VerifyReplication().doCommandLine(args), Lists.newArrayList(args).toString());
args = new String[] { "--sourceSnapshotName=snapshot1", "--sourceSnapshotTmpDir=/tmp/",
"--peerSnapshotName=snapshot2", "--peerSnapshotTmpDir=/tmp/", "--peerFSAddress=tempfs",
"--peerHBaseRootAddress=hdfs://tempfs:50070/hbase/", "2", tableName.getNameAsString() };
- assertTrue(Lists.newArrayList(args).toString(), new VerifyReplication().doCommandLine(args));
+ assertTrue(new VerifyReplication().doCommandLine(args), Lists.newArrayList(args).toString());
}
@Test
@@ -344,9 +333,8 @@ public void testVerifyReplicationWithSnapshotSupport() throws Exception {
TestVerifyReplication.checkRestoreTmpDir(CONF2, temPath2, 2);
}
- @AfterClass
+ @AfterAll
public static void tearDownAfterClass() throws Exception {
htable3.close();
- TestReplicationBase.tearDownAfterClass();
}
}
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/replication/TestVerifyReplicationCrossDiffHdfs.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/replication/TestVerifyReplicationCrossDiffHdfs.java
index 2d83eac77625..13f090deda8c 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/replication/TestVerifyReplicationCrossDiffHdfs.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/replication/TestVerifyReplicationCrossDiffHdfs.java
@@ -17,14 +17,13 @@
*/
package org.apache.hadoop.hbase.replication;
-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.IOException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HConstants;
@@ -47,23 +46,20 @@
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
import org.apache.hadoop.hbase.zookeeper.MiniZooKeeperCluster;
import org.apache.hadoop.mapreduce.Job;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.hbase.thirdparty.com.google.common.collect.ImmutableList;
import org.apache.hbase.thirdparty.com.google.common.collect.ImmutableMap;
-@Category({ ReplicationTests.class, LargeTests.class })
+@Tag(ReplicationTests.TAG)
+@Tag(LargeTests.TAG)
public class TestVerifyReplicationCrossDiffHdfs {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestVerifyReplicationCrossDiffHdfs.class);
private static final Logger LOG =
LoggerFactory.getLogger(TestVerifyReplicationCrossDiffHdfs.class);
@@ -80,7 +76,7 @@ public class TestVerifyReplicationCrossDiffHdfs {
private static final String PEER_ID = "1";
private static final TableName TABLE_NAME = TableName.valueOf("testVerifyRepCrossDiffHDFS");
- @BeforeClass
+ @BeforeAll
public static void setUpBeforeClass() throws Exception {
conf1.set(HConstants.ZOOKEEPER_ZNODE_PARENT, "/1");
util1 = new HBaseTestingUtility(conf1);
@@ -144,11 +140,11 @@ private static void loadSomeData() throws IOException, InterruptedException {
}
}
}
- Assert.assertNotNull(results);
- Assert.assertEquals(10, results.length);
+ Assertions.assertNotNull(results);
+ Assertions.assertEquals(10, results.length);
}
- @AfterClass
+ @AfterAll
public static void tearDownClass() throws Exception {
if (mapReduceUtil != null) {
mapReduceUtil.shutdownMiniCluster();
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/replication/TestVerifyReplicationSecureClusterCredentials.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/replication/TestVerifyReplicationSecureClusterCredentials.java
index 48da7a05d603..19d02f0696b9 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/replication/TestVerifyReplicationSecureClusterCredentials.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/replication/TestVerifyReplicationSecureClusterCredentials.java
@@ -17,7 +17,7 @@
*/
package org.apache.hadoop.hbase.replication;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.File;
import java.io.IOException;
@@ -25,7 +25,6 @@
import java.util.Collection;
import java.util.function.Supplier;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.client.Admin;
import org.apache.hadoop.hbase.coprocessor.CoprocessorHost;
@@ -47,22 +46,15 @@
import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.security.token.Token;
import org.apache.hadoop.security.token.TokenIdentifier;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameter;
-import org.junit.runners.Parameterized.Parameters;
-
-@Category({ ReplicationTests.class, LargeTests.class })
-@RunWith(Parameterized.class)
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
+
+@Tag(ReplicationTests.TAG)
+@Tag(LargeTests.TAG)
public class TestVerifyReplicationSecureClusterCredentials {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestVerifyReplicationSecureClusterCredentials.class);
private static MiniKdc KDC;
private static final HBaseTestingUtility UTIL1 = new HBaseTestingUtility();
@@ -105,7 +97,7 @@ private static void setupCluster(HBaseTestingUtility util) throws Exception {
/**
* Sets the security firstly for getting the correct default realm.
*/
- @BeforeClass
+ @BeforeAll
public static void beforeClass() throws Exception {
setUpKdcServer();
setupCluster(UTIL1);
@@ -123,24 +115,21 @@ public static void beforeClass() throws Exception {
}
}
- @AfterClass
+ @AfterAll
public static void cleanup() throws IOException {
UTIL1.shutdownMiniCluster();
UTIL2.shutdownMiniCluster();
}
- @Parameters
public static Collection> peer() {
return Arrays.asList(() -> "1",
() -> ZKConfig.getZooKeeperClusterKey(UTIL2.getConfiguration()));
}
- @Parameter
- public Supplier peer;
-
- @Test
+ @ParameterizedTest
+ @MethodSource("peer")
@SuppressWarnings("unchecked")
- public void testJobCredentials() throws Exception {
+ public void testJobCredentials(Supplier peer) throws Exception {
Job job = new VerifyReplication().createSubmittableJob(
new Configuration(UTIL1.getConfiguration()), new String[] { peer.get(), "table" });
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/snapshot/TestExportSnapshotV2NoCluster.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/snapshot/TestExportSnapshotV2NoCluster.java
index 98ec2263949e..ec9f0524816c 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/snapshot/TestExportSnapshotV2NoCluster.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/snapshot/TestExportSnapshotV2NoCluster.java
@@ -39,6 +39,7 @@
@Tag(MapReduceTests.TAG)
@Tag(SmallTests.TAG)
public class TestExportSnapshotV2NoCluster {
+
private static final Logger LOG = LoggerFactory.getLogger(TestExportSnapshotV2NoCluster.class);
private HBaseCommonTestingUtility testUtil = new HBaseCommonTestingUtility();
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationBase.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationBase.java
index b021dcbc0d40..e87e13d151b9 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationBase.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationBase.java
@@ -53,6 +53,9 @@
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -265,6 +268,7 @@ private static void startClusters() throws Exception {
htable2 = connection2.getTable(tableName);
}
+ @BeforeAll
@BeforeClass
public static void setUpBeforeClass() throws Exception {
configureClusters(UTIL1, UTIL2);
@@ -296,6 +300,7 @@ protected final void addPeer(String peerId, TableName tableName, HBaseTestingUti
}
@Before
+ @BeforeEach
public void setUpBase() throws Exception {
addPeer(PEER_ID2, tableName);
}
@@ -311,6 +316,7 @@ protected final void removePeer(String peerId, HBaseTestingUtility util) throws
}
@After
+ @AfterEach
public void tearDownBase() throws Exception {
removePeer(PEER_ID2);
}