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 @@ -18,8 +18,10 @@
package org.apache.hadoop.hbase.backup;

import static org.apache.hadoop.hbase.backup.util.BackupUtils.succeeded;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;

import java.io.IOException;
import java.util.ArrayList;
Expand All @@ -41,7 +43,6 @@
import org.apache.hadoop.hbase.client.Table;
import org.apache.hadoop.hbase.testclassification.LargeTests;
import org.apache.hadoop.hbase.util.Pair;
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 @@ -74,7 +75,7 @@ public void setConf(Configuration conf) {
if (val != null) {
failurePhase = FailurePhase.valueOf(val);
} else {
Assertions.fail("Failure phase is not set");
fail("Failure phase is not set");
}
}

Expand Down Expand Up @@ -242,13 +243,13 @@ public void TestIncBackupMergeRestore() throws Exception {
Table t1 = insertIntoTable(conn, table1, famName, 1, ADD_ROWS);
LOG.debug("writing " + ADD_ROWS + " rows to " + table1);

Assertions.assertEquals(NB_ROWS_IN_BATCH + ADD_ROWS, TEST_UTIL.countRows(t1));
assertEquals(NB_ROWS_IN_BATCH + ADD_ROWS, TEST_UTIL.countRows(t1));
t1.close();
LOG.debug("written " + ADD_ROWS + " rows to " + table1);

Table t2 = insertIntoTable(conn, table2, famName, 1, ADD_ROWS);

Assertions.assertEquals(NB_ROWS_IN_BATCH + ADD_ROWS, TEST_UTIL.countRows(t2));
assertEquals(NB_ROWS_IN_BATCH + ADD_ROWS, TEST_UTIL.countRows(t2));
t2.close();
LOG.debug("written " + ADD_ROWS + " rows to " + table2);

Expand Down Expand Up @@ -279,7 +280,7 @@ public void TestIncBackupMergeRestore() throws Exception {
try (BackupAdmin bAdmin = new BackupAdminImpl(conn)) {
String[] backups = new String[] { backupIdIncMultiple, backupIdIncMultiple2 };
bAdmin.mergeBackups(backups);
Assertions.fail("Expected IOException");
fail("Expected IOException");
} catch (IOException e) {
BackupSystemTable table = new BackupSystemTable(conn);
if (phase.ordinal() < FailurePhase.PHASE4.ordinal()) {
Expand All @@ -288,7 +289,7 @@ public void TestIncBackupMergeRestore() throws Exception {
assertFalse(table.isMergeInProgress());
try {
table.finishBackupExclusiveOperation();
Assertions.fail("IOException is expected");
fail("IOException is expected");
} catch (IOException ee) {
// Expected
}
Expand All @@ -297,7 +298,7 @@ public void TestIncBackupMergeRestore() throws Exception {
assertTrue(table.isMergeInProgress());
try {
table.startBackupExclusiveOperation();
Assertions.fail("IOException is expected");
fail("IOException is expected");
} catch (IOException ee) {
// Expected - clean up before proceeding
// table.finishMergeOperation();
Expand Down Expand Up @@ -330,12 +331,12 @@ public void TestIncBackupMergeRestore() throws Exception {
Table hTable = conn.getTable(table1_restore);
LOG.debug("After incremental restore: " + hTable.getDescriptor());
LOG.debug("f1 has " + TEST_UTIL.countRows(hTable, famName) + " rows");
Assertions.assertEquals(NB_ROWS_IN_BATCH + 2 * ADD_ROWS, TEST_UTIL.countRows(hTable, famName));
assertEquals(NB_ROWS_IN_BATCH + 2 * ADD_ROWS, TEST_UTIL.countRows(hTable, famName));

hTable.close();

hTable = conn.getTable(table2_restore);
Assertions.assertEquals(NB_ROWS_IN_BATCH + 2 * ADD_ROWS, TEST_UTIL.countRows(hTable));
assertEquals(NB_ROWS_IN_BATCH + 2 * ADD_ROWS, TEST_UTIL.countRows(hTable));
hTable.close();

admin.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@
*/
package org.apache.hadoop.hbase.metrics;

import static org.junit.jupiter.api.Assertions.assertTrue;

import java.util.Collection;
import org.apache.hadoop.hbase.testclassification.MetricsTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.metrics2.AbstractMetric;
import org.apache.hadoop.metrics2.MetricsRecord;
import org.apache.hadoop.metrics2.impl.MetricsExportHelper;
import org.apache.hadoop.metrics2.lib.DefaultMetricsSystem;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;

Expand All @@ -49,10 +50,9 @@ public void testExportHelper() {
Collection<MetricsRecord> metrics = MetricsExportHelper.export();
DefaultMetricsSystem.instance().stop();

Assertions.assertTrue(metrics.stream().anyMatch(mr -> mr.name().equals(metricsName)));
Assertions.assertTrue(contains(metrics, metricsName, gaugeName),
gaugeName + " is missing in the export");
Assertions.assertTrue(contains(metrics, metricsName, counterName),
assertTrue(metrics.stream().anyMatch(mr -> mr.name().equals(metricsName)));
assertTrue(contains(metrics, metricsName, gaugeName), gaugeName + " is missing in the export");
assertTrue(contains(metrics, metricsName, counterName),
counterName + " is missing in the export");
}

Expand Down
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
Loading