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

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

commit 371f68cadf58e0fb0c92fd24fe6123bebd084578
Author: slfan1989 <55643692+slfan1...@users.noreply.github.com>
AuthorDate: Fri May 23 16:03:05 2025 +0800

    RATIS-1977. Remove Junit 4 dependencies. (#1269)
---
 pom.xml                                            |  19 +--
 ratis-common/pom.xml                               |  11 --
 .../src/test/java/org/apache/ratis/BaseTest.java   |   9 --
 ratis-examples/pom.xml                             |   5 -
 ratis-proto/pom.xml                                |   4 +-
 ratis-server/pom.xml                               |  10 --
 .../org/apache/ratis/RaftExceptionBaseTest.java    |   4 +-
 .../test/java/org/apache/ratis/RaftTestUtil.java   |  11 +-
 .../ratis/server/impl/LeaderElectionTests.java     | 147 ++++++++++-----------
 .../server/impl/StateMachineShutdownTests.java     |  25 ++--
 ratis-test/pom.xml                                 |  10 --
 11 files changed, 103 insertions(+), 152 deletions(-)

diff --git a/pom.xml b/pom.xml
index 1a85348a2..4d8dfe1e6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -221,8 +221,10 @@
     <testsThreadCount>4</testsThreadCount>
 
     <slf4j.version>2.0.7</slf4j.version>
-    <junit-bom.version>5.11.2</junit-bom.version>
+    <junit-bom.version>5.12.2</junit-bom.version>
+    <mockito.version>4.11.0</mockito.version>
     <jacoco.version>0.8.12</jacoco.version>
+    <jakarta.annotation.version>1.3.5</jakarta.annotation.version>
     <flaky-test-groups>flaky | 
org.apache.ratis.test.tag.FlakyTest</flaky-test-groups>
   </properties>
 
@@ -417,12 +419,6 @@
         <scope>test</scope>
         <version>${slf4j.version}</version>
       </dependency>
-
-      <dependency>
-        <groupId>junit</groupId>
-        <artifactId>junit</artifactId>
-        <version>4.13.2</version>
-      </dependency>
       <dependency>
         <groupId>org.junit</groupId>
         <artifactId>junit-bom</artifactId>
@@ -433,13 +429,12 @@
       <dependency>
         <groupId>org.mockito</groupId>
         <artifactId>mockito-core</artifactId>
-        <version>4.3.1</version>
+        <version>${mockito.version}</version>
       </dependency>
       <dependency>
-        <groupId>org.apache.tomcat</groupId>
-        <artifactId>annotations-api</artifactId>
-        <version>6.0.53</version>
-        <scope>provided</scope>
+        <groupId>jakarta.annotation</groupId>
+        <artifactId>jakarta.annotation-api</artifactId>
+        <version>${jakarta.annotation.version}</version>
       </dependency>
     </dependencies>
   </dependencyManagement>
diff --git a/ratis-common/pom.xml b/ratis-common/pom.xml
index a09f44679..b040f8796 100644
--- a/ratis-common/pom.xml
+++ b/ratis-common/pom.xml
@@ -38,12 +38,6 @@
       <artifactId>slf4j-api</artifactId>
     </dependency>
 
-    <dependency>
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
-      <scope>test</scope>
-    </dependency>
-
     <dependency>
       <groupId>org.junit.jupiter</groupId>
       <artifactId>junit-jupiter-api</artifactId>
@@ -54,11 +48,6 @@
       <artifactId>junit-jupiter-engine</artifactId>
       <scope>test</scope>
     </dependency>
-    <dependency>
-      <groupId>org.junit.vintage</groupId>
-      <artifactId>junit-vintage-engine</artifactId>
-      <scope>test</scope>
-    </dependency>
     <dependency>
       <groupId>org.junit.platform</groupId>
       <artifactId>junit-platform-launcher</artifactId>
diff --git a/ratis-common/src/test/java/org/apache/ratis/BaseTest.java 
b/ratis-common/src/test/java/org/apache/ratis/BaseTest.java
index ff912879d..52b986ab9 100644
--- a/ratis-common/src/test/java/org/apache/ratis/BaseTest.java
+++ b/ratis-common/src/test/java/org/apache/ratis/BaseTest.java
@@ -25,8 +25,6 @@ import org.apache.ratis.util.Slf4jUtils;
 import org.apache.ratis.util.StringUtils;
 import org.apache.ratis.util.TimeDuration;
 import org.apache.ratis.util.function.CheckedRunnable;
-import org.junit.After;
-import org.junit.Before;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.Assumptions;
@@ -71,8 +69,6 @@ public abstract class BaseTest {
     }
   }
 
-  // TODO: Junit 4 reference should be removed once all the unit tests are 
migrated to Junit 5.
-
   private String testCaseName;
 
   @BeforeEach
@@ -84,8 +80,6 @@ public abstract class BaseTest {
         + "." + (method == null? null : method.getName());
   }
 
