diff --git a/hbase-http/src/test/java/org/apache/hadoop/hbase/http/TestHttpServer.java b/hbase-http/src/test/java/org/apache/hadoop/hbase/http/TestHttpServer.java index 7091a2ac7014..4f1bd7f111af 100644 --- a/hbase-http/src/test/java/org/apache/hadoop/hbase/http/TestHttpServer.java +++ b/hbase-http/src/test/java/org/apache/hadoop/hbase/http/TestHttpServer.java @@ -17,6 +17,7 @@ */ package org.apache.hadoop.hbase.http; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.greaterThan; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; @@ -73,7 +74,6 @@ import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; -import org.hamcrest.MatcherAssert; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Disabled; @@ -297,7 +297,7 @@ public void testNegotiatesEncodingGzip() throws IOException { assertNotNull(entity); assertNull(entity.getContentEncoding()); unencodedContentLength = entity.getContentLength(); - MatcherAssert.assertThat(unencodedContentLength, greaterThan(0L)); + assertThat(unencodedContentLength, greaterThan(0L)); final String unencodedEntityBody = readFully(entity.getContent()); assertEquals(sourceContent, unencodedEntityBody); } @@ -310,13 +310,13 @@ public void testNegotiatesEncodingGzip() throws IOException { assertNotNull(entity.getContentEncoding()); assertEquals("gzip", entity.getContentEncoding().getValue()); encodedContentLength = entity.getContentLength(); - MatcherAssert.assertThat(encodedContentLength, greaterThan(0L)); + assertThat(encodedContentLength, greaterThan(0L)); final String encodedEntityBody = readFully(entity.getContent()); // the encoding/decoding process, as implemented in this specific combination of dependency // versions, does not perfectly preserve trailing whitespace. thus, `trim()`. assertEquals(sourceContent.trim(), encodedEntityBody.trim()); } - MatcherAssert.assertThat(unencodedContentLength, greaterThan(encodedContentLength)); + assertThat(unencodedContentLength, greaterThan(encodedContentLength)); } } diff --git a/hbase-it/src/test/java/org/apache/hadoop/hbase/test/IntegrationTestBigLinkedList.java b/hbase-it/src/test/java/org/apache/hadoop/hbase/test/IntegrationTestBigLinkedList.java index b47d60c3cc3b..38bacdafb04c 100644 --- a/hbase-it/src/test/java/org/apache/hadoop/hbase/test/IntegrationTestBigLinkedList.java +++ b/hbase-it/src/test/java/org/apache/hadoop/hbase/test/IntegrationTestBigLinkedList.java @@ -17,6 +17,8 @@ */ package org.apache.hadoop.hbase.test; +import static org.junit.jupiter.api.Assertions.assertEquals; + import java.io.DataInput; import java.io.DataOutput; import java.io.FileNotFoundException; @@ -1859,7 +1861,7 @@ public void testContinuousIngest() throws IOException, Exception { } int ret = ToolRunner.run(conf, new Loop(), new String[] { "1", "1", "2000000", util.getDataTestDirOnTestFS("IntegrationTestBigLinkedList").toString(), "1" }); - org.junit.jupiter.api.Assertions.assertEquals(0, ret); + assertEquals(0, ret); } private void usage() { diff --git a/hbase-it/src/test/java/org/apache/hadoop/hbase/test/IntegrationTestBigLinkedListWithVisibility.java b/hbase-it/src/test/java/org/apache/hadoop/hbase/test/IntegrationTestBigLinkedListWithVisibility.java index 625d55e83bd3..21306d9964e3 100644 --- a/hbase-it/src/test/java/org/apache/hadoop/hbase/test/IntegrationTestBigLinkedListWithVisibility.java +++ b/hbase-it/src/test/java/org/apache/hadoop/hbase/test/IntegrationTestBigLinkedListWithVisibility.java @@ -17,6 +17,8 @@ */ package org.apache.hadoop.hbase.test; +import static org.junit.jupiter.api.Assertions.assertEquals; + import java.io.IOException; import java.security.PrivilegedExceptionAction; import java.util.Arrays; @@ -631,7 +633,7 @@ public void testContinuousIngest() throws IOException, Exception { new String[] { "1", "1", "20000", util.getDataTestDirOnTestFS("IntegrationTestBigLinkedListWithVisibility").toString(), "1", "10000" }); - org.junit.jupiter.api.Assertions.assertEquals(0, ret); + assertEquals(0, ret); } public static void main(String[] args) throws Exception { 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 13f090deda8c..00cc6020cb2f 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 @@ -18,6 +18,7 @@ package org.apache.hadoop.hbase.replication; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.fail; import java.io.IOException; @@ -47,7 +48,6 @@ import org.apache.hadoop.hbase.zookeeper.MiniZooKeeperCluster; import org.apache.hadoop.mapreduce.Job; 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; @@ -140,8 +140,8 @@ private static void loadSomeData() throws IOException, InterruptedException { } } } - Assertions.assertNotNull(results); - Assertions.assertEquals(10, results.length); + assertNotNull(results); + assertEquals(10, results.length); } @AfterAll diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/TestIPv6NIOServerSocketChannel.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/TestIPv6NIOServerSocketChannel.java index 4a04c8cc0e4e..5c5d7653cd5d 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/TestIPv6NIOServerSocketChannel.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/TestIPv6NIOServerSocketChannel.java @@ -17,6 +17,10 @@ */ package org.apache.hadoop.hbase; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.io.IOException; import java.net.BindException; import java.net.InetAddress; @@ -26,7 +30,6 @@ import java.util.Locale; import org.apache.hadoop.hbase.testclassification.MiscTests; import org.apache.hadoop.hbase.testclassification.SmallTests; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.slf4j.Logger; @@ -116,8 +119,8 @@ public void testServerSocket() throws IOException { // On Windows JDK6, we will get expected exception: // java.net.SocketException: Address family not supported by protocol family // or java.net.SocketException: Protocol family not supported - Assertions.assertFalse(ex instanceof BindException); - Assertions.assertTrue(ex.getMessage().toLowerCase(Locale.ROOT).contains("protocol family")); + assertFalse(ex instanceof BindException); + assertTrue(ex.getMessage().toLowerCase(Locale.ROOT).contains("protocol family")); LOG.info("Received expected exception:", ex); // if this is the case, ensure that we are running on preferIPv4=true @@ -132,7 +135,7 @@ public void ensurePreferIPv4() throws IOException { InetAddress[] addrs = InetAddress.getAllByName("localhost"); for (InetAddress addr : addrs) { LOG.info("resolved localhost as:" + addr); - Assertions.assertEquals(4, addr.getAddress().length); // ensure 4 byte ipv4 address + assertEquals(4, addr.getAddress().length); // ensure 4 byte ipv4 address } } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/TestJMXConnectorServer.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/TestJMXConnectorServer.java index b773d2c4392c..f7f927b1dd65 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/TestJMXConnectorServer.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/TestJMXConnectorServer.java @@ -17,6 +17,10 @@ */ package org.apache.hadoop.hbase; +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 javax.management.remote.JMXConnector; import javax.management.remote.JMXConnectorFactory; @@ -33,7 +37,6 @@ import org.apache.hadoop.hbase.testclassification.MiscTests; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; @@ -101,7 +104,7 @@ public void testHMConnectorServerWhenStopMaster() throws Exception { LOG.info("Exception occurred while stopping HMaster. ", e); accessDenied = true; } - Assertions.assertTrue(accessDenied); + assertTrue(accessDenied); checkConnector(); } @@ -132,7 +135,7 @@ public void testHMConnectorServerWhenShutdownCluster() throws Exception { LOG.error("Exception occurred while stopping HMaster. ", e); accessDenied = true; } - Assertions.assertTrue(accessDenied); + assertTrue(accessDenied); checkConnector(); } @@ -145,10 +148,10 @@ private void checkConnector() throws Exception { .connect(JMXListener.buildJMXServiceURL(rmiRegistryPort, rmiRegistryPort)); } catch (IOException e) { if (e.getCause() instanceof ServiceUnavailableException) { - Assertions.fail("Can't connect to ConnectorServer."); + fail("Can't connect to ConnectorServer."); } } - Assertions.assertNotNull(connector, "JMXConnector should not be null."); + assertNotNull(connector, "JMXConnector should not be null."); connector.close(); } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/TestJMXListener.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/TestJMXListener.java index 6f43c7376808..376dc8ae3774 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/TestJMXListener.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/TestJMXListener.java @@ -18,6 +18,7 @@ package org.apache.hadoop.hbase; 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.IOException; @@ -31,7 +32,6 @@ import org.apache.hadoop.hbase.testclassification.MiscTests; import org.apache.hadoop.hbase.util.JVMClusterUtil; 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; @@ -96,7 +96,7 @@ public void testStart() throws Exception { MBeanServerConnection mb = connector.getMBeanServerConnection(); String domain = mb.getDefaultDomain(); - Assertions.assertTrue(!domain.isEmpty(), "default domain is not correct"); + assertTrue(!domain.isEmpty(), "default domain is not correct"); connector.close(); } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/TimestampTestBase.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/TimestampTestBase.java index 5970a144f610..1799cc544ba8 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/TimestampTestBase.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/TimestampTestBase.java @@ -17,6 +17,8 @@ */ package org.apache.hadoop.hbase; +import static org.junit.jupiter.api.Assertions.assertEquals; + import java.io.IOException; import org.apache.hadoop.hbase.client.Delete; import org.apache.hadoop.hbase.client.Durability; @@ -27,7 +29,6 @@ import org.apache.hadoop.hbase.client.Scan; import org.apache.hadoop.hbase.client.Table; import org.apache.hadoop.hbase.util.Bytes; -import org.junit.jupiter.api.Assertions; /** * Tests user specifiable time stamps putting, getting and scanning. Also tests same in presence of @@ -104,9 +105,9 @@ private static void assertOnlyLatest(final Table incommon, final long currentTim get.addColumn(FAMILY_NAME, QUALIFIER_NAME); get.setMaxVersions(3); Result result = incommon.get(get); - Assertions.assertEquals(1, result.size()); + assertEquals(1, result.size()); long time = Bytes.toLong(CellUtil.cloneValue(result.rawCells()[0])); - Assertions.assertEquals(time, currentTime); + assertEquals(time, currentTime); } /* @@ -122,7 +123,7 @@ public static void assertVersions(final Table incommon, final long[] tss) throws Result r = incommon.get(get); byte[] bytes = r.getValue(FAMILY_NAME, QUALIFIER_NAME); long t = Bytes.toLong(bytes); - Assertions.assertEquals(tss[0], t); + assertEquals(tss[0], t); // Now assert that if we ask for multiple versions, that they come out in // order. @@ -131,10 +132,10 @@ public static void assertVersions(final Table incommon, final long[] tss) throws get.setMaxVersions(tss.length); Result result = incommon.get(get); Cell[] kvs = result.rawCells(); - Assertions.assertEquals(kvs.length, tss.length); + assertEquals(kvs.length, tss.length); for (int i = 0; i < kvs.length; i++) { t = Bytes.toLong(CellUtil.cloneValue(kvs[i])); - Assertions.assertEquals(tss[i], t); + assertEquals(tss[i], t); } // Determine highest stamp to set as next max stamp @@ -147,10 +148,10 @@ public static void assertVersions(final Table incommon, final long[] tss) throws get.setMaxVersions(kvs.length - 1); result = incommon.get(get); kvs = result.rawCells(); - Assertions.assertEquals(kvs.length, tss.length - 1); + assertEquals(kvs.length, tss.length - 1); for (int i = 1; i < kvs.length; i++) { t = Bytes.toLong(CellUtil.cloneValue(kvs[i - 1])); - Assertions.assertEquals(tss[i], t); + assertEquals(tss[i], t); } // Test scanner returns expected version @@ -169,12 +170,12 @@ public static void doTestTimestampScanning(final Table incommon, final FlushCach // Get count of latest items. int count = assertScanContentTimestamp(incommon, HConstants.LATEST_TIMESTAMP); // Assert I get same count when I scan at each timestamp. - Assertions.assertEquals(count, assertScanContentTimestamp(incommon, T0)); - Assertions.assertEquals(count, assertScanContentTimestamp(incommon, T1)); + assertEquals(count, assertScanContentTimestamp(incommon, T0)); + assertEquals(count, assertScanContentTimestamp(incommon, T1)); // Flush everything out to disk and then retry flusher.flushcache(); - Assertions.assertEquals(count, assertScanContentTimestamp(incommon, T0)); - Assertions.assertEquals(count, assertScanContentTimestamp(incommon, T1)); + assertEquals(count, assertScanContentTimestamp(incommon, T0)); + assertEquals(count, assertScanContentTimestamp(incommon, T1)); } /* diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestRpcExecutor.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestRpcExecutor.java index 533aa7bd6638..2d6a092b590b 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestRpcExecutor.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestRpcExecutor.java @@ -21,6 +21,7 @@ import static org.apache.hadoop.hbase.ipc.RpcExecutor.DEFAULT_CALL_QUEUE_HANDLER_FACTOR; import static org.apache.hadoop.hbase.ipc.RpcExecutor.DEFAULT_CALL_QUEUE_SIZE_HARD_LIMIT; import static org.apache.hadoop.hbase.ipc.RpcServer.DEFAULT_MAX_CALLQUEUE_LENGTH_PER_HANDLER; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.Mockito.mock; import java.util.List; @@ -29,7 +30,6 @@ import org.apache.hadoop.hbase.HBaseConfiguration; import org.apache.hadoop.hbase.testclassification.MediumTests; import org.apache.hadoop.hbase.testclassification.RPCTests; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; @@ -63,19 +63,19 @@ public void testDefaultQueueLimits(TestInfo testInfo) { List> queues = executor.getQueues(); int expectedQueueSize = Math.round(handlerCount * DEFAULT_CALL_QUEUE_HANDLER_FACTOR); - Assertions.assertEquals(expectedQueueSize, queues.size(), + assertEquals(expectedQueueSize, queues.size(), "Number of queues should be according to default callQueueHandlerFactor"); // By default, the soft limit depends on number of handler the queue will serve int expectedSoftLimit = (handlerCount / expectedQueueSize) * DEFAULT_MAX_CALLQUEUE_LENGTH_PER_HANDLER; - Assertions.assertEquals(expectedSoftLimit, executor.currentQueueLimit, + assertEquals(expectedSoftLimit, executor.currentQueueLimit, "Soft limit of queues is wrongly calculated"); // Hard limit should be maximum of softLimit and DEFAULT_CALL_QUEUE_SIZE_HARD_LIMIT int hardQueueLimit = queues.get(0).remainingCapacity() + queues.get(0).size(); int expectedHardLimit = Math.max(expectedSoftLimit, DEFAULT_CALL_QUEUE_SIZE_HARD_LIMIT); - Assertions.assertEquals(expectedHardLimit, hardQueueLimit, + assertEquals(expectedHardLimit, hardQueueLimit, "Default hard limit of queues is wrongly calculated "); } @@ -94,17 +94,17 @@ public void testConfiguredQueueLimits(TestInfo testInfo) { new BalancedQueueRpcExecutor(testInfo.getTestMethod().get().getName() + "1", handlerCount, maxQueueLength, qosFunction, conf, null); - Assertions.assertEquals(maxQueueLength, executor.currentQueueLimit, + assertEquals(maxQueueLength, executor.currentQueueLimit, "Configured soft limit is not applied."); List> queues1 = executor.getQueues(); int expectedQueueSize = Math.round(handlerCount * callQueueHandlerFactor); - Assertions.assertEquals(expectedQueueSize, queues1.size(), + assertEquals(expectedQueueSize, queues1.size(), "Number of queues should be according to callQueueHandlerFactor"); int hardQueueLimit1 = queues1.get(0).remainingCapacity() + queues1.get(0).size(); - Assertions.assertEquals(DEFAULT_CALL_QUEUE_SIZE_HARD_LIMIT, hardQueueLimit1, + assertEquals(DEFAULT_CALL_QUEUE_SIZE_HARD_LIMIT, hardQueueLimit1, "Default Hard limit is not applied"); } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestRogueRSAssignment.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestRogueRSAssignment.java index 0bdb55132558..1869a2979a02 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestRogueRSAssignment.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestRogueRSAssignment.java @@ -17,8 +17,9 @@ */ package org.apache.hadoop.hbase.master.assignment; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.Is.isA; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertInstanceOf; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertThrows; @@ -155,7 +156,7 @@ public void testReportRSWithWrongRegion() throws Exception { // TODO: replace YouAreDeadException with appropriate exception as and when necessary ServiceException exception = assertThrows(ServiceException.class, () -> master.getMasterRpcServices().regionServerReport(null, request.build())); - assertInstanceOf(YouAreDeadException.class, exception.getCause()); + assertThat((YouAreDeadException) exception.getCause(), isA(YouAreDeadException.class)); } private RegionServerStatusProtos.RegionServerReportRequest.Builder diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/visibility/TestVisibilityLabelsReplication.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/visibility/TestVisibilityLabelsReplication.java index 2e94258ff17e..14cc4ee20f26 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/visibility/TestVisibilityLabelsReplication.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/visibility/TestVisibilityLabelsReplication.java @@ -70,7 +70,6 @@ import org.apache.hadoop.hbase.wal.WALEdit; import org.apache.hadoop.hbase.zookeeper.MiniZooKeeperCluster; import org.apache.hadoop.hbase.zookeeper.ZKWatcher; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.slf4j.Logger; @@ -275,9 +274,9 @@ protected static void doAssert(byte[] row, String visTag) throws Exception { if (VisibilityReplicationEndPointForTest.lastEntries == null) { return; // first call } - Assertions.assertEquals(1, VisibilityReplicationEndPointForTest.lastEntries.size()); + assertEquals(1, VisibilityReplicationEndPointForTest.lastEntries.size()); List cells = VisibilityReplicationEndPointForTest.lastEntries.get(0).getEdit().getCells(); - Assertions.assertEquals(4, cells.size()); + assertEquals(4, cells.size()); boolean tagFound = false; for (Cell cell : cells) { if ( diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/visibility/TestVisibilityLabelsWithDefaultVisLabelService.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/visibility/TestVisibilityLabelsWithDefaultVisLabelService.java index b2dcd6f69ba9..178ab02cfb09 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/visibility/TestVisibilityLabelsWithDefaultVisLabelService.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/visibility/TestVisibilityLabelsWithDefaultVisLabelService.java @@ -49,7 +49,6 @@ import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.JVMClusterUtil.RegionServerThread; import org.apache.hadoop.hbase.util.Threads; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; @@ -175,7 +174,7 @@ public VisibilityLabelsResponse run() throws Exception { } } // One label is the "system" label. - Assertions.assertEquals(13, i, "The count should be 13"); + assertEquals(13, i, "The count should be 13"); } @Test diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/visibility/TestVisibilityWithCheckAuths.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/visibility/TestVisibilityWithCheckAuths.java index 0da694755b1d..2d80b38056b4 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/visibility/TestVisibilityWithCheckAuths.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/visibility/TestVisibilityWithCheckAuths.java @@ -19,6 +19,7 @@ import static org.apache.hadoop.hbase.security.visibility.VisibilityConstants.LABELS_TABLE_NAME; import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; import java.io.IOException; import java.security.PrivilegedExceptionAction; @@ -40,7 +41,6 @@ import org.apache.hadoop.hbase.testclassification.SecurityTests; import org.apache.hadoop.hbase.util.Bytes; 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; @@ -136,7 +136,7 @@ public Void run() throws Exception { p.setCellVisibility(new CellVisibility(PUBLIC + "&" + TOPSECRET)); p.addColumn(fam, qual, 125L, value); table.put(p); - Assertions.fail("Testcase should fail with AccesDeniedException"); + fail("Testcase should fail with AccessDeniedException"); } catch (Throwable t) { assertTrue(t.getMessage().contains("AccessDeniedException")); } @@ -203,7 +203,7 @@ public Void run() throws Exception { append.addColumn(fam, qual, Bytes.toBytes("c")); append.setCellVisibility(new CellVisibility(PUBLIC)); table.append(append); - Assertions.fail("Testcase should fail with AccesDeniedException"); + fail("Testcase should fail with AccessDeniedException"); } catch (Throwable t) { assertTrue(t.getMessage().contains("AccessDeniedException")); } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/tool/BulkLoadHFilesTestBase.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/tool/BulkLoadHFilesTestBase.java index fa55aad669f5..790c338bcaba 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/tool/BulkLoadHFilesTestBase.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/tool/BulkLoadHFilesTestBase.java @@ -17,6 +17,7 @@ */ package org.apache.hadoop.hbase.tool; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.greaterThan; import static org.junit.jupiter.api.Assertions.assertArrayEquals; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -57,7 +58,6 @@ import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.CommonFSUtils; import org.apache.hadoop.hbase.util.HFileTestUtil; -import org.hamcrest.MatcherAssert; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInfo; @@ -569,7 +569,7 @@ private void verifyHFileCreateTimeTS(Path p) throws IOException { try (HFile.Reader reader = HFile.createReader(p.getFileSystem(conf), p, new CacheConfig(conf), true, conf)) { long fileCreateTime = reader.getHFileInfo().getHFileContext().getFileCreateTime(); - MatcherAssert.assertThat(fileCreateTime, greaterThan(0L)); + assertThat(fileCreateTime, greaterThan(0L)); } } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestRegionMover1.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestRegionMover1.java index 412ce39e8702..135ecdc5eec8 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestRegionMover1.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestRegionMover1.java @@ -19,6 +19,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.File; import java.io.FileWriter; @@ -43,7 +44,6 @@ import org.apache.hadoop.hbase.util.RegionMover.RegionMoverBuilder; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; @@ -345,7 +345,7 @@ public void testDecomServerExclusionWithAck() throws Exception { int sourceServerRegions = regionServer.getRegions().size(); try (RegionMover regionMover = rmBuilder.build()) { - Assertions.assertTrue(regionMover.unload()); + assertTrue(regionMover.unload()); LOG.info("Unloading {}", hostname); assertEquals(0, regionServer.getNumberOfOnlineRegions()); assertEquals(regionsExcludeServer, cluster.getRegionServer(1).getNumberOfOnlineRegions()); @@ -354,11 +354,11 @@ public void testDecomServerExclusionWithAck() throws Exception { List regionList = cluster.getRegionServer(1).getRegions(); int index = 0; for (HRegion hRegion : regionList) { - Assertions.assertEquals(hRegion, regions.get(index++)); + assertEquals(hRegion, regions.get(index++)); } - Assertions.assertEquals(targetServerRegions + sourceServerRegions, + assertEquals(targetServerRegions + sourceServerRegions, cluster.getRegionServer(2).getNumberOfOnlineRegions()); - Assertions.assertTrue(regionMover.load()); + assertTrue(regionMover.load()); } TEST_UTIL.getAdmin().recommissionRegionServer(excludeServer.getServerName(), @@ -400,7 +400,7 @@ public void testDecomServerExclusion() throws Exception { int sourceServerRegions = sourceRegionServer.getRegions().size(); try (RegionMover regionMover = rmBuilder.build()) { - Assertions.assertTrue(regionMover.unload()); + assertTrue(regionMover.unload()); LOG.info("Unloading {}", hostname); assertEquals(0, sourceRegionServer.getNumberOfOnlineRegions()); assertEquals(regionsExcludeServer, cluster.getRegionServer(0).getNumberOfOnlineRegions()); @@ -409,11 +409,11 @@ public void testDecomServerExclusion() throws Exception { List regionList = cluster.getRegionServer(0).getRegions(); int index = 0; for (HRegion hRegion : regionList) { - Assertions.assertEquals(hRegion, regions.get(index++)); + assertEquals(hRegion, regions.get(index++)); } - Assertions.assertEquals(targetServerRegions + sourceServerRegions, + assertEquals(targetServerRegions + sourceServerRegions, cluster.getRegionServer(2).getNumberOfOnlineRegions()); - Assertions.assertTrue(regionMover.load()); + assertTrue(regionMover.load()); } TEST_UTIL.getAdmin().recommissionRegionServer(excludeServer.getServerName(), @@ -446,7 +446,7 @@ public void testExcludeAndDecomServers() throws Exception { new RegionMoverBuilder(sourceServer, TEST_UTIL.getConfiguration()).ack(true) .excludeFile(excludeFile.getCanonicalPath()); try (RegionMover regionMover = rmBuilder.build()) { - Assertions.assertFalse(regionMover.unload()); + assertFalse(regionMover.unload()); } TEST_UTIL.getAdmin().recommissionRegionServer(decomServer.getServerName(), diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestRegionMover3.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestRegionMover3.java index 04b06f47e799..ce05b2878b5d 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestRegionMover3.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestRegionMover3.java @@ -17,6 +17,9 @@ */ package org.apache.hadoop.hbase.util; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; @@ -37,7 +40,6 @@ import org.apache.hadoop.hbase.testclassification.LargeTests; import org.apache.hadoop.hbase.testclassification.MiscTests; import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; @@ -98,9 +100,9 @@ public void testRegionUnloadWithRack(TestInfo testInfo) throws Exception { int numRegions1 = hRegionServer1.getNumberOfOnlineRegions(); int numRegions2 = hRegionServer2.getNumberOfOnlineRegions(); - Assertions.assertTrue(numRegions0 >= 3); - Assertions.assertTrue(numRegions1 >= 3); - Assertions.assertTrue(numRegions2 >= 3); + assertTrue(numRegions0 >= 3); + assertTrue(numRegions1 >= 3); + assertTrue(numRegions2 >= 3); int totalRegions = numRegions0 + numRegions1 + numRegions2; // source RS: rs0 @@ -127,8 +129,8 @@ public void testRegionUnloadWithRack(TestInfo testInfo) throws Exception { int newNumRegions0 = hRegionServer0.getNumberOfOnlineRegions(); int newNumRegions1 = hRegionServer1.getNumberOfOnlineRegions(); int newNumRegions2 = hRegionServer2.getNumberOfOnlineRegions(); - Assertions.assertEquals(0, newNumRegions1); - Assertions.assertEquals(totalRegions, newNumRegions0 + newNumRegions2); + assertEquals(0, newNumRegions1); + assertEquals(totalRegions, newNumRegions0 + newNumRegions2); } // use custom rackManager, which resolves "rack-1" for rs0 and rs1, @@ -141,9 +143,9 @@ public void testRegionUnloadWithRack(TestInfo testInfo) throws Exception { int newNumRegions0 = hRegionServer0.getNumberOfOnlineRegions(); int newNumRegions1 = hRegionServer1.getNumberOfOnlineRegions(); int newNumRegions2 = hRegionServer2.getNumberOfOnlineRegions(); - Assertions.assertEquals(0, newNumRegions0); - Assertions.assertEquals(0, newNumRegions1); - Assertions.assertEquals(totalRegions, newNumRegions2); + assertEquals(0, newNumRegions0); + assertEquals(0, newNumRegions1); + assertEquals(totalRegions, newNumRegions2); } }