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


The following commit(s) were added to refs/heads/master by this push:
     new 0269873ff RATIS-1970. Add junit 5 dependencies in ratis-common. (#993)
0269873ff is described below

commit 0269873ff17921a6289c91efb47fccddf7e450a1
Author: Nandakumar Vadivelu <[email protected]>
AuthorDate: Wed Dec 20 03:12:03 2023 +0530

    RATIS-1970. Add junit 5 dependencies in ratis-common. (#993)
---
 pom.xml                                            |  8 +++++++
 ratis-common/pom.xml                               | 26 ++++++++++++++++++++++
 .../java/org/apache/ratis/util/TestFileUtils.java  | 22 +++++++++---------
 .../java/org/apache/ratis/util/TestNetUtils.java   |  7 +++---
 .../org/apache/ratis/util/TestPureJavaCrc32C.java  |  6 ++---
 .../java/org/apache/ratis/util/TestTaskQueue.java  |  6 ++---
 6 files changed, 54 insertions(+), 21 deletions(-)

diff --git a/pom.xml b/pom.xml
index 54aead776..8841644da 100644
--- a/pom.xml
+++ b/pom.xml
@@ -221,6 +221,7 @@
     <testsThreadCount>4</testsThreadCount>
 
     <slf4j.version>2.0.7</slf4j.version>
+    <junit.jupiter.version>5.10.1</junit.jupiter.version>
   </properties>
 
   <dependencyManagement>
@@ -420,6 +421,13 @@
         <artifactId>junit</artifactId>
         <version>4.13.2</version>
       </dependency>
+      <dependency>
+        <groupId>org.junit</groupId>
+        <artifactId>junit-bom</artifactId>
+        <version>${junit.jupiter.version}</version>
+        <type>pom</type>
+        <scope>import</scope>
+      </dependency>
       <dependency>
         <groupId>org.mockito</groupId>
         <artifactId>mockito-core</artifactId>
diff --git a/ratis-common/pom.xml b/ratis-common/pom.xml
index 42e0bc905..9bb36bcce 100644
--- a/ratis-common/pom.xml
+++ b/ratis-common/pom.xml
@@ -44,6 +44,32 @@
       <scope>test</scope>
     </dependency>
 
+    <dependency>
+      <groupId>org.junit.jupiter</groupId>
+      <artifactId>junit-jupiter-api</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.junit.jupiter</groupId>
+      <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>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.junit.jupiter</groupId>
+      <artifactId>junit-jupiter-params</artifactId>
+      <scope>test</scope>
+    </dependency>
+
     <dependency>
       <groupId>com.github.spotbugs</groupId>
       <artifactId>spotbugs-annotations</artifactId>
diff --git 
a/ratis-common/src/test/java/org/apache/ratis/util/TestFileUtils.java 
b/ratis-common/src/test/java/org/apache/ratis/util/TestFileUtils.java
index 720fc2c17..3171756b8 100644
--- a/ratis-common/src/test/java/org/apache/ratis/util/TestFileUtils.java
+++ b/ratis-common/src/test/java/org/apache/ratis/util/TestFileUtils.java
@@ -18,8 +18,8 @@
 package org.apache.ratis.util;
 
 import org.apache.ratis.BaseTest;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
 
 import java.io.File;
 import java.io.IOException;
@@ -30,27 +30,27 @@ public class TestFileUtils extends BaseTest {
   @Test
   public void testRenameToCorrupt() throws IOException {
     final File dir = getClassTestDir();
-    Assert.assertTrue(dir.mkdirs());
+    Assertions.assertTrue(dir.mkdirs());
     try {
       runTestRenameToCorrupt(dir);
     } finally {
       FileUtils.deleteFully(dir);
     }
-    Assert.assertFalse(dir.exists());
+    Assertions.assertFalse(dir.exists());
   }
 
   static void runTestRenameToCorrupt(File dir) throws IOException {
     final File srcFile = new File(dir, "snapshot.1_20");
-    Assert.assertFalse(srcFile.exists());
-    Assert.assertTrue(srcFile.createNewFile());
-    Assert.assertTrue(srcFile.exists());
+    Assertions.assertFalse(srcFile.exists());
+    Assertions.assertTrue(srcFile.createNewFile());
+    Assertions.assertTrue(srcFile.exists());
 
     final File renamed = FileUtils.move(srcFile, ".corrupt");
-    Assert.assertNotNull(renamed);
-    Assert.assertTrue(renamed.exists());
-    Assert.assertFalse(srcFile.exists());
+    Assertions.assertNotNull(renamed);
+    Assertions.assertTrue(renamed.exists());
+    Assertions.assertFalse(srcFile.exists());
 
     FileUtils.deleteFully(renamed);
-    Assert.assertFalse(renamed.exists());
+    Assertions.assertFalse(renamed.exists());
   }
 }
diff --git a/ratis-common/src/test/java/org/apache/ratis/util/TestNetUtils.java 
b/ratis-common/src/test/java/org/apache/ratis/util/TestNetUtils.java
index 8fea1a12e..6fb85e263 100644
--- a/ratis-common/src/test/java/org/apache/ratis/util/TestNetUtils.java
+++ b/ratis-common/src/test/java/org/apache/ratis/util/TestNetUtils.java
@@ -17,21 +17,20 @@
  */
 package org.apache.ratis.util;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
 
 import java.net.InetSocketAddress;
 import java.util.List;
 import java.util.stream.Collectors;
 
-import static org.junit.Assert.assertEquals;
-
 public class TestNetUtils {
 
   @Test
   public void createsUniqueAddresses() {
     for (int i = 0; i < 10; i++) {
       List<InetSocketAddress> addresses = 
NetUtils.createLocalServerAddress(100);
-      assertEquals(addresses.stream().distinct().collect(Collectors.toList()), 
addresses);
+      
Assertions.assertEquals(addresses.stream().distinct().collect(Collectors.toList()),
 addresses);
     }
   }
 }
diff --git 
a/ratis-common/src/test/java/org/apache/ratis/util/TestPureJavaCrc32C.java 
b/ratis-common/src/test/java/org/apache/ratis/util/TestPureJavaCrc32C.java
index 5a695fd84..3ba373d80 100644
--- a/ratis-common/src/test/java/org/apache/ratis/util/TestPureJavaCrc32C.java
+++ b/ratis-common/src/test/java/org/apache/ratis/util/TestPureJavaCrc32C.java
@@ -18,8 +18,8 @@
 package org.apache.ratis.util;
 
 import org.apache.ratis.BaseTest;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
 
 import java.nio.ByteBuffer;
 import java.util.concurrent.ThreadLocalRandom;
@@ -52,7 +52,7 @@ public class TestPureJavaCrc32C extends BaseTest {
       buffer.position(off).limit(off + len);
       bufferCrc.update(buffer);
 
-      Assert.assertEquals(arrayCrc.getValue(), bufferCrc.getValue());
+      Assertions.assertEquals(arrayCrc.getValue(), bufferCrc.getValue());
       off += len;
     }
   }
diff --git 
a/ratis-common/src/test/java/org/apache/ratis/util/TestTaskQueue.java 
b/ratis-common/src/test/java/org/apache/ratis/util/TestTaskQueue.java
index b0e587012..063a130c4 100644
--- a/ratis-common/src/test/java/org/apache/ratis/util/TestTaskQueue.java
+++ b/ratis-common/src/test/java/org/apache/ratis/util/TestTaskQueue.java
@@ -17,8 +17,8 @@
  */
 package org.apache.ratis.util;
 
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
 
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
@@ -42,7 +42,7 @@ public class TestTaskQueue {
     for(int i = 0; i < 10; i++) {
       final int id = i;
       q.submit(() -> randomSleep(id), executor)
-          .thenAccept(j -> Assert.assertTrue("Queue is not empty after task " 
+ id + " completed", q.isEmpty()))
+          .thenAccept(j -> Assertions.assertTrue(q.isEmpty(), "Queue is not 
empty after task " + id + " completed"))
           .get();
     }
   }

Reply via email to