-  // @Before annotation is retained to support junit 4 tests.
-  @Before
   @BeforeEach
   public void checkAssumptions() {
     final Throwable first = firstException.get();
@@ -95,8 +89,6 @@ public abstract class BaseTest {
     Assumptions.assumeTrue(exited == null, () -> "Already exited with " + 
exited);
   }
 
-  // @After annotation is retained to support junit 4 tests.
-  @After
   @AfterEach
   public void assertNoFailures() {
     final Throwable e = firstException.get();
@@ -129,7 +121,6 @@ public abstract class BaseTest {
   }
 
   public File getTestDir() {
-    // This will work for both junit 4 and 5.
     return new File(getClassTestDir(), testCaseName);
   }
 
diff --git a/ratis-examples/pom.xml b/ratis-examples/pom.xml
index 6b734a965..d13e68df5 100644
--- a/ratis-examples/pom.xml
+++ b/ratis-examples/pom.xml
@@ -117,11 +117,6 @@
       <scope>runtime</scope>
     </dependency>
 
-    <dependency>
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
-      <scope>test</scope>
-    </dependency>
     <dependency>
       <groupId>org.junit.jupiter</groupId>
       <artifactId>junit-jupiter-engine</artifactId>
diff --git a/ratis-proto/pom.xml b/ratis-proto/pom.xml
index 9e65096e4..9a548b406 100644
--- a/ratis-proto/pom.xml
+++ b/ratis-proto/pom.xml
@@ -176,8 +176,8 @@
       <artifactId>ratis-thirdparty-misc</artifactId>
     </dependency>
     <dependency>
-      <groupId>org.apache.tomcat</groupId>
-      <artifactId>annotations-api</artifactId>
+      <groupId>jakarta.annotation</groupId>
+      <artifactId>jakarta.annotation-api</artifactId>
     </dependency>
   </dependencies>
 </project>
diff --git a/ratis-server/pom.xml b/ratis-server/pom.xml
index 22041f0ee..54ea8e1de 100644
--- a/ratis-server/pom.xml
+++ b/ratis-server/pom.xml
@@ -65,11 +65,6 @@
       <artifactId>slf4j-api</artifactId>
     </dependency>
 
-    <dependency>
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
-      <scope>test</scope>
-    </dependency>
     <dependency>
       <groupId>org.junit.jupiter</groupId>
       <artifactId>junit-jupiter-api</artifactId>
@@ -80,11 +75,6 @@
       <artifactId>junit-jupiter-engine</artifactId>
       <scope>test</scope>
     </dependency>
-    <dependency>
-      <groupId>org.junit.vintage</groupId>
-      <artifactId>junit-vintage-engine</artifactId>
-      <scope>test</scope>
-    </dependency>
     <dependency>
       <groupId>org.junit.platform</groupId>
       <artifactId>junit-platform-launcher</artifactId>
diff --git 
a/ratis-server/src/test/java/org/apache/ratis/RaftExceptionBaseTest.java 
b/ratis-server/src/test/java/org/apache/ratis/RaftExceptionBaseTest.java
index 3d2837cd6..9f602e081 100644
--- a/ratis-server/src/test/java/org/apache/ratis/RaftExceptionBaseTest.java
+++ b/ratis-server/src/test/java/org/apache/ratis/RaftExceptionBaseTest.java
@@ -34,7 +34,7 @@ import org.apache.ratis.util.JavaUtils;
 import org.apache.ratis.util.Slf4jUtils;
 import org.apache.ratis.util.SizeInBytes;
 import org.junit.jupiter.api.Assertions;
-import org.junit.Assume;
+import org.junit.jupiter.api.Assumptions;
 import org.junit.jupiter.api.Test;
 import org.slf4j.event.Level;
 
@@ -84,7 +84,7 @@ public abstract class RaftExceptionBaseTest<CLUSTER extends 
MiniRaftCluster>
     final SimpleMessage message = new SimpleMessage(messageId);
     final RaftClientReply reply = 
rpc.sendRequest(cluster.newRaftClientRequest(ClientId.randomId(), server, 
message));
     Assertions.assertNotNull(reply);
-    Assume.assumeFalse(reply.isSuccess());
+    Assumptions.assumeFalse(reply.isSuccess());
     final NotLeaderException nle = reply.getNotLeaderException();
     Objects.requireNonNull(nle);
     Assertions.assertEquals(expectedSuggestedLeader, 
nle.getSuggestedLeader().getId());
diff --git a/ratis-server/src/test/java/org/apache/ratis/RaftTestUtil.java 
b/ratis-server/src/test/java/org/apache/ratis/RaftTestUtil.java
index f8d92cf08..40a93df17 100644
--- a/ratis-server/src/test/java/org/apache/ratis/RaftTestUtil.java
+++ b/ratis-server/src/test/java/org/apache/ratis/RaftTestUtil.java
@@ -43,7 +43,8 @@ import org.apache.ratis.util.JavaUtils;
 import org.apache.ratis.util.Preconditions;
 import org.apache.ratis.util.ProtoUtils;
 import org.apache.ratis.util.TimeDuration;
-import org.junit.AssumptionViolatedException;
+import org.apache.ratis.util.function.CheckedConsumer;
+import org.junit.jupiter.api.Assumptions;
 import org.junit.jupiter.api.Assertions;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -475,18 +476,18 @@ public interface RaftTestUtil {
 
   static RaftPeerId changeLeader(MiniRaftCluster cluster, RaftPeerId oldLeader)
       throws Exception {
-    return changeLeader(cluster, oldLeader, AssumptionViolatedException::new);
+    return changeLeader(cluster, oldLeader, Assumptions::abort);
   }
 
-  static RaftPeerId changeLeader(MiniRaftCluster cluster, RaftPeerId 
oldLeader, Function<String, Exception> constructor)
-      throws Exception {
+  static RaftPeerId changeLeader(MiniRaftCluster cluster, RaftPeerId oldLeader,
+      CheckedConsumer<String, Exception> failToChangeLeaderHandler) throws 
Exception {
     final String name = JavaUtils.getCallerStackTraceElement().getMethodName() 
+ "-changeLeader";
     cluster.setBlockRequestsFrom(oldLeader.toString(), true);
     try {
       return JavaUtils.attemptRepeatedly(() -> {
         final RaftPeerId newLeader = waitForLeader(cluster).getId();
         if (newLeader.equals(oldLeader)) {
-          throw constructor.apply("Failed to change leader: newLeader == 
oldLeader == " + oldLeader);
+          failToChangeLeaderHandler.accept("Failed to change leader: newLeader 
== oldLeader == " + oldLeader);
         }
         LOG.info("Changed leader from " + oldLeader + " to " + newLeader);
         return newLeader;
diff --git 
a/ratis-server/src/test/java/org/apache/ratis/server/impl/LeaderElectionTests.java
 
b/ratis-server/src/test/java/org/apache/ratis/server/impl/LeaderElectionTests.java
index edb0a01bd..8a17fd135 100644
--- 
a/ratis-server/src/test/java/org/apache/ratis/server/impl/LeaderElectionTests.java
+++ 
b/ratis-server/src/test/java/org/apache/ratis/server/impl/LeaderElectionTests.java
@@ -38,7 +38,6 @@ import org.apache.ratis.server.RaftServerConfigKeys;
 import org.apache.ratis.server.metrics.LeaderElectionMetrics;
 import org.apache.ratis.server.protocol.TermIndex;
 import org.apache.ratis.server.raftlog.segmented.SegmentedRaftLogTestUtils;
-import org.apache.ratis.util.ExitUtils;
 import org.apache.ratis.test.tag.Flaky;
 import org.apache.ratis.thirdparty.com.codahale.metrics.Timer;
 import org.apache.ratis.util.CodeInjectionForTesting;
@@ -48,7 +47,6 @@ import org.apache.ratis.util.Slf4jUtils;
 import org.apache.ratis.util.TimeDuration;
 import org.apache.ratis.util.Timestamp;
 import org.apache.ratis.util.function.CheckedBiConsumer;
-import org.junit.Assert;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.Test;
 import org.slf4j.Logger;
@@ -71,10 +69,10 @@ import static 
org.apache.ratis.server.metrics.LeaderElectionMetrics.LAST_LEADER_
 import static 
org.apache.ratis.server.metrics.LeaderElectionMetrics.LEADER_ELECTION_COUNT_METRIC;
 import static 
org.apache.ratis.server.metrics.LeaderElectionMetrics.LEADER_ELECTION_TIME_TAKEN;
 import static 
org.apache.ratis.server.metrics.LeaderElectionMetrics.LEADER_ELECTION_TIMEOUT_COUNT_METRIC;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+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 static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
@@ -136,10 +134,10 @@ public abstract class LeaderElectionTests<CLUSTER extends 
MiniRaftCluster>
     LOG.info("{} isRunning at {}ms? {}", server.getId(), 
startTime.elapsedTimeMs(), isRunning);
 
     // Leader will be elected if the server is ready
-    Assertions.assertNotNull(waitForLeader(cluster), "No leader is elected.");
+    assertNotNull(waitForLeader(cluster), "No leader is elected.");
     final long elapsedMs = startTime.elapsedTimeMs();
     // allow a small difference to tolerate system timer inaccuracy
-    Assertions.assertTrue(elapsedMs > sleepMs - 10, () -> "elapseMs = " + 
elapsedMs + " but sleepMs = " + sleepMs);
+    assertTrue(elapsedMs > sleepMs - 10, () -> "elapseMs = " + elapsedMs + " 
but sleepMs = " + sleepMs);
     cluster.shutdown();
     CodeInjectionForTesting.remove(RaftServerImpl.START_COMPLETE);
   }
@@ -154,7 +152,7 @@ public abstract class LeaderElectionTests<CLUSTER extends 
MiniRaftCluster>
     try (RaftClient client = cluster.createClient()) {
       for (int i = 0; i < 10; ++i) {
         RaftClientReply reply = client.io().send(new 
RaftTestUtil.SimpleMessage("message_" + i));
-        Assertions.assertTrue(reply.isSuccess());
+        assertTrue(reply.isSuccess());
       }
       // add 3 new servers and wait longer time
       CodeInjectionForTesting.put(RaftServerImpl.START_COMPLETE, new 
SleepCode(2000));
@@ -164,11 +162,11 @@ public abstract class LeaderElectionTests<CLUSTER extends 
MiniRaftCluster>
       RaftClientReply reply = 
client.admin().setConfiguration(SetConfigurationRequest.Arguments.newBuilder()
               .setServersInNewConf(peerChanges.newPeers)
               .setMode(SetConfigurationRequest.Mode.ADD).build());
-      Assert.assertTrue(reply.isSuccess());
+      assertTrue(reply.isSuccess());
       for (RaftServer server : cluster.getServers()) {
         RaftServerProxy proxy = (RaftServerProxy) server;
         proxy.getImpls().forEach(s -> {
-          Assertions.assertTrue(s.isRunning());
+          assertTrue(s.isRunning());
         });
       }
     }
@@ -185,8 +183,7 @@ public abstract class LeaderElectionTests<CLUSTER extends 
MiniRaftCluster>
 
     RaftPeerId leader = RaftTestUtil.waitForLeader(cluster).getId();
     for(int i = 0; i < 10; i++) {
-      leader = RaftTestUtil.changeLeader(cluster, leader, 
IllegalStateException::new);
-      ExitUtils.assertNotTerminated();
+      leader = RaftTestUtil.changeLeader(cluster, leader, Assertions::fail);
     }
     SegmentedRaftLogTestUtils.setRaftLogWorkerLogLevel(Level.INFO);
     cluster.shutdown();
@@ -217,18 +214,18 @@ public abstract class LeaderElectionTests<CLUSTER extends 
MiniRaftCluster>
 
   void runTestLeaderNotCountListenerForMajority(CLUSTER cluster) throws 
Exception {
     final RaftServer.Division leader = waitForLeader(cluster);
-    Assertions.assertEquals(2, 
((RaftConfigurationImpl)cluster.getLeader().getRaftConf()).getMajorityCount());
+    assertEquals(2, 
((RaftConfigurationImpl)cluster.getLeader().getRaftConf()).getMajorityCount());
     try (RaftClient client = cluster.createClient(leader.getId())) {
       client.io().send(new RaftTestUtil.SimpleMessage("message"));
       List<RaftPeer> listeners = cluster.getListeners()
           
.stream().map(RaftServer.Division::getPeer).collect(Collectors.toList());
-      Assertions.assertEquals(2, listeners.size());
+      assertEquals(2, listeners.size());
       RaftClientReply reply = 
client.admin().setConfiguration(cluster.getPeers());
-      Assertions.assertTrue(reply.isSuccess());
+      assertTrue(reply.isSuccess());
       Collection<RaftPeer> peer = 
leader.getRaftConf().getAllPeers(RaftProtos.RaftPeerRole.LISTENER);
-      Assertions.assertEquals(0, peer.size());
+      assertEquals(0, peer.size());
     }
-    Assertions.assertEquals(3, 
((RaftConfigurationImpl)cluster.getLeader().getRaftConf()).getMajorityCount());
+    assertEquals(3, 
((RaftConfigurationImpl)cluster.getLeader().getRaftConf()).getMajorityCount());
   }
 
   @Test
@@ -246,7 +243,7 @@ public abstract class LeaderElectionTests<CLUSTER extends 
MiniRaftCluster>
       RaftTestUtil.isolate(cluster, listenerId);
       maxTimeout.sleep();
       maxTimeout.sleep();
-      Assertions.assertEquals(RaftProtos.RaftPeerRole.LISTENER, 
listener.getInfo().getCurrentRole());
+      assertEquals(RaftProtos.RaftPeerRole.LISTENER, 
listener.getInfo().getCurrentRole());
     } finally {
       RaftTestUtil.deIsolate(cluster, listener.getId());
     }
@@ -262,18 +259,18 @@ public abstract class LeaderElectionTests<CLUSTER extends 
MiniRaftCluster>
         client.io().send(new RaftTestUtil.SimpleMessage("message"));
 
         List<RaftServer.Division> followers = cluster.getFollowers();
-        Assertions.assertEquals(2, followers.size());
+        assertEquals(2, followers.size());
         RaftServer.Division newLeader = followers.get(0);
 
         RaftClientReply reply = 
client.admin().transferLeadership(newLeader.getId(), 20000);
-        Assertions.assertTrue(reply.isSuccess());
+        assertTrue(reply.isSuccess());
 
         final RaftServer.Division currLeader = waitForLeader(cluster);
-        Assertions.assertEquals(newLeader.getId(), currLeader.getId());
+        assertEquals(newLeader.getId(), currLeader.getId());
 
         reply = client.io().send(new RaftTestUtil.SimpleMessage("message"));
-        Assertions.assertEquals(newLeader.getId().toString(), 
reply.getReplierId());
-        Assertions.assertTrue(reply.isSuccess());
+        assertEquals(newLeader.getId().toString(), reply.getReplierId());
+        assertTrue(reply.isSuccess());
       }
 
       cluster.shutdown();
@@ -290,24 +287,24 @@ public abstract class LeaderElectionTests<CLUSTER extends 
MiniRaftCluster>
         client.io().send(new RaftTestUtil.SimpleMessage("message"));
 
         List<RaftServer.Division> followers = cluster.getFollowers();
-        Assertions.assertEquals(2, followers.size());
+        assertEquals(2, followers.size());
         RaftServer.Division newLeader = followers.get(0);
 
         List<RaftPeer> peers = cluster.getPeers();
         List<RaftPeer> peersWithNewPriority = getPeersWithPriority(peers, 
newLeader.getPeer());
         RaftClientReply reply = 
client.admin().setConfiguration(peersWithNewPriority.toArray(new RaftPeer[0]));
-        Assertions.assertTrue(reply.isSuccess());
+        assertTrue(reply.isSuccess());
 
         // Wait the old leader to step down.
         // TODO: make it more deterministic.
         TimeDuration.valueOf(1, TimeUnit.SECONDS).sleep();
 
         final RaftServer.Division currLeader = waitForLeader(cluster);
-        Assertions.assertEquals(newLeader.getId(), currLeader.getId());
+        assertEquals(newLeader.getId(), currLeader.getId());
 
         reply = client.io().send(new RaftTestUtil.SimpleMessage("message"));
-        Assertions.assertEquals(newLeader.getId().toString(), 
reply.getReplierId());
-        Assertions.assertTrue(reply.isSuccess());
+        assertEquals(newLeader.getId().toString(), reply.getReplierId());
+        assertTrue(reply.isSuccess());
       }
 
       cluster.shutdown();
@@ -322,7 +319,7 @@ public abstract class LeaderElectionTests<CLUSTER extends 
MiniRaftCluster>
       final RaftServer.Division leader = waitForLeader(cluster);
       try (RaftClient client = cluster.createClient(leader.getId())) {
         List<RaftServer.Division> followers = cluster.getFollowers();
-        Assertions.assertEquals(followers.size(), 2);
+        assertEquals(followers.size(), 2);
         RaftServer.Division newLeader = followers.get(0);
 
         // isolate new leader, so that transfer leadership will timeout
@@ -338,9 +335,9 @@ public abstract class LeaderElectionTests<CLUSTER extends 
MiniRaftCluster>
               client.admin().transferLeadership(newLeader.getId(), timeoutMs);
             } catch (TransferLeadershipException e) {
               long cost = System.currentTimeMillis() - start;
-              Assertions.assertTrue(cost > timeoutMs);
-              Assertions.assertTrue(e.getMessage().contains("Failed to 
transfer leadership to"));
-              
Assertions.assertTrue(e.getMessage().contains(TransferLeadership.Result.Type.TIMED_OUT.toString()));
+              assertTrue(cost > timeoutMs);
+              assertTrue(e.getMessage().contains("Failed to transfer 
leadership to"));
+              
assertTrue(e.getMessage().contains(TransferLeadership.Result.Type.TIMED_OUT.toString()));
             }
 
             return true;
@@ -354,17 +351,17 @@ public abstract class LeaderElectionTests<CLUSTER extends 
MiniRaftCluster>
           try {
             client.io().send(new RaftTestUtil.SimpleMessage("message"));
           } catch (LeaderSteppingDownException e) {
-            Assertions.assertTrue(e.getMessage().contains("is stepping down"));
+            assertTrue(e.getMessage().contains("is stepping down"));
           }
           return null;
         }, 5, TimeDuration.ONE_SECOND, "check leader steppingDown", 
RaftServer.LOG);
 
-        Assertions.assertTrue(transferTimeoutFuture.get());
+        assertTrue(transferTimeoutFuture.get());
 
         // after transfer timeout, leader should accept request
         RaftClientReply reply = client.io().send(new 
RaftTestUtil.SimpleMessage("message"));
-        Assertions.assertEquals(leader.getId().toString(), 
reply.getReplierId());
-        Assertions.assertTrue(reply.isSuccess());
+        assertEquals(leader.getId().toString(), reply.getReplierId());
+        assertTrue(reply.isSuccess());
 
         RaftTestUtil.deIsolate(cluster, newLeader.getId());
       }
@@ -402,7 +399,7 @@ public abstract class LeaderElectionTests<CLUSTER extends 
MiniRaftCluster>
     log.info(cluster.printServers());
 
     final RaftServer.Division leader = cluster.getLeader();
-    Assertions.assertEquals(newLeader, leader.getId().toString());
+    assertEquals(newLeader, leader.getId().toString());
   }
 
   @Test
@@ -431,7 +428,7 @@ public abstract class LeaderElectionTests<CLUSTER extends 
MiniRaftCluster>
             .orElseThrow(() -> new IllegalStateException("No leader yet")),
         10, ONE_SECOND, "getLeaderId", LOG);
     LOG.info(cluster.printServers());
-    Assertions.assertEquals(leader.getId(), lastServerLeaderId);
+    assertEquals(leader.getId(), lastServerLeaderId);
     cluster.shutdown();
   }
 
@@ -446,7 +443,7 @@ public abstract class LeaderElectionTests<CLUSTER extends 
MiniRaftCluster>
         RaftTestUtil.isolate(cluster, leader.getId());
         RaftClientReply reply = client.io().send(new 
RaftTestUtil.SimpleMessage("message"));
         Assertions.assertNotEquals(reply.getReplierId(), 
leader.getId().toString());
-        Assertions.assertTrue(reply.isSuccess());
+        assertTrue(reply.isSuccess());
       } finally {
         RaftTestUtil.deIsolate(cluster, leader.getId());
       }
@@ -463,15 +460,15 @@ public abstract class LeaderElectionTests<CLUSTER extends 
MiniRaftCluster>
       try (RaftClient client = cluster.createClient(leader.getId())) {
         client.io().send(new RaftTestUtil.SimpleMessage("message"));
         List<RaftPeer> servers = cluster.getPeers();
-        Assertions.assertEquals(servers.size(), 3);
+        assertEquals(servers.size(), 3);
         MiniRaftCluster.PeerChanges changes = cluster.addNewPeers(1,
             true, false, RaftProtos.RaftPeerRole.LISTENER);
         RaftClientReply reply = client.admin().setConfiguration(servers, 
Arrays.asList(changes.newPeers));
-        Assertions.assertTrue(reply.isSuccess());
+        assertTrue(reply.isSuccess());
         Collection<RaftPeer> listener =
             leader.getRaftConf().getAllPeers(RaftProtos.RaftPeerRole.LISTENER);
-        Assertions.assertEquals(1, listener.size());
-        Assertions.assertEquals(changes.newPeers[0].getId(), new 
ArrayList<>(listener).get(0).getId());
+        assertEquals(1, listener.size());
+        assertEquals(changes.newPeers[0].getId(), new 
ArrayList<>(listener).get(0).getId());
       }
       cluster.shutdown();
     }
@@ -485,18 +482,18 @@ public abstract class LeaderElectionTests<CLUSTER extends 
MiniRaftCluster>
       try (RaftClient client = cluster.createClient(leader.getId())) {
         client.io().send(new RaftTestUtil.SimpleMessage("message"));
         List<RaftPeer> servers = cluster.getPeers();
-        Assertions.assertEquals(4, servers.size());
+        assertEquals(4, servers.size());
         List<RaftPeer> listener = new ArrayList<>(
             
leader.getRaftConf().getAllPeers(RaftProtos.RaftPeerRole.LISTENER));
-        Assertions.assertEquals(1, listener.size());
+        assertEquals(1, listener.size());
         MiniRaftCluster.PeerChanges changes = cluster.addNewPeers(1, true, 
false);
         ArrayList<RaftPeer> newPeers = new 
ArrayList<>(Arrays.asList(changes.newPeers));
         
newPeers.addAll(leader.getRaftConf().getAllPeers(RaftProtos.RaftPeerRole.FOLLOWER));
         RaftClientReply reply = client.admin().setConfiguration(newPeers, 
listener);
-        Assertions.assertTrue(reply.isSuccess());
-        Assertions.assertEquals(4,
+        assertTrue(reply.isSuccess());
+        assertEquals(4,
             
leader.getRaftConf().getAllPeers(RaftProtos.RaftPeerRole.FOLLOWER).size());
-        Assertions.assertEquals(1,
+        assertEquals(1,
             
leader.getRaftConf().getAllPeers(RaftProtos.RaftPeerRole.LISTENER).size());
       }
       cluster.shutdown();
@@ -510,13 +507,13 @@ public abstract class LeaderElectionTests<CLUSTER extends 
MiniRaftCluster>
       final RaftServer.Division leader = waitForLeader(cluster);
       try (RaftClient client = cluster.createClient(leader.getId())) {
         client.io().send(new RaftTestUtil.SimpleMessage("message"));
-        Assertions.assertEquals(1, cluster.getListeners().size());
+        assertEquals(1, cluster.getListeners().size());
         List<RaftPeer> servers = 
cluster.getFollowers().stream().map(RaftServer.Division::getPeer).collect(
             Collectors.toList());
         servers.add(leader.getPeer());
         RaftClientReply reply = client.admin().setConfiguration(servers);
-        Assertions.assertTrue(reply.isSuccess());
-        Assertions.assertEquals(0, 
leader.getRaftConf().getAllPeers(RaftProtos.RaftPeerRole.LISTENER).size());
+        assertTrue(reply.isSuccess());
+        assertEquals(0, 
leader.getRaftConf().getAllPeers(RaftProtos.RaftPeerRole.LISTENER).size());
       }
       cluster.shutdown();
     }
@@ -531,15 +528,15 @@ public abstract class LeaderElectionTests<CLUSTER extends 
MiniRaftCluster>
         client.io().send(new RaftTestUtil.SimpleMessage("message"));
         List<RaftPeer> followers = cluster.getFollowers().stream().map(
             RaftServer.Division::getPeer).collect(Collectors.toList());
-        Assertions.assertEquals(2, followers.size());
+        assertEquals(2, followers.size());
         List<RaftPeer> listeners = new ArrayList<>();
         listeners.add(followers.get(1));
         followers.remove(1);
         RaftClientReply reply = client.admin().setConfiguration(followers, 
listeners);
-        Assertions.assertTrue(reply.isSuccess());
+        assertTrue(reply.isSuccess());
         Collection<RaftPeer> peer = 
leader.getRaftConf().getAllPeers(RaftProtos.RaftPeerRole.LISTENER);
-        Assertions.assertEquals(1, peer.size());
-        Assertions.assertEquals(listeners.get(0).getId(), new 
ArrayList<>(peer).get(0).getId());
+        assertEquals(1, peer.size());
+        assertEquals(listeners.get(0).getId(), new 
ArrayList<>(peer).get(0).getId());
       }
       cluster.shutdown();
     }
@@ -554,11 +551,11 @@ public abstract class LeaderElectionTests<CLUSTER extends 
MiniRaftCluster>
         client.io().send(new RaftTestUtil.SimpleMessage("message"));
         List<RaftPeer> listeners = cluster.getListeners()
             
.stream().map(RaftServer.Division::getPeer).collect(Collectors.toList());
-        Assertions.assertEquals(listeners.size(), 1);
+        assertEquals(listeners.size(), 1);
         RaftClientReply reply = 
client.admin().setConfiguration(cluster.getPeers());
-        Assertions.assertTrue(reply.isSuccess());
+        assertTrue(reply.isSuccess());
         Collection<RaftPeer> peer = 
leader.getRaftConf().getAllPeers(RaftProtos.RaftPeerRole.LISTENER);
-        Assertions.assertEquals(0, peer.size());
+        assertEquals(0, peer.size());
       }
       cluster.shutdown();
     }
