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 c9df575 [ISSUE #2830] upgrade 5 files unit test framework from from
junit4 to junit5 (#2867)
c9df575 is described below
commit c9df575b04e29bdad862fbf9e7ec27feeec35d3b
Author: hbyandy <[email protected]>
AuthorDate: Fri Feb 11 17:16:11 2022 +0800
[ISSUE #2830] upgrade 5 files unit test framework from from junit4 to
junit5 (#2867)
* 升级metrics模块单元测试框架,从JUnit4到JUnit5
* upgrade 5 files unit test framework from junit4 to junit5
* fix 1 checkstle problem of URIPluginTest.java
---
.../HttpLongPollingDataChangedListenerTest.java | 17 +++++++-------
.../apache/shenyu/admin/model/vo/PluginVOTest.java | 4 ++--
.../shenyu/admin/model/vo/RuleConditionVOTest.java | 5 ++--
.../admin/model/vo/SelectorConditionVOTest.java | 4 ++--
.../apache/shenyu/plugin/uri/URIPluginTest.java | 27 +++++++++++++---------
5 files changed, 31 insertions(+), 26 deletions(-)
diff --git
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/listener/http/HttpLongPollingDataChangedListenerTest.java
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/listener/http/HttpLongPollingDataChangedListenerTest.java
index 05ee1f0..c90a1fa 100644
---
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/listener/http/HttpLongPollingDataChangedListenerTest.java
+++
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/listener/http/HttpLongPollingDataChangedListenerTest.java
@@ -17,14 +17,11 @@
package org.apache.shenyu.admin.listener.http;
+import org.apache.commons.lang3.StringUtils;
import org.apache.shenyu.admin.model.result.ShenyuAdminResult;
import org.apache.shenyu.admin.utils.ShenyuResultMessage;
import org.apache.shenyu.common.enums.ConfigGroupEnum;
import org.apache.shenyu.common.utils.GsonUtils;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.jupiter.api.extension.ExtendWith;
-import org.junit.platform.commons.util.StringUtils;
import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.http.MediaType;
import org.springframework.mock.web.MockHttpServletRequest;
@@ -35,9 +32,13 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* The TestCase for {@link HttpLongPollingDataChangedListener}.
@@ -53,7 +54,7 @@ public final class HttpLongPollingDataChangedListenerTest {
private MockHttpServletResponse httpServletResponse;
- @Before
+ @BeforeEach
public void setUp() {
this.httpServletRequest = new MockHttpServletRequest();
this.httpServletResponse = new MockHttpServletResponse();
diff --git
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/model/vo/PluginVOTest.java
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/model/vo/PluginVOTest.java
index 1f6dc5e..5757a02 100644
---
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/model/vo/PluginVOTest.java
+++
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/model/vo/PluginVOTest.java
@@ -20,11 +20,11 @@ package org.apache.shenyu.admin.model.vo;
import org.apache.shenyu.admin.AbstractReflectGetterSetterTest;
import org.apache.shenyu.admin.model.entity.PluginDO;
import org.apache.shenyu.common.enums.PluginEnum;
-import org.junit.Test;
import java.sql.Timestamp;
-import static org.junit.Assert.assertNotNull;
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
/**
* Test case for PluginVO.
diff --git
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/model/vo/RuleConditionVOTest.java
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/model/vo/RuleConditionVOTest.java
index e09d037..5d670b3 100644
---
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/model/vo/RuleConditionVOTest.java
+++
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/model/vo/RuleConditionVOTest.java
@@ -21,11 +21,10 @@ import
org.apache.shenyu.admin.AbstractReflectGetterSetterTest;
import org.apache.shenyu.admin.model.entity.RuleConditionDO;
import org.apache.shenyu.common.enums.OperatorEnum;
import org.apache.shenyu.common.enums.ParamTypeEnum;
-import org.junit.Test;
-
import java.sql.Timestamp;
-import static org.junit.Assert.assertNotNull;
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
/**
* Test case for RuleConditionVO.
diff --git
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/model/vo/SelectorConditionVOTest.java
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/model/vo/SelectorConditionVOTest.java
index 49d4bf5..06aca41 100644
---
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/model/vo/SelectorConditionVOTest.java
+++
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/model/vo/SelectorConditionVOTest.java
@@ -21,11 +21,11 @@ import
org.apache.shenyu.admin.AbstractReflectGetterSetterTest;
import org.apache.shenyu.admin.model.entity.SelectorConditionDO;
import org.apache.shenyu.common.enums.OperatorEnum;
import org.apache.shenyu.common.enums.ParamTypeEnum;
-import org.junit.Test;
import java.sql.Timestamp;
-import static org.junit.Assert.assertNotNull;
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
/**
* Test case for SelectorConditionVO.
diff --git
a/shenyu-plugin/shenyu-plugin-uri/src/test/java/org/apache/shenyu/plugin/uri/URIPluginTest.java
b/shenyu-plugin/shenyu-plugin-uri/src/test/java/org/apache/shenyu/plugin/uri/URIPluginTest.java
index 875b1db..e2cfac2 100644
---
a/shenyu-plugin/shenyu-plugin-uri/src/test/java/org/apache/shenyu/plugin/uri/URIPluginTest.java
+++
b/shenyu-plugin/shenyu-plugin-uri/src/test/java/org/apache/shenyu/plugin/uri/URIPluginTest.java
@@ -22,11 +22,7 @@ import org.apache.shenyu.common.enums.PluginEnum;
import org.apache.shenyu.common.enums.RpcTypeEnum;
import org.apache.shenyu.plugin.api.ShenyuPluginChain;
import org.apache.shenyu.plugin.api.context.ShenyuContext;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.jupiter.api.extension.ExtendWith;
-import org.mockito.junit.jupiter.MockitoExtension;
+
import org.springframework.mock.http.server.reactive.MockServerHttpRequest;
import org.springframework.mock.web.server.MockServerWebExchange;
import org.springframework.util.LinkedMultiValueMap;
@@ -38,7 +34,15 @@ import reactor.test.StepVerifier;
import java.net.InetSocketAddress;
import java.util.stream.Collectors;
-import static org.junit.Assert.assertEquals;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.mockito.junit.jupiter.MockitoSettings;
+import org.mockito.quality.Strictness;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
@@ -47,6 +51,7 @@ import static org.mockito.Mockito.when;
* The Test Case For {@link URIPlugin}.
*/
@ExtendWith(MockitoExtension.class)
+@MockitoSettings(strictness = Strictness.LENIENT)
public class URIPluginTest {
private MockServerHttpRequest request;
@@ -59,7 +64,7 @@ public class URIPluginTest {
private ShenyuContext shenyuContext;
- @Before
+ @BeforeEach
public void setUp() {
this.uriPlugin = new URIPlugin();
this.chain = mock(ShenyuPluginChain.class);
@@ -126,11 +131,11 @@ public class URIPluginTest {
@Test
public void testSkip() {
when(shenyuContext.getRpcType()).thenReturn(RpcTypeEnum.HTTP.getName());
- Assert.assertFalse(uriPlugin.skip(exchange));
+ assertFalse(uriPlugin.skip(exchange));
when(shenyuContext.getRpcType()).thenReturn(RpcTypeEnum.SPRING_CLOUD.getName());
- Assert.assertFalse(uriPlugin.skip(exchange));
+ assertFalse(uriPlugin.skip(exchange));
when(shenyuContext.getRpcType()).thenReturn(RpcTypeEnum.DUBBO.getName());
- Assert.assertTrue(uriPlugin.skip(exchange));
+ assertTrue(uriPlugin.skip(exchange));
}
@Test
@@ -141,7 +146,7 @@ public class URIPluginTest {
queryParams.add("add", "bj");
queryParams.add("name", "b j");
queryParams.add("age", "['z','zc','zz']");
-
Assert.assertEquals("zcq=01&zcq=03&add=bj&name=b%20j&age=['z','zc','zz']",
getCodecQuery(queryParams));
+ assertEquals("zcq=01&zcq=03&add=bj&name=b%20j&age=['z','zc','zz']",
getCodecQuery(queryParams));
}
/**