[SCB-2475] migrate servicestage module to junit5 (#3173)
diff --git a/common/common-rest/src/test/java/org/apache/servicecomb/common/rest/filter/TestHttpServerFilter.java b/common/common-rest/src/test/java/org/apache/servicecomb/common/rest/filter/TestHttpServerFilter.java
index 3976843..584a35a 100644
--- a/common/common-rest/src/test/java/org/apache/servicecomb/common/rest/filter/TestHttpServerFilter.java
+++ b/common/common-rest/src/test/java/org/apache/servicecomb/common/rest/filter/TestHttpServerFilter.java
@@ -22,8 +22,8 @@
import org.apache.servicecomb.core.Invocation;
import org.apache.servicecomb.foundation.test.scaffolding.exception.RuntimeExceptionWithoutStackTrace;
import org.apache.servicecomb.foundation.vertx.http.HttpServletResponseEx;
-import org.junit.Test;
import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestHttpServerFilter {
diff --git a/common/common-rest/src/test/java/org/apache/servicecomb/common/rest/filter/TestHttpServerFilterBeforeSendResponseExecutor.java b/common/common-rest/src/test/java/org/apache/servicecomb/common/rest/filter/TestHttpServerFilterBeforeSendResponseExecutor.java
index 80f4240..c004fec 100644
--- a/common/common-rest/src/test/java/org/apache/servicecomb/common/rest/filter/TestHttpServerFilterBeforeSendResponseExecutor.java
+++ b/common/common-rest/src/test/java/org/apache/servicecomb/common/rest/filter/TestHttpServerFilterBeforeSendResponseExecutor.java
@@ -24,11 +24,11 @@
import org.apache.servicecomb.core.Invocation;
import org.apache.servicecomb.foundation.test.scaffolding.exception.RuntimeExceptionWithoutStackTrace;
import org.apache.servicecomb.foundation.vertx.http.HttpServletResponseEx;
-import org.junit.Before;
-import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import mockit.Mocked;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
public class TestHttpServerFilterBeforeSendResponseExecutor {
@Mocked
@@ -42,7 +42,7 @@
HttpServerFilterBeforeSendResponseExecutor executor =
new HttpServerFilterBeforeSendResponseExecutor(httpServerFilters, invocation, responseEx);
- @Before
+ @BeforeEach
public void setup() {
httpServerFilters.add(new HttpServerFilterBaseForTest());
}
diff --git a/handlers/handler-flowcontrol-qps/src/test/java/org/apache/servicecomb/qps/TestConfig.java b/handlers/handler-flowcontrol-qps/src/test/java/org/apache/servicecomb/qps/TestConfig.java
index bd9e285..ea9f474 100644
--- a/handlers/handler-flowcontrol-qps/src/test/java/org/apache/servicecomb/qps/TestConfig.java
+++ b/handlers/handler-flowcontrol-qps/src/test/java/org/apache/servicecomb/qps/TestConfig.java
@@ -18,18 +18,18 @@
package org.apache.servicecomb.qps;
import org.apache.servicecomb.foundation.test.scaffolding.config.ArchaiusUtils;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
public class TestConfig {
- @BeforeClass
+ @BeforeAll
public static void classSetup() {
ArchaiusUtils.resetConfig();
}
- @AfterClass
+ @AfterAll
public static void classTeardown() {
ArchaiusUtils.resetConfig();
}
diff --git a/handlers/handler-publickey-auth/src/test/java/org/apache/servicecomb/authentication/TestAccessController.java b/handlers/handler-publickey-auth/src/test/java/org/apache/servicecomb/authentication/TestAccessController.java
index 76e9b57..059ac41 100644
--- a/handlers/handler-publickey-auth/src/test/java/org/apache/servicecomb/authentication/TestAccessController.java
+++ b/handlers/handler-publickey-auth/src/test/java/org/apache/servicecomb/authentication/TestAccessController.java
@@ -22,12 +22,12 @@
import org.apache.servicecomb.authentication.provider.AccessController;
import org.apache.servicecomb.foundation.test.scaffolding.config.ArchaiusUtils;
import org.apache.servicecomb.registry.api.registry.Microservice;
-import org.junit.After;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestAccessController {
- @After
+ @AfterEach
public void tearDown() {
ArchaiusUtils.resetConfig();
}
diff --git a/handlers/handler-publickey-auth/src/test/java/org/apache/servicecomb/authentication/TestConsumerAuthHandler.java b/handlers/handler-publickey-auth/src/test/java/org/apache/servicecomb/authentication/TestConsumerAuthHandler.java
index cf2786a..652eb0f 100644
--- a/handlers/handler-publickey-auth/src/test/java/org/apache/servicecomb/authentication/TestConsumerAuthHandler.java
+++ b/handlers/handler-publickey-auth/src/test/java/org/apache/servicecomb/authentication/TestConsumerAuthHandler.java
@@ -20,8 +20,8 @@
import org.apache.servicecomb.authentication.consumer.RSAConsumerTokenManager;
import org.apache.servicecomb.core.Invocation;
import org.apache.servicecomb.swagger.invocation.AsyncResponse;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
public class TestConsumerAuthHandler {
@@ -51,7 +51,7 @@
consumerAuthHandler.handle(invocation, asyncResp);
}
- @Before
+ @BeforeEach
public void setUp() throws Exception {
invocation = Mockito.mock(Invocation.class);
asyncResp = Mockito.mock(AsyncResponse.class);
diff --git a/handlers/handler-publickey-auth/src/test/java/org/apache/servicecomb/authentication/TestProviderAuthHandler.java b/handlers/handler-publickey-auth/src/test/java/org/apache/servicecomb/authentication/TestProviderAuthHandler.java
index 74c358b..9203a58 100644
--- a/handlers/handler-publickey-auth/src/test/java/org/apache/servicecomb/authentication/TestProviderAuthHandler.java
+++ b/handlers/handler-publickey-auth/src/test/java/org/apache/servicecomb/authentication/TestProviderAuthHandler.java
@@ -22,9 +22,9 @@
import org.apache.servicecomb.core.Invocation;
import org.apache.servicecomb.foundation.test.scaffolding.config.ArchaiusUtils;
import org.apache.servicecomb.swagger.invocation.AsyncResponse;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
public class TestProviderAuthHandler {
@@ -32,14 +32,14 @@
AsyncResponse asyncResp = null;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
ConfigUtil.installDynamicConfig();
invocation = Mockito.mock(Invocation.class);
asyncResp = Mockito.mock(AsyncResponse.class);
Mockito.when(invocation.getContext(Const.AUTH_TOKEN)).thenReturn("testtoken");
}
- @After
+ @AfterEach
public void tearDown() {
ArchaiusUtils.resetConfig();
}
diff --git a/huawei-cloud/servicestage/src/test/java/org/apache/servicecomb/huaweicloud/servicestage/TestAKSKAuthHeaderProvider.java b/huawei-cloud/servicestage/src/test/java/org/apache/servicecomb/huaweicloud/servicestage/TestAKSKAuthHeaderProvider.java
index 2982403..d5ff9cd 100644
--- a/huawei-cloud/servicestage/src/test/java/org/apache/servicecomb/huaweicloud/servicestage/TestAKSKAuthHeaderProvider.java
+++ b/huawei-cloud/servicestage/src/test/java/org/apache/servicecomb/huaweicloud/servicestage/TestAKSKAuthHeaderProvider.java
@@ -18,7 +18,7 @@
package org.apache.servicecomb.huaweicloud.servicestage;
import org.junit.jupiter.api.Assertions;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import com.netflix.config.ConcurrentCompositeConfiguration;
diff --git a/huawei-cloud/servicestage/src/test/java/org/apache/servicecomb/huaweicloud/servicestage/TestCasEnvConfig.java b/huawei-cloud/servicestage/src/test/java/org/apache/servicecomb/huaweicloud/servicestage/TestCasEnvConfig.java
index e21186c..078ec5a 100644
--- a/huawei-cloud/servicestage/src/test/java/org/apache/servicecomb/huaweicloud/servicestage/TestCasEnvConfig.java
+++ b/huawei-cloud/servicestage/src/test/java/org/apache/servicecomb/huaweicloud/servicestage/TestCasEnvConfig.java
@@ -16,14 +16,14 @@
*/
package org.apache.servicecomb.huaweicloud.servicestage;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
public class TestCasEnvConfig {
- @BeforeClass
+ @BeforeAll
public static void init() {
System.setProperty("CAS_APPLICATION_ID", "application-id");
System.setProperty("CAS_ENVIRONMENT_ID", "env-id");
@@ -37,7 +37,7 @@
Assertions.assertEquals("env-id", instance.getNonEmptyProperties().get("CAS_ENVIRONMENT_ID"));
}
- @AfterClass
+ @AfterAll
public static void destroy() {
System.getProperties().remove("CAS_ENVIRONMENT_ID");
System.getProperties().remove("CAS_APPLICATION_ID");
diff --git a/huawei-cloud/servicestage/src/test/java/org/apache/servicecomb/huaweicloud/servicestage/TestEnvVariablesAdapter.java b/huawei-cloud/servicestage/src/test/java/org/apache/servicecomb/huaweicloud/servicestage/TestEnvVariablesAdapter.java
index 46e8649..004dbf9 100644
--- a/huawei-cloud/servicestage/src/test/java/org/apache/servicecomb/huaweicloud/servicestage/TestEnvVariablesAdapter.java
+++ b/huawei-cloud/servicestage/src/test/java/org/apache/servicecomb/huaweicloud/servicestage/TestEnvVariablesAdapter.java
@@ -17,14 +17,14 @@
package org.apache.servicecomb.huaweicloud.servicestage;
import org.apache.servicecomb.registry.api.registry.MicroserviceInstance;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
public class TestEnvVariablesAdapter {
- @BeforeClass
+ @BeforeAll
public static void init() {
System.setProperty("servicecomb.huaweicloud.servicestage.cas.application-id", "application-id");
System.setProperty("servicecomb.huaweicloud.servicestage.cas.environment-id", "env-id");
@@ -41,7 +41,7 @@
Assertions.assertEquals("env-id", instance.getProperties().get("CAS_ENVIRONMENT_ID"));
}
- @AfterClass
+ @AfterAll
public static void destroy() {
System.getProperties().remove("servicecomb.huaweicloud.servicestage.cas.application-id");
System.getProperties().remove("servicecomb.huaweicloud.servicestage.cas.environment-id");