This is an automated email from the ASF dual-hosted git repository.

shoothzj pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/bookkeeper.git


The following commit(s) were added to refs/heads/master by this push:
     new d52e9e1d9a test: use junit assert instead of java assert statement in 
test (#4310)
d52e9e1d9a is described below

commit d52e9e1d9a61013d16da2979aa6603966870c03e
Author: ZhangJian He <[email protected]>
AuthorDate: Sun Apr 28 10:17:02 2024 +0800

    test: use junit assert instead of java assert statement in test (#4310)
    
    ### 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]>
---
 .../bookkeeper/util/DaemonThreadFactory.java       | 43 ----------------------
 .../TestRegionAwareEnsemblePlacementPolicy.java    |  2 +-
 .../TestBKDistributedLogManager.java               | 34 ++++++++---------
 3 files changed, 18 insertions(+), 61 deletions(-)

diff --git 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/util/DaemonThreadFactory.java
 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/util/DaemonThreadFactory.java
deleted file mode 100644
index feddf2a630..0000000000
--- 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/util/DaemonThreadFactory.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.bookkeeper.util;
-
-import java.util.concurrent.Executors;
-import java.util.concurrent.ThreadFactory;
-
-/**
- * Daemon thread factory.
- */
-public class DaemonThreadFactory implements ThreadFactory {
-    private ThreadFactory defaultThreadFactory = 
Executors.defaultThreadFactory();
-    private int priority = Thread.NORM_PRIORITY;
-    public DaemonThreadFactory() {
-    }
-    public DaemonThreadFactory(int priority) {
-        assert priority >= Thread.MIN_PRIORITY && priority <= 
Thread.MAX_PRIORITY;
-        this.priority = priority;
-    }
-    @Override
-    public Thread newThread(Runnable r) {
-        Thread thread = defaultThreadFactory.newThread(r);
-        thread.setDaemon(true);
-        thread.setPriority(priority);
-        return thread;
-    }
-}
diff --git 
a/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/TestRegionAwareEnsemblePlacementPolicy.java
 
b/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/TestRegionAwareEnsemblePlacementPolicy.java
index 4f5bf08621..e6ee04501e 100644
--- 
a/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/TestRegionAwareEnsemblePlacementPolicy.java
+++ 
b/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/TestRegionAwareEnsemblePlacementPolicy.java
@@ -1179,7 +1179,7 @@ public class TestRegionAwareEnsemblePlacementPolicy 
extends TestCase {
             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.");
diff --git 
a/stream/distributedlog/core/src/test/java/org/apache/distributedlog/TestBKDistributedLogManager.java
 
b/stream/distributedlog/core/src/test/java/org/apache/distributedlog/TestBKDistributedLogManager.java
index e26667dd04..9341dece0b 100644
--- 
a/stream/distributedlog/core/src/test/java/org/apache/distributedlog/TestBKDistributedLogManager.java
+++ 
b/stream/distributedlog/core/src/test/java/org/apache/distributedlog/TestBKDistributedLogManager.java
@@ -187,7 +187,7 @@ public class TestBKDistributedLogManager extends 
TestDistributedLogBase {
         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);
@@ -465,7 +465,7 @@ public class TestBKDistributedLogManager extends 
TestDistributedLogBase {
         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++;
@@ -792,7 +792,7 @@ public class TestBKDistributedLogManager extends 
TestDistributedLogBase {
             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);
@@ -874,7 +874,7 @@ public class TestBKDistributedLogManager extends 
TestDistributedLogBase {
 
         LogReader reader = dlm.getInputStream(1);
         LogRecord record = reader.readNext(false);
-        assert (null != record);
+        assertNotNull(record);
         DLMTestUtil.verifyLogRecord(record);
         long lastTxId = record.getTransactionId();
 
@@ -885,7 +885,7 @@ public class TestBKDistributedLogManager extends 
TestDistributedLogBase {
             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);
             }
@@ -1247,26 +1247,26 @@ public class TestBKDistributedLogManager extends 
TestDistributedLogBase {
         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();
         }
@@ -1274,7 +1274,7 @@ public class TestBKDistributedLogManager extends 
TestDistributedLogBase {
         {
             LogReader reader = dlm.getInputStream(1);
             LogRecordWithDLSN record = reader.readNext(false);
-            assertTrue(record != null);
+            assertNotNull(record);
             assertEquals(truncDLSN, record.getDlsn());
             reader.close();
         }
@@ -1282,7 +1282,7 @@ public class TestBKDistributedLogManager extends 
TestDistributedLogBase {
         {
             AsyncLogReader reader = dlm.getAsyncLogReader(DLSN.InitialDLSN);
             LogRecordWithDLSN record = Utils.ioResult(reader.readNext());
-            assertTrue(record != null);
+            assertNotNull(record);
             assertEquals(truncDLSN, record.getDlsn());
             Utils.close(reader);
         }
@@ -1291,7 +1291,7 @@ public class TestBKDistributedLogManager extends 
TestDistributedLogBase {
         {
             LogReader reader = dlm.getInputStream(beyondTruncDLSN);
             LogRecordWithDLSN record = reader.readNext(false);
-            assertTrue(record != null);
+            assertNotNull(record);
             assertEquals(beyondTruncDLSN, record.getDlsn());
             reader.close();
         }
@@ -1299,7 +1299,7 @@ public class TestBKDistributedLogManager extends 
TestDistributedLogBase {
         {
             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();
@@ -1308,7 +1308,7 @@ public class TestBKDistributedLogManager extends 
TestDistributedLogBase {
         {
             AsyncLogReader reader = dlm.getAsyncLogReader(beyondTruncDLSN);
             LogRecordWithDLSN record = Utils.ioResult(reader.readNext());
-            assertTrue(record != null);
+            assertNotNull(record);
             assertEquals(beyondTruncDLSN, record.getDlsn());
             Utils.close(reader);
         }

Reply via email to