This is an automated email from the ASF dual-hosted git repository.
xiaoyu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-shenyu.git
The following commit(s) were added to refs/heads/master by this push:
new 73a5039 [ISSUE 2830] Update junit4 to junit5 - update for common
module (#2841)
73a5039 is described below
commit 73a50390d858028cd5264d07e29f86946adae27f
Author: Han Gao <[email protected]>
AuthorDate: Wed Feb 9 16:34:07 2022 +0800
[ISSUE 2830] Update junit4 to junit5 - update for common module (#2841)
* migrating to junit5
* migrate from junit4 to 5 for common project
* fix comment issues
---
shenyu-common/pom.xml | 7 +++
.../common/concurrent/ShenyuThreadFactoryTest.java | 4 +-
.../common/constant/DefaultPathConstantsTest.java | 4 +-
.../common/constant/RedisKeyConstantsTest.java | 4 +-
.../apache/shenyu/common/dto/ConfigDataTest.java | 7 ++-
.../org/apache/shenyu/common/dto/MetaDataTest.java | 8 +--
.../common/enums/AdminPluginOperateEnumTest.java | 4 +-
.../shenyu/common/enums/AdminResourceEnumTest.java | 4 +-
.../shenyu/common/enums/ConfigGroupEnumTest.java | 16 ++----
.../shenyu/common/enums/DataEventTypeEnumTest.java | 10 ++--
.../shenyu/common/enums/DataSyncEnumTest.java | 4 +-
.../shenyu/common/enums/HttpMethodEnumTest.java | 13 +++--
.../common/enums/HystrixIsolationModeEnumTest.java | 4 +-
.../shenyu/common/enums/LoadBalanceEnumTest.java | 24 ++++----
.../shenyu/common/enums/MatchModeEnumTest.java | 6 +-
.../shenyu/common/enums/OperatorEnumTest.java | 9 +--
.../shenyu/common/enums/ParamTypeEnumTest.java | 16 +++---
.../apache/shenyu/common/enums/PluginEnumTest.java | 5 +-
.../shenyu/common/enums/PluginRoleEnumTest.java | 5 +-
.../shenyu/common/enums/PluginTypeEnumTest.java | 4 +-
.../shenyu/common/enums/RateLimitEnumTest.java | 5 +-
.../shenyu/common/enums/RedisModeEnumTest.java | 6 +-
.../apache/shenyu/common/enums/ResultEnumTest.java | 4 +-
.../shenyu/common/enums/RpcTypeEnumTest.java | 11 ++--
.../shenyu/common/enums/SelectorTypeEnumTest.java | 6 +-
.../shenyu/common/enums/SerializeEnumTest.java | 9 ++-
.../apache/shenyu/common/enums/WafEnumTest.java | 4 +-
.../shenyu/common/enums/WafModelEnumTest.java | 4 +-
.../common/exception/CommonErrorCodeTest.java | 4 +-
.../common/exception/SerializerExceptionTest.java | 6 +-
.../common/exception/ShenyuExceptionTest.java | 6 +-
.../common/timer/HierarchicalWheelTimerTest.java | 24 ++++----
.../shenyu/common/timer/WheelTimerFactoryTest.java | 9 +--
.../apache/shenyu/common/utils/DateUtilsTest.java | 5 +-
.../apache/shenyu/common/utils/GsonUtilsTest.java | 64 +++++++++++-----------
.../common/utils/HttpParamConverterTest.java | 22 ++------
.../apache/shenyu/common/utils/IpUtilsTest.java | 16 +++---
.../apache/shenyu/common/utils/JsonUtilsTest.java | 8 +--
.../apache/shenyu/common/utils/LogUtilsTest.java | 6 +-
.../apache/shenyu/common/utils/Md5UtilsTest.java | 4 +-
.../shenyu/common/utils/ParamCheckUtilsTest.java | 6 +-
.../shenyu/common/utils/PathMatchUtilsTest.java | 6 +-
.../shenyu/common/utils/ReflectUtilsTest.java | 6 +-
.../apache/shenyu/common/utils/SignUtilsTest.java | 6 +-
.../shenyu/common/utils/SpiLoadFactoryTest.java | 9 +--
.../shenyu/common/utils/ThreadUtilsTest.java | 11 ++--
.../apache/shenyu/common/utils/UUIDUtilsTest.java | 18 +++---
.../common/utils/UpstreamCheckUtilsTest.java | 11 ++--
.../shenyu/common/utils/VersionUtilsTest.java | 4 +-
.../plugin/resilience4j/core/RateLimiterTest.java | 9 +--
50 files changed, 239 insertions(+), 228 deletions(-)
diff --git a/shenyu-common/pom.xml b/shenyu-common/pom.xml
index 706924e..c8408cf 100644
--- a/shenyu-common/pom.xml
+++ b/shenyu-common/pom.xml
@@ -63,6 +63,13 @@
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
</dependency>
+
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter</artifactId>
+ <scope>test</scope>
+ </dependency>
+
</dependencies>
</project>
diff --git
a/shenyu-common/src/test/java/org/apache/shenyu/common/concurrent/ShenyuThreadFactoryTest.java
b/shenyu-common/src/test/java/org/apache/shenyu/common/concurrent/ShenyuThreadFactoryTest.java
index e8dbc30..6ac2179 100644
---
a/shenyu-common/src/test/java/org/apache/shenyu/common/concurrent/ShenyuThreadFactoryTest.java
+++
b/shenyu-common/src/test/java/org/apache/shenyu/common/concurrent/ShenyuThreadFactoryTest.java
@@ -17,12 +17,12 @@
package org.apache.shenyu.common.concurrent;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.concurrent.ThreadFactory;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.notNullValue;
-import static org.junit.Assert.assertThat;
/**
* Test cases for ShenyuThreadFactory.
diff --git
a/shenyu-common/src/test/java/org/apache/shenyu/common/constant/DefaultPathConstantsTest.java
b/shenyu-common/src/test/java/org/apache/shenyu/common/constant/DefaultPathConstantsTest.java
index 1a56680..8458cb4 100644
---
a/shenyu-common/src/test/java/org/apache/shenyu/common/constant/DefaultPathConstantsTest.java
+++
b/shenyu-common/src/test/java/org/apache/shenyu/common/constant/DefaultPathConstantsTest.java
@@ -18,11 +18,11 @@
package org.apache.shenyu.common.constant;
import org.apache.commons.lang3.RandomStringUtils;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.notNullValue;
-import static org.junit.Assert.assertThat;
/**
* Test cases for ZkPathConstants.
diff --git
a/shenyu-common/src/test/java/org/apache/shenyu/common/constant/RedisKeyConstantsTest.java
b/shenyu-common/src/test/java/org/apache/shenyu/common/constant/RedisKeyConstantsTest.java
index e0e9837..74e4398 100644
---
a/shenyu-common/src/test/java/org/apache/shenyu/common/constant/RedisKeyConstantsTest.java
+++
b/shenyu-common/src/test/java/org/apache/shenyu/common/constant/RedisKeyConstantsTest.java
@@ -17,11 +17,11 @@
package org.apache.shenyu.common.constant;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.notNullValue;
-import static org.junit.Assert.assertThat;
/**
* Test cases for RedisKeyConstants.
diff --git
a/shenyu-common/src/test/java/org/apache/shenyu/common/dto/ConfigDataTest.java
b/shenyu-common/src/test/java/org/apache/shenyu/common/dto/ConfigDataTest.java
index 0abff48..b2fc946 100644
---
a/shenyu-common/src/test/java/org/apache/shenyu/common/dto/ConfigDataTest.java
+++
b/shenyu-common/src/test/java/org/apache/shenyu/common/dto/ConfigDataTest.java
@@ -17,12 +17,13 @@
package org.apache.shenyu.common.dto;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.Collections;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
/**
* Test case for ConfigData.
diff --git
a/shenyu-common/src/test/java/org/apache/shenyu/common/dto/MetaDataTest.java
b/shenyu-common/src/test/java/org/apache/shenyu/common/dto/MetaDataTest.java
index 0c9a454..32ebf44 100644
--- a/shenyu-common/src/test/java/org/apache/shenyu/common/dto/MetaDataTest.java
+++ b/shenyu-common/src/test/java/org/apache/shenyu/common/dto/MetaDataTest.java
@@ -18,11 +18,11 @@
package org.apache.shenyu.common.dto;
import org.apache.commons.lang3.StringUtils;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
/**
* Test case for MetaData.
diff --git
a/shenyu-common/src/test/java/org/apache/shenyu/common/enums/AdminPluginOperateEnumTest.java
b/shenyu-common/src/test/java/org/apache/shenyu/common/enums/AdminPluginOperateEnumTest.java
index 9016412..d55c9f0 100644
---
a/shenyu-common/src/test/java/org/apache/shenyu/common/enums/AdminPluginOperateEnumTest.java
+++
b/shenyu-common/src/test/java/org/apache/shenyu/common/enums/AdminPluginOperateEnumTest.java
@@ -17,9 +17,9 @@
package org.apache.shenyu.common.enums;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class AdminPluginOperateEnumTest {
@Test
diff --git
a/shenyu-common/src/test/java/org/apache/shenyu/common/enums/AdminResourceEnumTest.java
b/shenyu-common/src/test/java/org/apache/shenyu/common/enums/AdminResourceEnumTest.java
index ccc00dc..5d34e70 100644
---
a/shenyu-common/src/test/java/org/apache/shenyu/common/enums/AdminResourceEnumTest.java
+++
b/shenyu-common/src/test/java/org/apache/shenyu/common/enums/AdminResourceEnumTest.java
@@ -17,9 +17,9 @@
package org.apache.shenyu.common.enums;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class AdminResourceEnumTest {
@Test
diff --git
a/shenyu-common/src/test/java/org/apache/shenyu/common/enums/ConfigGroupEnumTest.java
b/shenyu-common/src/test/java/org/apache/shenyu/common/enums/ConfigGroupEnumTest.java
index 8ceeb6c..475f888 100644
---
a/shenyu-common/src/test/java/org/apache/shenyu/common/enums/ConfigGroupEnumTest.java
+++
b/shenyu-common/src/test/java/org/apache/shenyu/common/enums/ConfigGroupEnumTest.java
@@ -18,29 +18,25 @@
package org.apache.shenyu.common.enums;
import org.apache.shenyu.common.exception.ShenyuException;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.Test;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.not;
-import static org.junit.Assert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
/**
* Test Cases for ConfigGroupEnum.
*/
public final class ConfigGroupEnumTest {
- @Rule
- public ExpectedException expectedEx = ExpectedException.none();
-
@Test
public void testAcquireByName() {
assertThat(ConfigGroupEnum.APP_AUTH,
equalTo(ConfigGroupEnum.acquireByName(ConfigGroupEnum.APP_AUTH.name())));
assertThat(ConfigGroupEnum.APP_AUTH,
not(ConfigGroupEnum.acquireByName(ConfigGroupEnum.PLUGIN.name())));
- expectedEx.expect(ShenyuException.class);
- expectedEx.expectMessage("this ConfigGroupEnum can not support
unknown");
- ConfigGroupEnum.acquireByName("unknown");
+ Exception exception = assertThrows(ShenyuException.class, () ->
ConfigGroupEnum.acquireByName("unknown"));
+ assertEquals(" this ConfigGroupEnum can not support unknown",
exception.getMessage());
}
}
diff --git
a/shenyu-common/src/test/java/org/apache/shenyu/common/enums/DataEventTypeEnumTest.java
b/shenyu-common/src/test/java/org/apache/shenyu/common/enums/DataEventTypeEnumTest.java
index ed40cf7..f3c8d5f 100644
---
a/shenyu-common/src/test/java/org/apache/shenyu/common/enums/DataEventTypeEnumTest.java
+++
b/shenyu-common/src/test/java/org/apache/shenyu/common/enums/DataEventTypeEnumTest.java
@@ -19,11 +19,13 @@ package org.apache.shenyu.common.enums;
import org.apache.shenyu.common.exception.ShenyuException;
import org.hamcrest.Matchers;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.Arrays;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
/**
* Test Cases for DataEventTypeEnum.
@@ -36,8 +38,8 @@ public final class DataEventTypeEnumTest {
.forEach(e -> assertThat(e,
Matchers.equalTo(DataEventTypeEnum.acquireByName(e.name()))));
}
- @Test(expected = ShenyuException.class)
+ @Test
public void testAcquireByNameInvalid() {
- DataEventTypeEnum.acquireByName("invalidName");
+ assertThrows(ShenyuException.class, () ->
DataEventTypeEnum.acquireByName("invalidName"));
}
}
diff --git
a/shenyu-common/src/test/java/org/apache/shenyu/common/enums/DataSyncEnumTest.java
b/shenyu-common/src/test/java/org/apache/shenyu/common/enums/DataSyncEnumTest.java
index 6884860..14942b1 100644
---
a/shenyu-common/src/test/java/org/apache/shenyu/common/enums/DataSyncEnumTest.java
+++
b/shenyu-common/src/test/java/org/apache/shenyu/common/enums/DataSyncEnumTest.java
@@ -17,9 +17,9 @@
package org.apache.shenyu.common.enums;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Test Cases for DataSyncEnum.
diff --git
a/shenyu-common/src/test/java/org/apache/shenyu/common/enums/HttpMethodEnumTest.java
b/shenyu-common/src/test/java/org/apache/shenyu/common/enums/HttpMethodEnumTest.java
index 7bd2bb7..a2c6330 100644
---
a/shenyu-common/src/test/java/org/apache/shenyu/common/enums/HttpMethodEnumTest.java
+++
b/shenyu-common/src/test/java/org/apache/shenyu/common/enums/HttpMethodEnumTest.java
@@ -17,12 +17,13 @@
package org.apache.shenyu.common.enums;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
import java.util.Arrays;
import org.apache.shenyu.common.exception.ShenyuException;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertThrows;
/** Test Cases for HttpMethodEnum. */
public final class HttpMethodEnumTest {
@@ -49,9 +50,9 @@ public final class HttpMethodEnumTest {
.forEach(e -> assertEquals(e,
HttpMethodEnum.acquireByName(e.getName())));
}
- @Test(expected = ShenyuException.class)
+ @Test
public void testAcquireByNameInvalid() {
String httpMethodName = "InvalidName";
- HttpMethodEnum.acquireByName(httpMethodName);
+ assertThrows(ShenyuException.class, () ->
HttpMethodEnum.acquireByName(httpMethodName));
}
}
diff --git
a/shenyu-common/src/test/java/org/apache/shenyu/common/enums/HystrixIsolationModeEnumTest.java
b/shenyu-common/src/test/java/org/apache/shenyu/common/enums/HystrixIsolationModeEnumTest.java
index f455e0d..8210275 100644
---
a/shenyu-common/src/test/java/org/apache/shenyu/common/enums/HystrixIsolationModeEnumTest.java
+++
b/shenyu-common/src/test/java/org/apache/shenyu/common/enums/HystrixIsolationModeEnumTest.java
@@ -17,9 +17,9 @@
package org.apache.shenyu.common.enums;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Test case for HystrixIsolationModeEnum.
diff --git
a/shenyu-common/src/test/java/org/apache/shenyu/common/enums/LoadBalanceEnumTest.java
b/shenyu-common/src/test/java/org/apache/shenyu/common/enums/LoadBalanceEnumTest.java
index 9bdbc9b..d4a5c67 100644
---
a/shenyu-common/src/test/java/org/apache/shenyu/common/enums/LoadBalanceEnumTest.java
+++
b/shenyu-common/src/test/java/org/apache/shenyu/common/enums/LoadBalanceEnumTest.java
@@ -17,8 +17,10 @@
package org.apache.shenyu.common.enums;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Test case for LoadBalanceEnum.
@@ -27,22 +29,22 @@ public final class LoadBalanceEnumTest {
@Test
public void testHashLoadBalance() {
- Assert.assertEquals(1, LoadBalanceEnum.HASH.getCode());
- Assert.assertEquals("hash", LoadBalanceEnum.HASH.getName());
- Assert.assertTrue(LoadBalanceEnum.HASH.isSupport());
+ assertEquals(1, LoadBalanceEnum.HASH.getCode());
+ assertEquals("hash", LoadBalanceEnum.HASH.getName());
+ assertTrue(LoadBalanceEnum.HASH.isSupport());
}
@Test
public void testRandomLoadBalance() {
- Assert.assertEquals(2, LoadBalanceEnum.RANDOM.getCode());
- Assert.assertEquals("random", LoadBalanceEnum.RANDOM.getName());
- Assert.assertTrue(LoadBalanceEnum.RANDOM.isSupport());
+ assertEquals(2, LoadBalanceEnum.RANDOM.getCode());
+ assertEquals("random", LoadBalanceEnum.RANDOM.getName());
+ assertTrue(LoadBalanceEnum.RANDOM.isSupport());
}
@Test
public void testRoundRobinLoadBalance() {
- Assert.assertEquals(3, LoadBalanceEnum.ROUND_ROBIN.getCode());
- Assert.assertEquals("roundRobin",
LoadBalanceEnum.ROUND_ROBIN.getName());
- Assert.assertTrue(LoadBalanceEnum.ROUND_ROBIN.isSupport());
+ assertEquals(3, LoadBalanceEnum.ROUND_ROBIN.getCode());
+ assertEquals("roundRobin", LoadBalanceEnum.ROUND_ROBIN.getName());
+ assertTrue(LoadBalanceEnum.ROUND_ROBIN.isSupport());
}
}
diff --git
a/shenyu-common/src/test/java/org/apache/shenyu/common/enums/MatchModeEnumTest.java
b/shenyu-common/src/test/java/org/apache/shenyu/common/enums/MatchModeEnumTest.java
index b565843..5a7619b 100644
---
a/shenyu-common/src/test/java/org/apache/shenyu/common/enums/MatchModeEnumTest.java
+++
b/shenyu-common/src/test/java/org/apache/shenyu/common/enums/MatchModeEnumTest.java
@@ -17,10 +17,10 @@
package org.apache.shenyu.common.enums;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
/**
* Test Cases for MatchModeEnum.
diff --git
a/shenyu-common/src/test/java/org/apache/shenyu/common/enums/OperatorEnumTest.java
b/shenyu-common/src/test/java/org/apache/shenyu/common/enums/OperatorEnumTest.java
index da3fa1d..d9b3f96 100644
---
a/shenyu-common/src/test/java/org/apache/shenyu/common/enums/OperatorEnumTest.java
+++
b/shenyu-common/src/test/java/org/apache/shenyu/common/enums/OperatorEnumTest.java
@@ -17,13 +17,14 @@
package org.apache.shenyu.common.enums;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.List;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
/**
* Test Cases for OperatorEnum.
diff --git
a/shenyu-common/src/test/java/org/apache/shenyu/common/enums/ParamTypeEnumTest.java
b/shenyu-common/src/test/java/org/apache/shenyu/common/enums/ParamTypeEnumTest.java
index f9b1f8c..1acc6fc 100644
---
a/shenyu-common/src/test/java/org/apache/shenyu/common/enums/ParamTypeEnumTest.java
+++
b/shenyu-common/src/test/java/org/apache/shenyu/common/enums/ParamTypeEnumTest.java
@@ -17,16 +17,18 @@
package org.apache.shenyu.common.enums;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-/** Test Cases for ParamTypeEnum. */
+/**
+ * Test Cases for ParamTypeEnum.
+ */
public final class ParamTypeEnumTest {
@Test
@@ -69,9 +71,7 @@ public final class ParamTypeEnumTest {
public void testGetParamTypeEnumByNameValid() {
Arrays.stream(ParamTypeEnum.values())
.filter(ParamTypeEnum::getSupport)
- .forEach(
- paramTypeEnum ->
- assertEquals(
- paramTypeEnum,
ParamTypeEnum.getParamTypeEnumByName(paramTypeEnum.getName())));
+ .forEach(paramTypeEnum -> assertEquals(
+ paramTypeEnum,
ParamTypeEnum.getParamTypeEnumByName(paramTypeEnum.getName())));
}
}
diff --git
a/shenyu-common/src/test/java/org/apache/shenyu/common/enums/PluginEnumTest.java
b/shenyu-common/src/test/java/org/apache/shenyu/common/enums/PluginEnumTest.java
index f56d897..1dc8ac3 100644
---
a/shenyu-common/src/test/java/org/apache/shenyu/common/enums/PluginEnumTest.java
+++
b/shenyu-common/src/test/java/org/apache/shenyu/common/enums/PluginEnumTest.java
@@ -17,12 +17,13 @@
package org.apache.shenyu.common.enums;
-import org.junit.Test;
-import static org.junit.Assert.assertEquals;
+import org.junit.jupiter.api.Test;
import java.util.Arrays;
import java.util.List;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
/**
* Test Cases for PluginEnum.
*/
diff --git
a/shenyu-common/src/test/java/org/apache/shenyu/common/enums/PluginRoleEnumTest.java
b/shenyu-common/src/test/java/org/apache/shenyu/common/enums/PluginRoleEnumTest.java
index 526a259..129d6e8 100644
---
a/shenyu-common/src/test/java/org/apache/shenyu/common/enums/PluginRoleEnumTest.java
+++
b/shenyu-common/src/test/java/org/apache/shenyu/common/enums/PluginRoleEnumTest.java
@@ -17,8 +17,9 @@
package org.apache.shenyu.common.enums;
-import org.junit.Test;
-import static org.junit.Assert.assertEquals;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Test Cases for PluginRoleEnum.
diff --git
a/shenyu-common/src/test/java/org/apache/shenyu/common/enums/PluginTypeEnumTest.java
b/shenyu-common/src/test/java/org/apache/shenyu/common/enums/PluginTypeEnumTest.java
index 83b186e..b7946ff 100644
---
a/shenyu-common/src/test/java/org/apache/shenyu/common/enums/PluginTypeEnumTest.java
+++
b/shenyu-common/src/test/java/org/apache/shenyu/common/enums/PluginTypeEnumTest.java
@@ -17,9 +17,9 @@
package org.apache.shenyu.common.enums;
-import static org.junit.Assert.assertEquals;
+import org.junit.jupiter.api.Test;
-import org.junit.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class PluginTypeEnumTest {
diff --git
a/shenyu-common/src/test/java/org/apache/shenyu/common/enums/RateLimitEnumTest.java
b/shenyu-common/src/test/java/org/apache/shenyu/common/enums/RateLimitEnumTest.java
index b5706c4..a3c4b08 100644
---
a/shenyu-common/src/test/java/org/apache/shenyu/common/enums/RateLimitEnumTest.java
+++
b/shenyu-common/src/test/java/org/apache/shenyu/common/enums/RateLimitEnumTest.java
@@ -17,11 +17,12 @@
package org.apache.shenyu.common.enums;
-import static org.junit.Assert.assertEquals;
+import org.junit.jupiter.api.Test;
-import org.junit.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class RateLimitEnumTest {
+
@Test
public void testGetKeyName() {
assertEquals("concurrent_request_rate_limiter",
RateLimitEnum.CONCURRENT.getKeyName());
diff --git
a/shenyu-common/src/test/java/org/apache/shenyu/common/enums/RedisModeEnumTest.java
b/shenyu-common/src/test/java/org/apache/shenyu/common/enums/RedisModeEnumTest.java
index 886410c..1266e62 100644
---
a/shenyu-common/src/test/java/org/apache/shenyu/common/enums/RedisModeEnumTest.java
+++
b/shenyu-common/src/test/java/org/apache/shenyu/common/enums/RedisModeEnumTest.java
@@ -17,10 +17,10 @@
package org.apache.shenyu.common.enums;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
/**
* Test Cases for RedisModeEnum.
diff --git
a/shenyu-common/src/test/java/org/apache/shenyu/common/enums/ResultEnumTest.java
b/shenyu-common/src/test/java/org/apache/shenyu/common/enums/ResultEnumTest.java
index 7e5889e..ad4a040 100644
---
a/shenyu-common/src/test/java/org/apache/shenyu/common/enums/ResultEnumTest.java
+++
b/shenyu-common/src/test/java/org/apache/shenyu/common/enums/ResultEnumTest.java
@@ -17,9 +17,9 @@
package org.apache.shenyu.common.enums;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Test case for ResultEnum.
diff --git
a/shenyu-common/src/test/java/org/apache/shenyu/common/enums/RpcTypeEnumTest.java
b/shenyu-common/src/test/java/org/apache/shenyu/common/enums/RpcTypeEnumTest.java
index 08f2154..23ced2f 100644
---
a/shenyu-common/src/test/java/org/apache/shenyu/common/enums/RpcTypeEnumTest.java
+++
b/shenyu-common/src/test/java/org/apache/shenyu/common/enums/RpcTypeEnumTest.java
@@ -18,14 +18,15 @@
package org.apache.shenyu.common.enums;
import org.apache.shenyu.common.exception.ShenyuException;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertThrows;
public class RpcTypeEnumTest {
@Test
@@ -88,8 +89,8 @@ public class RpcTypeEnumTest {
assertTrue(rpcTypeEnumList.contains(RpcTypeEnum.TARS));
}
- @Test(expected = ShenyuException.class)
+ @Test
public void testGetRpcTypeEnumByNameInvalid() {
- RpcTypeEnum.acquireByName("InvalidName");
+ assertThrows(ShenyuException.class, () ->
RpcTypeEnum.acquireByName("InvalidName"));
}
}
diff --git
a/shenyu-common/src/test/java/org/apache/shenyu/common/enums/SelectorTypeEnumTest.java
b/shenyu-common/src/test/java/org/apache/shenyu/common/enums/SelectorTypeEnumTest.java
index b1658b9..8149cad 100644
---
a/shenyu-common/src/test/java/org/apache/shenyu/common/enums/SelectorTypeEnumTest.java
+++
b/shenyu-common/src/test/java/org/apache/shenyu/common/enums/SelectorTypeEnumTest.java
@@ -17,10 +17,10 @@
package org.apache.shenyu.common.enums;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
/**
* Test Cases for SelectorTypeEnum.
diff --git
a/shenyu-common/src/test/java/org/apache/shenyu/common/enums/SerializeEnumTest.java
b/shenyu-common/src/test/java/org/apache/shenyu/common/enums/SerializeEnumTest.java
index ccba066..223a1e0 100644
---
a/shenyu-common/src/test/java/org/apache/shenyu/common/enums/SerializeEnumTest.java
+++
b/shenyu-common/src/test/java/org/apache/shenyu/common/enums/SerializeEnumTest.java
@@ -17,16 +17,19 @@
package org.apache.shenyu.common.enums;
-import junit.framework.TestCase;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Test case for SerializeEnum.
*/
-public final class SerializeEnumTest extends TestCase {
+public final class SerializeEnumTest {
/**
* test SerializeEnum#getSerialize.
*/
+ @Test
public void testGetSerialize() {
assertEquals(SerializeEnum.JDK.getSerialize(), "jdk");
assertEquals(SerializeEnum.KRYO.getSerialize(), "kryo");
@@ -38,6 +41,7 @@ public final class SerializeEnumTest extends TestCase {
/**
* test SerializeEnum#acquire.
*/
+ @Test
public void testAcquire() {
assertEquals(SerializeEnum.acquire("unknown"), SerializeEnum.JDK);
assertEquals(SerializeEnum.acquire("jdk"), SerializeEnum.JDK);
@@ -45,6 +49,5 @@ public final class SerializeEnumTest extends TestCase {
assertEquals(SerializeEnum.acquire("hessian"), SerializeEnum.HESSIAN);
assertEquals(SerializeEnum.acquire("fastJson"),
SerializeEnum.FAST_JSON);
assertEquals(SerializeEnum.acquire("protostuff"),
SerializeEnum.PROTOSTUFF);
-
}
}
diff --git
a/shenyu-common/src/test/java/org/apache/shenyu/common/enums/WafEnumTest.java
b/shenyu-common/src/test/java/org/apache/shenyu/common/enums/WafEnumTest.java
index 29595c2..ec0cd70 100644
---
a/shenyu-common/src/test/java/org/apache/shenyu/common/enums/WafEnumTest.java
+++
b/shenyu-common/src/test/java/org/apache/shenyu/common/enums/WafEnumTest.java
@@ -17,9 +17,9 @@
package org.apache.shenyu.common.enums;
-import static org.junit.Assert.assertEquals;
+import org.junit.jupiter.api.Test;
-import org.junit.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class WafEnumTest {
@Test
diff --git
a/shenyu-common/src/test/java/org/apache/shenyu/common/enums/WafModelEnumTest.java
b/shenyu-common/src/test/java/org/apache/shenyu/common/enums/WafModelEnumTest.java
index 37c0857..5057312 100644
---
a/shenyu-common/src/test/java/org/apache/shenyu/common/enums/WafModelEnumTest.java
+++
b/shenyu-common/src/test/java/org/apache/shenyu/common/enums/WafModelEnumTest.java
@@ -17,9 +17,9 @@
package org.apache.shenyu.common.enums;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Test case for WafModelEnum.
diff --git
a/shenyu-common/src/test/java/org/apache/shenyu/common/exception/CommonErrorCodeTest.java
b/shenyu-common/src/test/java/org/apache/shenyu/common/exception/CommonErrorCodeTest.java
index 2d8525d..d810f56 100644
---
a/shenyu-common/src/test/java/org/apache/shenyu/common/exception/CommonErrorCodeTest.java
+++
b/shenyu-common/src/test/java/org/apache/shenyu/common/exception/CommonErrorCodeTest.java
@@ -17,10 +17,10 @@
package org.apache.shenyu.common.exception;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertThat;
/**
* Test case for {@link CommonErrorCode}.
diff --git
a/shenyu-common/src/test/java/org/apache/shenyu/common/exception/SerializerExceptionTest.java
b/shenyu-common/src/test/java/org/apache/shenyu/common/exception/SerializerExceptionTest.java
index 9bf4d4b..a203817 100644
---
a/shenyu-common/src/test/java/org/apache/shenyu/common/exception/SerializerExceptionTest.java
+++
b/shenyu-common/src/test/java/org/apache/shenyu/common/exception/SerializerExceptionTest.java
@@ -17,10 +17,10 @@
package org.apache.shenyu.common.exception;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Test case for {@link SerializerException}.
diff --git
a/shenyu-common/src/test/java/org/apache/shenyu/common/exception/ShenyuExceptionTest.java
b/shenyu-common/src/test/java/org/apache/shenyu/common/exception/ShenyuExceptionTest.java
index 12e4e87..86a6390 100644
---
a/shenyu-common/src/test/java/org/apache/shenyu/common/exception/ShenyuExceptionTest.java
+++
b/shenyu-common/src/test/java/org/apache/shenyu/common/exception/ShenyuExceptionTest.java
@@ -17,10 +17,10 @@
package org.apache.shenyu.common.exception;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Test case for {@link ShenyuException}.
diff --git
a/shenyu-common/src/test/java/org/apache/shenyu/common/timer/HierarchicalWheelTimerTest.java
b/shenyu-common/src/test/java/org/apache/shenyu/common/timer/HierarchicalWheelTimerTest.java
index 2af52df..755d42a 100644
---
a/shenyu-common/src/test/java/org/apache/shenyu/common/timer/HierarchicalWheelTimerTest.java
+++
b/shenyu-common/src/test/java/org/apache/shenyu/common/timer/HierarchicalWheelTimerTest.java
@@ -17,13 +17,15 @@
package org.apache.shenyu.common.timer;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertSame;
+
/**
* HierarchicalWheelTimerTest .
*/
@@ -47,7 +49,7 @@ public class HierarchicalWheelTimerTest {
/**
* Sets up.
*/
- @Before
+ @BeforeEach
public void setUp() {
timer = WheelTimerFactory.newWheelTimer();
timerTaskList = new TimerTaskList(taskCount);
@@ -66,7 +68,7 @@ public class HierarchicalWheelTimerTest {
}
});
}
- Assert.assertEquals(timer.size(), 100);
+ assertEquals(timer.size(), 100);
}
/**
@@ -80,9 +82,9 @@ public class HierarchicalWheelTimerTest {
}
};
timer.add(timerTask);
- Assert.assertEquals(timer.size(), 1);
+ assertEquals(timer.size(), 1);
timerTask.cancel();
- Assert.assertEquals(timer.size(), 0);
+ assertEquals(timer.size(), 0);
}
/**
@@ -97,8 +99,8 @@ public class HierarchicalWheelTimerTest {
}
};
timerTaskList.add(new TimerTaskList.TimerTaskEntry(timer, timerTask,
-1L));
- Assert.assertEquals(taskCount.get(), 1);
- timerTaskList.foreach(timerTask1 -> Assert.assertSame(timerTask1,
timerTask1));
+ assertEquals(taskCount.get(), 1);
+ timerTaskList.foreach(timerTask1 -> assertSame(timerTask1,
timerTask1));
}
/**
@@ -112,9 +114,9 @@ public class HierarchicalWheelTimerTest {
}
};
timerTaskList.add(new TimerTaskList.TimerTaskEntry(timer, timerTask,
-1L));
- Assert.assertEquals(taskCount.get(), 1);
+ assertEquals(taskCount.get(), 1);
for (final TimerTask task : timerTaskList) {
- Assert.assertSame(timerTask, timerTask);
+ assertSame(timerTask, timerTask);
}
}
}
diff --git
a/shenyu-common/src/test/java/org/apache/shenyu/common/timer/WheelTimerFactoryTest.java
b/shenyu-common/src/test/java/org/apache/shenyu/common/timer/WheelTimerFactoryTest.java
index ad3142f..269a88c 100644
---
a/shenyu-common/src/test/java/org/apache/shenyu/common/timer/WheelTimerFactoryTest.java
+++
b/shenyu-common/src/test/java/org/apache/shenyu/common/timer/WheelTimerFactoryTest.java
@@ -17,14 +17,15 @@
package org.apache.shenyu.common.timer;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertSame;
/**
* WheelTimerFactoryTest .
*/
public class WheelTimerFactoryTest {
-
+
/**
* Test get shared.
*/
@@ -32,6 +33,6 @@ public class WheelTimerFactoryTest {
public void testGetShared() {
Timer sharedTimer1 = WheelTimerFactory.getSharedTimer();
Timer sharedTimer2 = WheelTimerFactory.getSharedTimer();
- Assert.assertSame(sharedTimer1, sharedTimer2);
+ assertSame(sharedTimer1, sharedTimer2);
}
}
diff --git
a/shenyu-common/src/test/java/org/apache/shenyu/common/utils/DateUtilsTest.java
b/shenyu-common/src/test/java/org/apache/shenyu/common/utils/DateUtilsTest.java
index 9852272..1771d85 100644
---
a/shenyu-common/src/test/java/org/apache/shenyu/common/utils/DateUtilsTest.java
+++
b/shenyu-common/src/test/java/org/apache/shenyu/common/utils/DateUtilsTest.java
@@ -17,14 +17,15 @@
package org.apache.shenyu.common.utils;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
/**
* Test Cases for DateUtils.
diff --git
a/shenyu-common/src/test/java/org/apache/shenyu/common/utils/GsonUtilsTest.java
b/shenyu-common/src/test/java/org/apache/shenyu/common/utils/GsonUtilsTest.java
index 0cde1f0..3d167f1 100644
---
a/shenyu-common/src/test/java/org/apache/shenyu/common/utils/GsonUtilsTest.java
+++
b/shenyu-common/src/test/java/org/apache/shenyu/common/utils/GsonUtilsTest.java
@@ -26,8 +26,7 @@ import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.google.gson.reflect.TypeToken;
import org.apache.commons.lang3.tuple.Pair;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.math.BigDecimal;
import java.util.Arrays;
@@ -37,8 +36,11 @@ import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.comparesEqualTo;
-import static org.junit.Assert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertNull;
/**
* Test cases for GsonUtils.
@@ -65,7 +67,7 @@ public class GsonUtilsTest {
public void testToJson() {
TestObject testObject = generateTestObject();
- Assert.assertEquals(EXPECTED_JSON,
GsonUtils.getInstance().toJson(testObject));
+ assertEquals(EXPECTED_JSON,
GsonUtils.getInstance().toJson(testObject));
}
/**
@@ -78,7 +80,7 @@ public class GsonUtilsTest {
JsonObject jsonObject = new
JsonParser().parse(EXPECTED_JSON).getAsJsonObject();
TestObject parseObject = GsonUtils.getInstance().fromJson(jsonObject,
TestObject.class);
- Assert.assertEquals(testObject, parseObject);
+ assertEquals(testObject, parseObject);
}
/**
@@ -88,7 +90,7 @@ public class GsonUtilsTest {
public void testFromJsonAboutString() {
TestObject testObject = generateTestObject();
- Assert.assertEquals(testObject,
GsonUtils.getInstance().fromJson(EXPECTED_JSON, TestObject.class));
+ assertEquals(testObject,
GsonUtils.getInstance().fromJson(EXPECTED_JSON, TestObject.class));
}
/**
@@ -100,7 +102,7 @@ public class GsonUtilsTest {
String testJson = "[\"123\",\"test\",\"测试\"]";
- Assert.assertEquals(testList,
GsonUtils.getInstance().fromList(testJson, String.class));
+ assertEquals(testList, GsonUtils.getInstance().fromList(testJson,
String.class));
}
/**
@@ -118,11 +120,11 @@ public class GsonUtilsTest {
.collect(Collectors.toMap(s -> s.split("=")[0], s ->
s.split("=")[1]));
param.forEach((key, value) -> {
- Assert.assertTrue(resultMap.containsKey(key));
- Assert.assertEquals(value, resultMap.get(key));
+ assertTrue(resultMap.containsKey(key));
+ assertEquals(value, resultMap.get(key));
});
- Assert.assertEquals("", GsonUtils.getInstance().toGetParam(""));
+ assertEquals("", GsonUtils.getInstance().toGetParam(""));
}
/**
@@ -138,7 +140,7 @@ public class GsonUtilsTest {
+ "{\"name\":\"test\",\"id\":\"123\",\"data\":\"测试\"},"
+ "{\"name\":\"test\",\"id\":\"123\",\"data\":\"测试\"}]";
- Assert.assertEquals(list, GsonUtils.getInstance().toListMap(json));
+ assertEquals(list, GsonUtils.getInstance().toListMap(json));
}
/**
@@ -153,16 +155,16 @@ public class GsonUtilsTest {
Map<String, Object> parseMap =
GsonUtils.getInstance().toObjectMap(json);
map.forEach((key, value) -> {
- Assert.assertTrue(parseMap.containsKey(key));
+ assertTrue(parseMap.containsKey(key));
Object jsonValue = parseMap.get(key);
if (jsonValue instanceof JsonElement) {
- Assert.assertEquals(value,
GsonUtils.getInstance().fromJson((JsonElement) jsonValue, TestObject.class));
+ assertEquals(value,
GsonUtils.getInstance().fromJson((JsonElement) jsonValue, TestObject.class));
} else {
- Assert.assertEquals(value, parseMap.get(key));
+ assertEquals(value, parseMap.get(key));
}
});
- Assert.assertNull(GsonUtils.getInstance().toObjectMap(null));
+ assertNull(GsonUtils.getInstance().toObjectMap(null));
}
/**
@@ -176,11 +178,11 @@ public class GsonUtilsTest {
Map<String, TestObject> parseMap =
GsonUtils.getInstance().toObjectMap(json, TestObject.class);
map.forEach((key, value) -> {
- Assert.assertTrue(parseMap.containsKey(key));
- Assert.assertEquals(value, parseMap.get(key));
+ assertTrue(parseMap.containsKey(key));
+ assertEquals(value, parseMap.get(key));
});
- Assert.assertNull(GsonUtils.getInstance().toObjectMap(null,
String.class));
+ assertNull(GsonUtils.getInstance().toObjectMap(null, String.class));
}
/**
@@ -195,11 +197,11 @@ public class GsonUtilsTest {
String json =
"{\"data1\":[\"111\",\"222\"],\"data2\":[\"333\",\"555\"]}";
Map<String, List<String>> parseMap =
GsonUtils.getInstance().toObjectMapList(json, String.class);
map.forEach((key, value) -> {
- Assert.assertTrue(parseMap.containsKey(key));
- Assert.assertEquals(value, parseMap.get(key));
+ assertTrue(parseMap.containsKey(key));
+ assertEquals(value, parseMap.get(key));
});
- Assert.assertNull(GsonUtils.getInstance().toObjectMapList(null,
String.class));
+ assertNull(GsonUtils.getInstance().toObjectMapList(null,
String.class));
}
/**
@@ -216,16 +218,16 @@ public class GsonUtilsTest {
Map<String, Object> parseMap = GsonUtils.getInstance().toTreeMap(json);
map.forEach((key, value) -> {
- Assert.assertTrue(parseMap.containsKey(key));
+ assertTrue(parseMap.containsKey(key));
Object jsonValue = parseMap.get(key);
if (jsonValue instanceof JsonElement) {
- Assert.assertEquals(value,
GsonUtils.getInstance().fromJson((JsonElement) jsonValue, TestObject.class));
+ assertEquals(value,
GsonUtils.getInstance().fromJson((JsonElement) jsonValue, TestObject.class));
} else {
- Assert.assertEquals(value, parseMap.get(key));
+ assertEquals(value, parseMap.get(key));
}
});
- Assert.assertNull(GsonUtils.getInstance().toObjectMap(null));
+ assertNull(GsonUtils.getInstance().toObjectMap(null));
}
/**
@@ -243,25 +245,25 @@ public class GsonUtilsTest {
Map<String, Object> parseMap =
GsonUtils.getInstance().convertToMap(testJson);
map.forEach((key, value) -> {
- Assert.assertTrue(parseMap.containsKey(key));
+ assertTrue(parseMap.containsKey(key));
if (value instanceof Map) {
Map<?, ?> tempMap = (Map<?, ?>) parseMap.get(key);
((Map<?, ?>) value).forEach((key1, value1) -> {
- Assert.assertTrue(tempMap.containsKey(key1));
- Assert.assertEquals(value1.toString(),
tempMap.get(key1).toString());
+ assertTrue(tempMap.containsKey(key1));
+ assertEquals(value1.toString(),
tempMap.get(key1).toString());
});
} else if (value instanceof List) {
List<?> tempList = (List<?>) parseMap.get(key);
List<?> tempValue = (List<?>) value;
for (int i = 0; i < tempValue.size(); i++) {
- Assert.assertEquals(tempValue.get(i).toString(),
tempList.get(i).toString());
+ assertEquals(tempValue.get(i).toString(),
tempList.get(i).toString());
}
} else {
- Assert.assertEquals(value.toString(),
parseMap.get(key).toString());
+ assertEquals(value.toString(), parseMap.get(key).toString());
}
});
- Assert.assertNull(GsonUtils.getInstance().convertToMap(null));
+ assertNull(GsonUtils.getInstance().convertToMap(null));
}
@Test
diff --git
a/shenyu-common/src/test/java/org/apache/shenyu/common/utils/HttpParamConverterTest.java
b/shenyu-common/src/test/java/org/apache/shenyu/common/utils/HttpParamConverterTest.java
index 2aacd8e..1d4b805 100644
---
a/shenyu-common/src/test/java/org/apache/shenyu/common/utils/HttpParamConverterTest.java
+++
b/shenyu-common/src/test/java/org/apache/shenyu/common/utils/HttpParamConverterTest.java
@@ -18,29 +18,22 @@
package org.apache.shenyu.common.utils;
import org.hamcrest.collection.IsMapContaining;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ErrorCollector;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.Test;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import java.util.Map;
import static org.hamcrest.CoreMatchers.allOf;
-import static org.junit.Assert.assertEquals;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
/**
* Test cases for HttpParamConverter.
*/
public final class HttpParamConverterTest {
- @Rule
- public ErrorCollector collector = new ErrorCollector();
-
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
@Test
public void testOfString() {
assertEquals("{\"a\":\"1\",\"b\":\"2\"}",
HttpParamConverter.ofString(() -> "a=1&b=2"));
@@ -49,7 +42,7 @@ public final class HttpParamConverterTest {
@Test
public void testInitQueryParams() {
Map<String, String> params =
HttpParamConverter.initQueryParams("a=1&b=2&c=&d");
- collector.checkThat(params,
+ assertThat(params,
allOf(IsMapContaining.hasEntry("a", "1"),
IsMapContaining.hasEntry("b", "2"),
IsMapContaining.hasEntry("c", ""),
@@ -63,10 +56,7 @@ public final class HttpParamConverterTest {
public void testDecodeQueryParam() {
assertEquals("a=1&b=2",
HttpParamConverter.decodeQueryParam("a%3d1%26b%3d2"));
- thrown.expect(IllegalArgumentException.class);
- thrown.expectMessage("Incomplete trailing escape (%) pattern");
- assertEquals("a=1&b=2",
HttpParamConverter.decodeQueryParam("a%3d1%26b%3d2%%"));
-
+ assertThrows(IllegalArgumentException.class, () ->
HttpParamConverter.decodeQueryParam("a%3d1%26b%3d2%%"));
}
@Test
diff --git
a/shenyu-common/src/test/java/org/apache/shenyu/common/utils/IpUtilsTest.java
b/shenyu-common/src/test/java/org/apache/shenyu/common/utils/IpUtilsTest.java
index 6a07369..77629ae 100644
---
a/shenyu-common/src/test/java/org/apache/shenyu/common/utils/IpUtilsTest.java
+++
b/shenyu-common/src/test/java/org/apache/shenyu/common/utils/IpUtilsTest.java
@@ -17,9 +17,9 @@
package org.apache.shenyu.common.utils;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
import org.mockito.MockedStatic;
import java.net.InetAddress;
@@ -27,9 +27,9 @@ import java.net.NetworkInterface;
import java.net.SocketException;
import java.util.Vector;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.mockStatic;
import static org.mockito.Mockito.when;
@@ -41,12 +41,12 @@ public final class IpUtilsTest {
private MockedStatic<NetworkInterface> networkInterfaceMockedStatic;
- @Before
+ @BeforeEach
public void setUp() {
networkInterfaceMockedStatic = mockStatic(NetworkInterface.class);
}
- @After
+ @AfterEach
public void close() {
networkInterfaceMockedStatic.close();
}
diff --git
a/shenyu-common/src/test/java/org/apache/shenyu/common/utils/JsonUtilsTest.java
b/shenyu-common/src/test/java/org/apache/shenyu/common/utils/JsonUtilsTest.java
index a3061ce..dcc9e0c 100644
---
a/shenyu-common/src/test/java/org/apache/shenyu/common/utils/JsonUtilsTest.java
+++
b/shenyu-common/src/test/java/org/apache/shenyu/common/utils/JsonUtilsTest.java
@@ -18,7 +18,7 @@
package org.apache.shenyu.common.utils;
import org.apache.shenyu.common.constant.Constants;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.HashMap;
import java.util.LinkedList;
@@ -26,9 +26,9 @@ import java.util.List;
import java.util.Map;
import java.util.Objects;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
/**
* Test cases for JsonUtils.
diff --git
a/shenyu-common/src/test/java/org/apache/shenyu/common/utils/LogUtilsTest.java
b/shenyu-common/src/test/java/org/apache/shenyu/common/utils/LogUtilsTest.java
index 905d7f6..9fb1b99 100644
---
a/shenyu-common/src/test/java/org/apache/shenyu/common/utils/LogUtilsTest.java
+++
b/shenyu-common/src/test/java/org/apache/shenyu/common/utils/LogUtilsTest.java
@@ -17,8 +17,8 @@
package org.apache.shenyu.common.utils;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import java.util.function.Supplier;
@@ -39,7 +39,7 @@ public final class LogUtilsTest {
private Supplier<Object> supplier;
- @Before
+ @BeforeEach
public void setUp() {
logger = spy(Logger.class);
supplier = mock(Supplier.class);
diff --git
a/shenyu-common/src/test/java/org/apache/shenyu/common/utils/Md5UtilsTest.java
b/shenyu-common/src/test/java/org/apache/shenyu/common/utils/Md5UtilsTest.java
index d079f73..eb3364d 100644
---
a/shenyu-common/src/test/java/org/apache/shenyu/common/utils/Md5UtilsTest.java
+++
b/shenyu-common/src/test/java/org/apache/shenyu/common/utils/Md5UtilsTest.java
@@ -17,9 +17,9 @@
package org.apache.shenyu.common.utils;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Test cases for Md5Utils.
diff --git
a/shenyu-common/src/test/java/org/apache/shenyu/common/utils/ParamCheckUtilsTest.java
b/shenyu-common/src/test/java/org/apache/shenyu/common/utils/ParamCheckUtilsTest.java
index 56beb18..e215287 100644
---
a/shenyu-common/src/test/java/org/apache/shenyu/common/utils/ParamCheckUtilsTest.java
+++
b/shenyu-common/src/test/java/org/apache/shenyu/common/utils/ParamCheckUtilsTest.java
@@ -17,10 +17,10 @@
package org.apache.shenyu.common.utils;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Test cases for ParamCheckUtils.
diff --git
a/shenyu-common/src/test/java/org/apache/shenyu/common/utils/PathMatchUtilsTest.java
b/shenyu-common/src/test/java/org/apache/shenyu/common/utils/PathMatchUtilsTest.java
index 4f0c4c0..51c98dc 100644
---
a/shenyu-common/src/test/java/org/apache/shenyu/common/utils/PathMatchUtilsTest.java
+++
b/shenyu-common/src/test/java/org/apache/shenyu/common/utils/PathMatchUtilsTest.java
@@ -17,10 +17,10 @@
package org.apache.shenyu.common.utils;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Test cases for PathMatchUtils.
diff --git
a/shenyu-common/src/test/java/org/apache/shenyu/common/utils/ReflectUtilsTest.java
b/shenyu-common/src/test/java/org/apache/shenyu/common/utils/ReflectUtilsTest.java
index dfdaa22..78407f2 100644
---
a/shenyu-common/src/test/java/org/apache/shenyu/common/utils/ReflectUtilsTest.java
+++
b/shenyu-common/src/test/java/org/apache/shenyu/common/utils/ReflectUtilsTest.java
@@ -17,10 +17,10 @@
package org.apache.shenyu.common.utils;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
/**
* Test cases for ReflectUtils.
diff --git
a/shenyu-common/src/test/java/org/apache/shenyu/common/utils/SignUtilsTest.java
b/shenyu-common/src/test/java/org/apache/shenyu/common/utils/SignUtilsTest.java
index 6e3af16..43cc16c 100644
---
a/shenyu-common/src/test/java/org/apache/shenyu/common/utils/SignUtilsTest.java
+++
b/shenyu-common/src/test/java/org/apache/shenyu/common/utils/SignUtilsTest.java
@@ -17,13 +17,13 @@
package org.apache.shenyu.common.utils;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.HashMap;
import java.util.Map;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Test cases for SignUtils.
diff --git
a/shenyu-common/src/test/java/org/apache/shenyu/common/utils/SpiLoadFactoryTest.java
b/shenyu-common/src/test/java/org/apache/shenyu/common/utils/SpiLoadFactoryTest.java
index d939b29..bb961cf 100644
---
a/shenyu-common/src/test/java/org/apache/shenyu/common/utils/SpiLoadFactoryTest.java
+++
b/shenyu-common/src/test/java/org/apache/shenyu/common/utils/SpiLoadFactoryTest.java
@@ -17,11 +17,12 @@
package org.apache.shenyu.common.utils;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.List;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
/**
* Test Cases for SpiLoadFactory.
@@ -33,9 +34,9 @@ public class SpiLoadFactoryTest {
assertNotNull(SpiLoadFactory.loadFirst(SpiInterface.class));
}
- @Test(expected = IllegalStateException.class)
+ @Test
public void testLoadFirstNoDefined() {
- SpiLoadFactory.loadFirst(List.class);
+ assertThrows(IllegalStateException.class, () ->
SpiLoadFactory.loadFirst(List.class));
}
@Test
diff --git
a/shenyu-common/src/test/java/org/apache/shenyu/common/utils/ThreadUtilsTest.java
b/shenyu-common/src/test/java/org/apache/shenyu/common/utils/ThreadUtilsTest.java
index 4af1b5d..4452512 100644
---
a/shenyu-common/src/test/java/org/apache/shenyu/common/utils/ThreadUtilsTest.java
+++
b/shenyu-common/src/test/java/org/apache/shenyu/common/utils/ThreadUtilsTest.java
@@ -17,13 +17,11 @@
package org.apache.shenyu.common.utils;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import java.util.concurrent.TimeUnit;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
@@ -33,12 +31,11 @@ import static org.mockito.Mockito.verify;
/**
* Test Cases for ThreadUtils.
*/
-@RunWith(MockitoJUnitRunner.class)
public final class ThreadUtilsTest {
private TimeUnit timeUnit;
- @Before
+ @BeforeEach
public void setUp() {
timeUnit = mock(TimeUnit.class);
}
diff --git
a/shenyu-common/src/test/java/org/apache/shenyu/common/utils/UUIDUtilsTest.java
b/shenyu-common/src/test/java/org/apache/shenyu/common/utils/UUIDUtilsTest.java
index 411674c..9f80dd2 100644
---
a/shenyu-common/src/test/java/org/apache/shenyu/common/utils/UUIDUtilsTest.java
+++
b/shenyu-common/src/test/java/org/apache/shenyu/common/utils/UUIDUtilsTest.java
@@ -18,8 +18,7 @@
package org.apache.shenyu.common.utils;
import org.apache.commons.lang3.StringUtils;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
@@ -28,6 +27,9 @@ import java.lang.reflect.Method;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.greaterThan;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Test cases for UUIDUtils.
@@ -37,14 +39,14 @@ public final class UUIDUtilsTest {
@Test
public void testGetInstance() {
UUIDUtils uuidUtils = UUIDUtils.getInstance();
- Assert.assertNotNull(uuidUtils);
+ assertNotNull(uuidUtils);
}
@Test
public void testGenerateShortUuid() {
String shortUuid = UUIDUtils.getInstance().generateShortUuid();
- Assert.assertTrue(StringUtils.isNotEmpty(shortUuid));
- Assert.assertEquals(19, shortUuid.length());
+ assertTrue(StringUtils.isNotEmpty(shortUuid));
+ assertEquals(19, shortUuid.length());
}
@Test
@@ -56,13 +58,13 @@ public final class UUIDUtilsTest {
try {
constructor.newInstance(-1L, 10L, 10L);
} catch (InvocationTargetException ex) {
- Assert.assertTrue(ex.getCause().getMessage().startsWith("worker Id
can't be greater than"));
+ assertTrue(ex.getCause().getMessage().startsWith("worker Id can't
be greater than"));
}
try {
constructor.newInstance(10L, -1L, 10L);
} catch (InvocationTargetException ex) {
-
Assert.assertTrue(ex.getCause().getMessage().startsWith("datacenter Id can't be
greater than"));
+ assertTrue(ex.getCause().getMessage().startsWith("datacenter Id
can't be greater than"));
}
}
@@ -90,7 +92,7 @@ public final class UUIDUtilsTest {
try {
method.invoke(UUIDUtils.getInstance());
} catch (InvocationTargetException ex) {
- Assert.assertTrue(ex.getCause().getMessage().startsWith("Clock
moved backwards."));
+ assertTrue(ex.getCause().getMessage().startsWith("Clock moved
backwards."));
}
}
diff --git
a/shenyu-common/src/test/java/org/apache/shenyu/common/utils/UpstreamCheckUtilsTest.java
b/shenyu-common/src/test/java/org/apache/shenyu/common/utils/UpstreamCheckUtilsTest.java
index 11962ba..79b9f3b 100644
---
a/shenyu-common/src/test/java/org/apache/shenyu/common/utils/UpstreamCheckUtilsTest.java
+++
b/shenyu-common/src/test/java/org/apache/shenyu/common/utils/UpstreamCheckUtilsTest.java
@@ -17,15 +17,16 @@
package org.apache.shenyu.common.utils;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
/**
* Test cases for UpstreamCheckUtils.
@@ -40,7 +41,7 @@ public final class UpstreamCheckUtilsTest {
}
@Test
- @Ignore
+ @Disabled
public void testSocketConnect() {
Runnable runnable = () -> {
ServerSocket serverSocket;
diff --git
a/shenyu-common/src/test/java/org/apache/shenyu/common/utils/VersionUtilsTest.java
b/shenyu-common/src/test/java/org/apache/shenyu/common/utils/VersionUtilsTest.java
index b86e6a7..68b8cbe 100644
---
a/shenyu-common/src/test/java/org/apache/shenyu/common/utils/VersionUtilsTest.java
+++
b/shenyu-common/src/test/java/org/apache/shenyu/common/utils/VersionUtilsTest.java
@@ -17,9 +17,9 @@
package org.apache.shenyu.common.utils;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
/**
* Test cases for VersionUtils.
diff --git
a/shenyu-plugin/shenyu-plugin-resilience4j/src/test/java/org/apache/shenyu/plugin/resilience4j/core/RateLimiterTest.java
b/shenyu-plugin/shenyu-plugin-resilience4j/src/test/java/org/apache/shenyu/plugin/resilience4j/core/RateLimiterTest.java
index 5c65606..bf59670 100644
---
a/shenyu-plugin/shenyu-plugin-resilience4j/src/test/java/org/apache/shenyu/plugin/resilience4j/core/RateLimiterTest.java
+++
b/shenyu-plugin/shenyu-plugin-resilience4j/src/test/java/org/apache/shenyu/plugin/resilience4j/core/RateLimiterTest.java
@@ -20,10 +20,8 @@ package org.apache.shenyu.plugin.resilience4j.core;
import io.github.resilience4j.ratelimiter.RateLimiter;
import io.github.resilience4j.ratelimiter.RequestNotPermitted;
import io.github.resilience4j.reactor.ratelimiter.operator.RateLimiterOperator;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import reactor.core.publisher.Mono;
import reactor.test.StepVerifier;
@@ -36,12 +34,11 @@ import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
/**
* RateLimiter test.
*/
-@RunWith(MockitoJUnitRunner.class)
public final class RateLimiterTest {
private RateLimiter rateLimiter;
- @Before
+ @BeforeEach
public void setUp() {
rateLimiter = mock(RateLimiter.class, RETURNS_DEEP_STUBS);
}