@@ -638,7 +635,7 @@ public abstract class LeaderElectionTests<CLUSTER extends 
MiniRaftCluster>
         RaftTestUtil.isolate(cluster, follower.getId());
         // send message so that the isolated follower's log lag the others
         RaftClientReply reply = client.io().send(new 
RaftTestUtil.SimpleMessage("message"));
-        Assertions.assertTrue(reply.isSuccess());
+        assertTrue(reply.isSuccess());
 
         final long savedTerm = leader.getInfo().getCurrentTerm();
         LOG.info("Wait follower {} timeout and trigger pre-vote", 
follower.getId());
@@ -653,7 +650,7 @@ public abstract class LeaderElectionTests<CLUSTER extends 
MiniRaftCluster>
         assertEquals(savedTerm, leader.getInfo().getCurrentTerm());
 
         reply = client.io().send(new RaftTestUtil.SimpleMessage("message"));
-        Assertions.assertTrue(reply.isSuccess());
+        assertTrue(reply.isSuccess());
       }
 
       cluster.shutdown();
@@ -688,23 +685,23 @@ public abstract class LeaderElectionTests<CLUSTER extends 
MiniRaftCluster>
     final RaftServer.Division leader = RaftTestUtil.waitForLeader(cluster);
     final RaftPeerId leaderId = leader.getId();
     final List<RaftServer.Division> followers = cluster.getFollowers();
