Skip to content

Commit

Permalink
test: use junit assert instead of java assert statement in test (#4310)
Browse files Browse the repository at this point in the history
### Motivation

See #995

### Changes

1. use junit assert instead of java assert statement in test
2. delete a unused util class also uses assert statement

Signed-off-by: ZhangJian He <[email protected]>
  • Loading branch information
hezhangjian authored Apr 28, 2024
1 parent 99776d4 commit d52e9e1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 61 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -1179,7 +1179,7 @@ public void testEnsembleWithThreeRegionsReplaceInternal(int minDurability, boole
try {
BookieId replacedBookie = repp.replaceBookie(6, 6, ackQuorum, null,
ensemble, bookieToReplace, excludedAddrs).getResult();
assert (replacedBookie.equals(replacedBookieExpected));
assertEquals(replacedBookieExpected, replacedBookie);
assertEquals(3, getNumRegionsInEnsemble(ensemble));
} catch (BKNotEnoughBookiesException bnebe) {
fail("Should not get not enough bookies exception even there is only one rack.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ private void testNonPartitionedWritesInternal(String name, DistributedLogConfigu
long lastTxId = -1;
while (null != record) {
DLMTestUtil.verifyLogRecord(record);
assert (lastTxId < record.getTransactionId());
assertTrue(lastTxId < record.getTransactionId());
lastTxId = record.getTransactionId();
numTrans++;
record = reader.readNext(false);
Expand Down Expand Up @@ -465,7 +465,7 @@ public void testContinuousReaderBulk() throws Exception {
long lastTxId = -1;
while (!recordList.isEmpty()) {
for (LogRecord record : recordList) {
assert (lastTxId < record.getTransactionId());
assertTrue(lastTxId < record.getTransactionId());
lastTxId = record.getTransactionId();
DLMTestUtil.verifyLogRecord(record);
numTrans++;
Expand Down Expand Up @@ -792,7 +792,7 @@ private void markEndOfStreamOnEmptyLogSegment(int numCompletedSegments) throws E
long lastTxId = -1;
while (null != record) {
DLMTestUtil.verifyLogRecord(record);
assert (lastTxId < record.getTransactionId());
assertTrue(lastTxId < record.getTransactionId());
lastTxId = record.getTransactionId();
numTrans++;
record = reader.readNext(false);
Expand Down Expand Up @@ -874,7 +874,7 @@ public void deleteDuringRead() throws Exception {

LogReader reader = dlm.getInputStream(1);
LogRecord record = reader.readNext(false);
assert (null != record);
assertNotNull(record);
DLMTestUtil.verifyLogRecord(record);
long lastTxId = record.getTransactionId();

Expand All @@ -885,7 +885,7 @@ public void deleteDuringRead() throws Exception {
record = reader.readNext(false);
while (null != record) {
DLMTestUtil.verifyLogRecord(record);
assert (lastTxId < record.getTransactionId());
assertTrue(lastTxId < record.getTransactionId());
lastTxId = record.getTransactionId();
record = reader.readNext(false);
}
Expand Down Expand Up @@ -1247,42 +1247,42 @@ public void testTruncationValidation() throws Exception {
for (LogSegmentMetadata segment: cachedSegments) {
if (segment.getLastDLSN().compareTo(truncDLSN) < 0) {
assertTrue(segment.isTruncated());
assertTrue(!segment.isPartiallyTruncated());
assertFalse(segment.isPartiallyTruncated());
} else if (segment.getFirstDLSN().compareTo(truncDLSN) < 0) {
assertTrue(!segment.isTruncated());
assertFalse(segment.isTruncated());
assertTrue(segment.isPartiallyTruncated());
} else {
assertTrue(!segment.isTruncated());
assertTrue(!segment.isPartiallyTruncated());
assertFalse(segment.isTruncated());
assertFalse(segment.isPartiallyTruncated());
}
}

segmentList = DLMTestUtil.readLogSegments(zookeeperClient,
LogMetadata.getLogSegmentsPath(uri, name, conf.getUnpartitionedStreamName()));

assertTrue(segmentList.get(truncDLSN.getLogSegmentSequenceNo())
.getMinActiveDLSN().compareTo(truncDLSN) == 0);
assertEquals(0, segmentList.get(truncDLSN.getLogSegmentSequenceNo())
.getMinActiveDLSN().compareTo(truncDLSN));

{
LogReader reader = dlm.getInputStream(DLSN.InitialDLSN);
LogRecordWithDLSN record = reader.readNext(false);
assertTrue(record != null);
assertNotNull(record);
assertEquals(truncDLSN, record.getDlsn());
reader.close();
}

{
LogReader reader = dlm.getInputStream(1);
LogRecordWithDLSN record = reader.readNext(false);
assertTrue(record != null);
assertNotNull(record);
assertEquals(truncDLSN, record.getDlsn());
reader.close();
}

{
AsyncLogReader reader = dlm.getAsyncLogReader(DLSN.InitialDLSN);
LogRecordWithDLSN record = Utils.ioResult(reader.readNext());
assertTrue(record != null);
assertNotNull(record);
assertEquals(truncDLSN, record.getDlsn());
Utils.close(reader);
}
Expand All @@ -1291,15 +1291,15 @@ public void testTruncationValidation() throws Exception {
{
LogReader reader = dlm.getInputStream(beyondTruncDLSN);
LogRecordWithDLSN record = reader.readNext(false);
assertTrue(record != null);
assertNotNull(record);
assertEquals(beyondTruncDLSN, record.getDlsn());
reader.close();
}

{
LogReader reader = dlm.getInputStream(beyondTruncTxId);
LogRecordWithDLSN record = reader.readNext(false);
assertTrue(record != null);
assertNotNull(record);
assertEquals(beyondTruncDLSN, record.getDlsn());
assertEquals(beyondTruncTxId, record.getTransactionId());
reader.close();
Expand All @@ -1308,7 +1308,7 @@ public void testTruncationValidation() throws Exception {
{
AsyncLogReader reader = dlm.getAsyncLogReader(beyondTruncDLSN);
LogRecordWithDLSN record = Utils.ioResult(reader.readNext());
assertTrue(record != null);
assertNotNull(record);
assertEquals(beyondTruncDLSN, record.getDlsn());
Utils.close(reader);
}
Expand Down

0 comments on commit d52e9e1

Please sign in to comment.