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

adoroszlai 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 a2cb49e8c RATIS-1975. Migrate ratis-metrics-dropwizard3 tests to Junit 
5. (#1037)
a2cb49e8c is described below

commit a2cb49e8cb64c30c1f7f7adb82f87477501f522d
Author: Nandakumar Vadivelu <[email protected]>
AuthorDate: Thu Feb 1 21:34:03 2024 +0530

    RATIS-1975. Migrate ratis-metrics-dropwizard3 tests to Junit 5. (#1037)
---
 ratis-metrics-dropwizard3/pom.xml                      | 10 ++++++++++
 .../dropwizard3/TestLoadDm3MetricRegistries.java       | 14 +++++++-------
 .../ratis/metrics/dropwizard3/TestRefCountingMap.java  | 18 +++++++++---------
 3 files changed, 26 insertions(+), 16 deletions(-)

diff --git a/ratis-metrics-dropwizard3/pom.xml 
b/ratis-metrics-dropwizard3/pom.xml
index 04b86cbaa..42fff0445 100644
--- a/ratis-metrics-dropwizard3/pom.xml
+++ b/ratis-metrics-dropwizard3/pom.xml
@@ -58,6 +58,16 @@
       <artifactId>junit</artifactId>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>org.junit.jupiter</groupId>
+      <artifactId>junit-jupiter-engine</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.junit.jupiter</groupId>
+      <artifactId>junit-jupiter-api</artifactId>
+      <scope>test</scope>
+    </dependency>
     <dependency>
       <groupId>org.mockito</groupId>
       <artifactId>mockito-core</artifactId>
diff --git 
a/ratis-metrics-dropwizard3/src/test/java/org/apache/ratis/metrics/dropwizard3/TestLoadDm3MetricRegistries.java
 
b/ratis-metrics-dropwizard3/src/test/java/org/apache/ratis/metrics/dropwizard3/TestLoadDm3MetricRegistries.java
index 92a36f5c8..5b3897ffd 100644
--- 
a/ratis-metrics-dropwizard3/src/test/java/org/apache/ratis/metrics/dropwizard3/TestLoadDm3MetricRegistries.java
+++ 
b/ratis-metrics-dropwizard3/src/test/java/org/apache/ratis/metrics/dropwizard3/TestLoadDm3MetricRegistries.java
@@ -23,8 +23,8 @@ import org.apache.ratis.metrics.MetricRegistries;
 import org.apache.ratis.metrics.MetricRegistriesLoader;
 import org.apache.ratis.metrics.MetricRegistryInfo;
 import org.apache.ratis.metrics.RatisMetricRegistry;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
 
 /**
  * Test class for {@link MetricRegistriesLoader}.
@@ -33,7 +33,7 @@ public class TestLoadDm3MetricRegistries {
   @Test
   public void testLoadDm3() {
     final MetricRegistries r = MetricRegistriesLoader.load();
-    Assert.assertSame(Dm3MetricRegistriesImpl.class, r.getClass());
+    Assertions.assertSame(Dm3MetricRegistriesImpl.class, r.getClass());
   }
 
   @Test
@@ -47,15 +47,15 @@ public class TestLoadDm3MetricRegistries {
     // check if add and remove of metric do reporting counter increase
     MetricRegistryInfo info = new MetricRegistryInfo("t1", "t1", "t1", "t1");
     r.create(info);
-    Assert.assertTrue(cntr.get() == 1);
+    Assertions.assertEquals(1, cntr.get());
     r.remove(info);
-    Assert.assertTrue(cntr.get() == 2);
+    Assertions.assertEquals(2, cntr.get());
 
     // after removal, add and remove of metric must not do any increase
     r.removeReporterRegistration(reporter, stopReporter);
     r.create(info);
-    Assert.assertTrue(cntr.get() == 2);
+    Assertions.assertEquals(2, cntr.get());
     r.remove(info);
-    Assert.assertTrue(cntr.get() == 2);
+    Assertions.assertEquals(2, cntr.get());
   }
 }
diff --git 
a/ratis-metrics-dropwizard3/src/test/java/org/apache/ratis/metrics/dropwizard3/TestRefCountingMap.java
 
b/ratis-metrics-dropwizard3/src/test/java/org/apache/ratis/metrics/dropwizard3/TestRefCountingMap.java
index 1aa15d37c..87b8bf012 100644
--- 
a/ratis-metrics-dropwizard3/src/test/java/org/apache/ratis/metrics/dropwizard3/TestRefCountingMap.java
+++ 
b/ratis-metrics-dropwizard3/src/test/java/org/apache/ratis/metrics/dropwizard3/TestRefCountingMap.java
@@ -17,23 +17,23 @@
  */
 package org.apache.ratis.metrics.dropwizard3;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.util.Collection;
 import java.util.Set;
 
 import org.apache.ratis.thirdparty.com.google.common.collect.Lists;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 public class TestRefCountingMap {
 
   private RefCountingMap<String, String> map;
 
-  @Before
+  @BeforeEach
   public void setUp() {
     map = new RefCountingMap<>();
   }
@@ -128,7 +128,7 @@ public class TestRefCountingMap {
     Set<String> keys = map.keySet();
     assertEquals(3, keys.size());
 
-    Lists.newArrayList("foo", "bar", "baz").stream().forEach(v -> 
assertTrue(keys.contains(v)));
+    Lists.newArrayList("foo", "bar", "baz").forEach(v -> 
assertTrue(keys.contains(v)));
   }
 
   @Test
@@ -141,7 +141,7 @@ public class TestRefCountingMap {
     Collection<String> values = map.values();
     assertEquals(3, values.size());
 
-    Lists.newArrayList("foovalue", "foovalue3", "foovalue4").stream()
+    Lists.newArrayList("foovalue", "foovalue3", "foovalue4")
             .forEach(v -> assertTrue(values.contains(v)));
   }
 }

Reply via email to