-    Assertions.assertTrue(followers.size() >= 1);
+    assertTrue(followers.size() >= 1);
     final RaftServerImpl f1 = (RaftServerImpl)followers.get(0);
 
     try (final RaftClient client = cluster.createClient()) {
       pauseLeaderReply = 
client.getLeaderElectionManagementApi(f1.getId()).pause();
-      Assertions.assertTrue(pauseLeaderReply.isSuccess());
+      assertTrue(pauseLeaderReply.isSuccess());
       client.io().send(new RaftTestUtil.SimpleMessage("message"));
       RaftServer.Division newLeader = followers.get(0);
       List<RaftPeer> peers = cluster.getPeers();
       List<RaftPeer> peersWithNewPriority = getPeersWithPriority(peers, 
newLeader.getPeer());
       RaftClientReply reply = 
client.admin().setConfiguration(peersWithNewPriority.toArray(new RaftPeer[0]));
-      Assertions.assertTrue(reply.isSuccess());
-      JavaUtils.attempt(() -> Assertions.assertEquals(leaderId, 
leader.getId()),
+      assertTrue(reply.isSuccess());
+      JavaUtils.attempt(() -> assertEquals(leaderId, leader.getId()),
           20, HUNDRED_MILLIS, "check leader id", LOG);
       final RaftClientReply resumeLeaderReply = 
client.getLeaderElectionManagementApi(f1.getId()).resume();
-      Assertions.assertTrue(resumeLeaderReply.isSuccess());
-      JavaUtils.attempt(() -> Assertions.assertEquals(f1.getId(), 
cluster.getLeader().getId()),
+      assertTrue(resumeLeaderReply.isSuccess());
+      JavaUtils.attempt(() -> assertEquals(f1.getId(), 
cluster.getLeader().getId()),
           20, HUNDRED_MILLIS, "check new leader", LOG);
     }
   }
@@ -730,15 +727,15 @@ public abstract class LeaderElectionTests<CLUSTER extends 
MiniRaftCluster>
     try (final RaftClient client = cluster.createClient(leader.getId())) {
       client.io().send(new RaftTestUtil.SimpleMessage("message"));
 
-      Assertions.assertTrue(leader.getInfo().isLeader());
-      Assertions.assertTrue(leader.getInfo().isLeaderReady());
+      assertTrue(leader.getInfo().isLeader());
+      assertTrue(leader.getInfo().isLeaderReady());
       RaftServerTestUtil.assertLeaderLease(leader, true);
 
       RaftTestUtil.isolate(cluster, leader.getId());
       Thread.sleep(leaseTimeoutMs);
 
-      Assertions.assertTrue(leader.getInfo().isLeader());
-      Assertions.assertTrue(leader.getInfo().isLeaderReady());
+      assertTrue(leader.getInfo().isLeader());
+      assertTrue(leader.getInfo().isLeaderReady());
       RaftServerTestUtil.assertLeaderLease(leader, false);
     } finally {
       RaftTestUtil.deIsolate(cluster, leader.getId());
@@ -759,8 +756,8 @@ public abstract class LeaderElectionTests<CLUSTER extends 
MiniRaftCluster>
     try (final RaftClient client = cluster.createClient(leader.getId())) {
       client.io().send(new RaftTestUtil.SimpleMessage("message"));
 
-      Assertions.assertTrue(leader.getInfo().isLeader());
-      Assertions.assertTrue(leader.getInfo().isLeaderReady());
+      assertTrue(leader.getInfo().isLeader());
+      assertTrue(leader.getInfo().isLeaderReady());
       RaftServerTestUtil.assertLeaderLease(leader, true);
 
       final List<RaftServer.Division> followers = cluster.getFollowers();
@@ -781,8 +778,8 @@ public abstract class LeaderElectionTests<CLUSTER extends 
MiniRaftCluster>
 
       Thread.sleep(leaseTimeoutMs);
 
-      Assertions.assertTrue(leader.getInfo().isLeader());
-      Assertions.assertTrue(leader.getInfo().isLeaderReady());
+      assertTrue(leader.getInfo().isLeader());
+      assertTrue(leader.getInfo().isLeaderReady());
       RaftServerTestUtil.assertLeaderLease(leader, false);
 
     } finally {
diff --git 
a/ratis-server/src/test/java/org/apache/ratis/server/impl/StateMachineShutdownTests.java
 
b/ratis-server/src/test/java/org/apache/ratis/server/impl/StateMachineShutdownTests.java
index 3333fdb85..d97c5c4d5 100644
--- 
a/ratis-server/src/test/java/org/apache/ratis/server/impl/StateMachineShutdownTests.java
+++ 
b/ratis-server/src/test/java/org/apache/ratis/server/impl/StateMachineShutdownTests.java
@@ -28,7 +28,10 @@ import org.apache.ratis.server.RaftServer;
 import org.apache.ratis.statemachine.impl.SimpleStateMachine4Testing;
 import org.apache.ratis.statemachine.StateMachine;
 import org.apache.ratis.statemachine.TransactionContext;
-import org.junit.*;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.mockito.MockedStatic;
 import org.mockito.Mockito;
 import org.slf4j.Logger;
@@ -121,12 +124,12 @@ public abstract class StateMachineShutdownTests<CLUSTER 
extends MiniRaftCluster>
     }
   }
 
-  @Before
+  @BeforeEach
   public void setup() {
     mocked = Mockito.mockStatic(CompletableFuture.class, 
Mockito.CALLS_REAL_METHODS);
   }
 
-  @After
+  @AfterEach
   public void tearDownClass() {
     if (mocked != null) {
       mocked.close();
@@ -162,10 +165,10 @@ public abstract class StateMachineShutdownTests<CLUSTER 
extends MiniRaftCluster>
       RaftClientReply watchReply = client.io().watch(
               logIndex, RaftProtos.ReplicationLevel.ALL_COMMITTED);
       watchReply.getCommitInfos().forEach(
-              val -> Assert.assertTrue(val.getCommitIndex() >= logIndex));
+              val -> Assertions.assertTrue(val.getCommitIndex() >= logIndex));
       final RaftServer.Division secondFollower = cluster.getFollowers().get(1);
       // Second follower is blocked in apply transaction
-      Assert.assertTrue(secondFollower.getInfo().getLastAppliedIndex() < 
logIndex);
+      Assertions.assertTrue(secondFollower.getInfo().getLastAppliedIndex() < 
logIndex);
 
       // Now shutdown the follower in a separate thread
       final Thread t = new Thread(secondFollower::close);
@@ -176,24 +179,24 @@ public abstract class StateMachineShutdownTests<CLUSTER 
extends MiniRaftCluster>
       // Now unblock the second follower
       long minIndex = ((StateMachineWithConditionalWait) 
secondFollower.getStateMachine()).blockTxns.stream()
               .min(Comparator.naturalOrder()).get();
-      Assert.assertEquals(2, 
StateMachineWithConditionalWait.numTxns.values().stream()
+      Assertions.assertEquals(2, 
StateMachineWithConditionalWait.numTxns.values().stream()
                       .filter(val -> val.get() == 3).count());
       // The second follower should still be blocked in apply transaction
-      Assert.assertTrue(secondFollower.getInfo().getLastAppliedIndex() < 
minIndex);
+      Assertions.assertTrue(secondFollower.getInfo().getLastAppliedIndex() < 
minIndex);
       for (long index : ((StateMachineWithConditionalWait) 
secondFollower.getStateMachine()).blockTxns) {
         if (minIndex != index) {
           ((StateMachineWithConditionalWait) 
secondFollower.getStateMachine()).unBlockApplyTxn(index);
         }
       }
-      Assert.assertEquals(2, 
StateMachineWithConditionalWait.numTxns.values().stream()
+      Assertions.assertEquals(2, 
StateMachineWithConditionalWait.numTxns.values().stream()
               .filter(val -> val.get() == 3).count());
-      Assert.assertTrue(secondFollower.getInfo().getLastAppliedIndex() < 
minIndex);
+      Assertions.assertTrue(secondFollower.getInfo().getLastAppliedIndex() < 
minIndex);
       ((StateMachineWithConditionalWait) 
secondFollower.getStateMachine()).unBlockApplyTxn(minIndex);
 
       // Now wait for the thread
       t.join(5000);
-      Assert.assertEquals(logIndex, 
secondFollower.getInfo().getLastAppliedIndex());
-      Assert.assertEquals(3, 
StateMachineWithConditionalWait.numTxns.values().stream()
+      Assertions.assertEquals(logIndex, 
secondFollower.getInfo().getLastAppliedIndex());
+      Assertions.assertEquals(3, 
StateMachineWithConditionalWait.numTxns.values().stream()
               .filter(val -> val.get() == 3).count());
 
       cluster.shutdown();
diff --git a/ratis-test/pom.xml b/ratis-test/pom.xml
index a47e9bd35..efd87bedd 100644
--- a/ratis-test/pom.xml
+++ b/ratis-test/pom.xml
@@ -131,11 +131,6 @@
       <scope>test</scope>
     </dependency>
 
-    <dependency>
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
-      <scope>test</scope>
-    </dependency>
     <dependency>
       <groupId>org.junit.jupiter</groupId>
       <artifactId>junit-jupiter-engine</artifactId>
@@ -151,11 +146,6 @@
       <artifactId>junit-jupiter-params</artifactId>
       <scope>test</scope>
     </dependency>
-    <dependency>
-      <groupId>org.junit.vintage</groupId>
-      <artifactId>junit-vintage-engine</artifactId>
-      <scope>test</scope>
-    </dependency>
     <dependency>
       <groupId>org.junit.platform</groupId>
       <artifactId>junit-platform-launcher</artifactId>


Reply via email to