Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand All @@ -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));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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();
}
Expand All @@ -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();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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();

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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);
}

/*
Expand All @@ -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.
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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));
}

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -63,19 +63,19 @@ public void testDefaultQueueLimits(TestInfo testInfo) {

List<BlockingQueue<CallRunner>> 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 ");
}

Expand All @@ -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<BlockingQueue<CallRunner>> 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");

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<Cell> cells = VisibilityReplicationEndPointForTest.lastEntries.get(0).getEdit().getCells();
Assertions.assertEquals(4, cells.size());
assertEquals(4, cells.size());
boolean tagFound = false;
for (Cell cell : cells) {
if (
Expand Down
Loading