[SCB-2475] migrate to junit5 governance part1 (#2950)
diff --git a/governance/src/test/java/org/apache/servicecomb/governance/handler/ext/RetryExtensionTest.java b/governance/src/test/java/org/apache/servicecomb/governance/handler/ext/RetryExtensionTest.java
index 8ceca63..2273d6a 100644
--- a/governance/src/test/java/org/apache/servicecomb/governance/handler/ext/RetryExtensionTest.java
+++ b/governance/src/test/java/org/apache/servicecomb/governance/handler/ext/RetryExtensionTest.java
@@ -24,8 +24,8 @@
import java.util.Arrays;
import java.util.List;
-import org.junit.Assert;
import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.ConfigDataApplicationContextInitializer;
import org.springframework.test.context.ContextConfiguration;
@@ -41,40 +41,40 @@
public void test_status_code_to_contains() {
List<String> statusList = Arrays.asList("502", "503");
boolean result = AbstractRetryExtension.statusCodeContains(statusList, "502");
- Assert.assertTrue(result);
+ Assertions.assertTrue(result);
result = AbstractRetryExtension.statusCodeContains(statusList, "504");
- Assert.assertFalse(result);
+ Assertions.assertFalse(result);
statusList = Arrays.asList("5xx", "4x4", "4x", "x32", "xx6");
result = AbstractRetryExtension.statusCodeContains(statusList, "502");
- Assert.assertTrue(result);
+ Assertions.assertTrue(result);
result = AbstractRetryExtension.statusCodeContains(statusList, "504");
- Assert.assertTrue(result);
+ Assertions.assertTrue(result);
statusList = Arrays.asList("4x4", "x32", "xx6");
result = AbstractRetryExtension.statusCodeContains(statusList, "402");
- Assert.assertFalse(result);
+ Assertions.assertFalse(result);
result = AbstractRetryExtension.statusCodeContains(statusList, "404");
- Assert.assertTrue(result);
+ Assertions.assertTrue(result);
result = AbstractRetryExtension.statusCodeContains(statusList, "332");
- Assert.assertTrue(result);
+ Assertions.assertTrue(result);
result = AbstractRetryExtension.statusCodeContains(statusList, "446");
- Assert.assertTrue(result);
+ Assertions.assertTrue(result);
statusList = Arrays.asList("4x", "x3x", "x5");
result = AbstractRetryExtension.statusCodeContains(statusList, "446");
- Assert.assertFalse(result);
+ Assertions.assertFalse(result);
result = AbstractRetryExtension.statusCodeContains(statusList, "455");
- Assert.assertFalse(result);
+ Assertions.assertFalse(result);
result = AbstractRetryExtension.statusCodeContains(statusList, "434");
- Assert.assertTrue(result);
+ Assertions.assertTrue(result);
}
@Test
@@ -82,7 +82,7 @@
Exception target = new ConnectException("connection refused");
Exception root = new Exception(target);
boolean canRetry = RetryExtension.canRetryForException(RetryExtension.STRICT_RETRIABLE, root);
- Assert.assertTrue(canRetry);
+ Assertions.assertTrue(canRetry);
}
@Test
@@ -90,7 +90,7 @@
Exception target = new SocketTimeoutException("Read timed out");
Exception root = new Exception(target);
boolean canRetry = RetryExtension.canRetryForException(RetryExtension.STRICT_RETRIABLE, root);
- Assert.assertTrue(canRetry);
+ Assertions.assertTrue(canRetry);
}
@Test
@@ -98,12 +98,12 @@
Exception target = new IOException("Connection reset by peer");
Exception root = new Exception(target);
boolean canRetry = RetryExtension.canRetryForException(RetryExtension.STRICT_RETRIABLE, root);
- Assert.assertTrue(canRetry);
+ Assertions.assertTrue(canRetry);
target = new IOException("Target not exist");
root = new Exception(target);
canRetry = RetryExtension.canRetryForException(RetryExtension.STRICT_RETRIABLE, root);
- Assert.assertFalse(canRetry);
+ Assertions.assertFalse(canRetry);
}
@Test
@@ -111,12 +111,12 @@
Exception target = new VertxException("Connection was closed");
Exception root = new Exception(target);
boolean canRetry = RetryExtension.canRetryForException(RetryExtension.STRICT_RETRIABLE, root);
- Assert.assertTrue(canRetry);
+ Assertions.assertTrue(canRetry);
target = new IOException("");
root = new Exception(target);
canRetry = RetryExtension.canRetryForException(RetryExtension.STRICT_RETRIABLE, root);
- Assert.assertFalse(canRetry);
+ Assertions.assertFalse(canRetry);
}
@Test
@@ -124,12 +124,12 @@
Exception target = new NoRouteToHostException("Host is unreachable");
Exception root = new Exception(target);
boolean canRetry = RetryExtension.canRetryForException(RetryExtension.STRICT_RETRIABLE, root);
- Assert.assertTrue(canRetry);
+ Assertions.assertTrue(canRetry);
target = new NoRouteToHostException("No route to host");
root = new Exception(target);
canRetry = RetryExtension.canRetryForException(RetryExtension.STRICT_RETRIABLE, root);
- Assert.assertTrue(canRetry);
+ Assertions.assertTrue(canRetry);
}
@Test
@@ -140,7 +140,7 @@
}
Exception root = new Exception(target);
boolean canRetry = RetryExtension.canRetryForException(RetryExtension.STRICT_RETRIABLE, root);
- Assert.assertTrue(canRetry);
+ Assertions.assertTrue(canRetry);
}
@Test
@@ -151,6 +151,6 @@
}
Exception root = new Exception(target);
boolean canRetry = RetryExtension.canRetryForException(RetryExtension.STRICT_RETRIABLE, root);
- Assert.assertFalse(canRetry);
+ Assertions.assertFalse(canRetry);
}
}
diff --git a/governance/src/test/java/org/apache/servicecomb/router/RouterDistributorTest.java b/governance/src/test/java/org/apache/servicecomb/router/RouterDistributorTest.java
index a374602..5a2856c 100644
--- a/governance/src/test/java/org/apache/servicecomb/router/RouterDistributorTest.java
+++ b/governance/src/test/java/org/apache/servicecomb/router/RouterDistributorTest.java
@@ -19,9 +19,9 @@
import org.apache.servicecomb.router.cache.RouterRuleCache;
import org.apache.servicecomb.router.distribute.RouterDistributor;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.ConfigDataApplicationContextInitializer;
@@ -122,7 +122,7 @@
public void testHeaderIsEmpty() {
List<ServiceIns> list = getMockList();
List<ServiceIns> serverList = mainFilter(list, Collections.emptyMap());
- Assert.assertEquals(2, serverList.size());
+ Assertions.assertEquals(2, serverList.size());
}
@Test
@@ -134,8 +134,8 @@
List<ServiceIns> list = getMockList();
list.remove(1);
List<ServiceIns> serverList = mainFilter(list, headerMap);
- Assert.assertEquals(1, serverList.size());
- Assert.assertEquals("01", serverList.get(0).getId());
+ Assertions.assertEquals(1, serverList.size());
+ Assertions.assertEquals("01", serverList.get(0).getId());
}
@Test
@@ -145,8 +145,8 @@
headers.put("appId", "01");
headers.put("format", "json");
List<ServiceIns> serverList = mainFilter(getMockList(), headers);
- Assert.assertEquals(1, serverList.size());
- Assert.assertEquals("02", serverList.get(0).getId());
+ Assertions.assertEquals(1, serverList.size());
+ Assertions.assertEquals("02", serverList.get(0).getId());
}
private List<ServiceIns> getMockList() {
diff --git a/governance/src/test/java/org/apache/servicecomb/router/VersionCompareUtilTest.java b/governance/src/test/java/org/apache/servicecomb/router/VersionCompareUtilTest.java
index 46ee61e..d4438a9 100644
--- a/governance/src/test/java/org/apache/servicecomb/router/VersionCompareUtilTest.java
+++ b/governance/src/test/java/org/apache/servicecomb/router/VersionCompareUtilTest.java
@@ -17,18 +17,18 @@
package org.apache.servicecomb.router;
import org.apache.servicecomb.router.util.VersionCompareUtil;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class VersionCompareUtilTest {
@Test
public void testVersion() {
- Assert.assertTrue(VersionCompareUtil.compareVersion("0.0.1", "0.0.0") > 0);
- Assert.assertEquals(0, VersionCompareUtil.compareVersion("0.0.0", "0.0.0"));
- Assert.assertTrue(VersionCompareUtil.compareVersion("0.0.0", "0.0.1") < 0);
- Assert.assertEquals(0, VersionCompareUtil.compareVersion("0.0.0", "0.0.0.0"));
- Assert.assertTrue(VersionCompareUtil.compareVersion("0.0.1", "0.0.0.0") > 0);
- Assert.assertTrue(VersionCompareUtil.compareVersion("0.0.1", "0.0.0.0") > 0);
+ Assertions.assertTrue(VersionCompareUtil.compareVersion("0.0.1", "0.0.0") > 0);
+ Assertions.assertEquals(0, VersionCompareUtil.compareVersion("0.0.0", "0.0.0"));
+ Assertions.assertTrue(VersionCompareUtil.compareVersion("0.0.0", "0.0.1") < 0);
+ Assertions.assertEquals(0, VersionCompareUtil.compareVersion("0.0.0", "0.0.0.0"));
+ Assertions.assertTrue(VersionCompareUtil.compareVersion("0.0.1", "0.0.0.0") > 0);
+ Assertions.assertTrue(VersionCompareUtil.compareVersion("0.0.1", "0.0.0.0") > 0);
}
}