diff --git a/address/pom.xml b/address/pom.xml
index 2dfb65afa09..36c69ca77e0 100644
--- a/address/pom.xml
+++ b/address/pom.xml
@@ -41,8 +41,8 @@
- org.springframework.boot
- spring-boot-starter-test
+ org.springframework
+ spring-test
test
diff --git a/api/pom.xml b/api/pom.xml
index 63505fc473c..50da5b17068 100644
--- a/api/pom.xml
+++ b/api/pom.xml
@@ -63,11 +63,6 @@
com.fasterxml.jackson.core
jackson-databind
-
- junit
- junit
- test
-
org.springframework
spring-test
diff --git a/api/src/test/java/com/alibaba/nacos/api/naming/pojo/builder/InstanceBuilderTest.java b/api/src/test/java/com/alibaba/nacos/api/naming/pojo/builder/InstanceBuilderTest.java
index 574db46c34f..85e34bda514 100644
--- a/api/src/test/java/com/alibaba/nacos/api/naming/pojo/builder/InstanceBuilderTest.java
+++ b/api/src/test/java/com/alibaba/nacos/api/naming/pojo/builder/InstanceBuilderTest.java
@@ -22,8 +22,6 @@
import java.util.HashMap;
import java.util.Map;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -55,20 +53,20 @@ class InstanceBuilderTest {
@Test
void testBuildFullInstance() {
InstanceBuilder builder = InstanceBuilder.newBuilder();
- Instance actual = builder.setServiceName(SERVICE_NAME).setClusterName(CLUSTER_NAME).setInstanceId(INSTANCE_ID)
- .setIp(IP).setPort(PORT).setWeight(WEIGHT).setHealthy(HEALTHY).setEnabled(ENABLED)
- .setEphemeral(EPHEMERAL).addMetadata(META_KEY, META_VALUE).build();
- assertThat(actual.getServiceName(), is(SERVICE_NAME));
- assertThat(actual.getClusterName(), is(CLUSTER_NAME));
- assertThat(actual.getInstanceId(), is(INSTANCE_ID));
- assertThat(actual.getIp(), is(IP));
- assertThat(actual.getPort(), is(PORT));
- assertThat(actual.getWeight(), is(WEIGHT));
- assertThat(actual.isHealthy(), is(HEALTHY));
- assertThat(actual.isEnabled(), is(ENABLED));
- assertThat(actual.isEphemeral(), is(EPHEMERAL));
- assertThat(actual.getMetadata().size(), is(1));
- assertThat(actual.getMetadata().get(META_KEY), is(META_VALUE));
+ Instance actual = builder.setServiceName(SERVICE_NAME).setClusterName(CLUSTER_NAME).setInstanceId(INSTANCE_ID).setIp(IP)
+ .setPort(PORT).setWeight(WEIGHT).setHealthy(HEALTHY).setEnabled(ENABLED).setEphemeral(EPHEMERAL)
+ .addMetadata(META_KEY, META_VALUE).build();
+ assertEquals(actual.getServiceName(), SERVICE_NAME);
+ assertEquals(actual.getClusterName(), CLUSTER_NAME);
+ assertEquals(actual.getInstanceId(), INSTANCE_ID);
+ assertEquals(actual.getIp(), IP);
+ assertEquals(actual.getPort(), PORT);
+ assertEquals(actual.getWeight(), WEIGHT);
+ assertEquals(actual.isHealthy(), HEALTHY);
+ assertEquals(actual.isEnabled(), ENABLED);
+ assertEquals(actual.isEphemeral(), EPHEMERAL);
+ assertEquals(actual.getMetadata().size(), 1);
+ assertEquals(actual.getMetadata().get(META_KEY), META_VALUE);
}
@Test
@@ -81,8 +79,8 @@ void testBuildInstanceWithoutNewMetadata() {
assertNull(actual.getClusterName());
assertNull(actual.getInstanceId());
assertNull(actual.getIp());
- assertThat(actual.getPort(), is(0));
- assertThat(actual.getWeight(), is(1.0));
+ assertEquals(actual.getPort(), 0);
+ assertEquals(actual.getWeight(), 1.0);
assertTrue(actual.isHealthy());
assertTrue(actual.isEnabled());
assertTrue(actual.isEphemeral());
@@ -97,8 +95,8 @@ void testBuildEmptyInstance() {
assertNull(actual.getClusterName());
assertNull(actual.getInstanceId());
assertNull(actual.getIp());
- assertThat(actual.getPort(), is(0));
- assertThat(actual.getWeight(), is(1.0));
+ assertEquals(actual.getPort(), 0);
+ assertEquals(actual.getWeight(), 1.0);
assertTrue(actual.isHealthy());
assertTrue(actual.isEnabled());
assertTrue(actual.isEphemeral());
diff --git a/auth/pom.xml b/auth/pom.xml
index 745aab5dd4b..f1af84b1a1f 100644
--- a/auth/pom.xml
+++ b/auth/pom.xml
@@ -50,7 +50,11 @@
spring-boot-starter
true
-
+
+ org.springframework
+ spring-test
+ test
+
org.apache.tomcat.embed
tomcat-embed-core
diff --git a/client/src/test/java/com/alibaba/nacos/client/naming/event/InstancesDiffTest.java b/client/src/test/java/com/alibaba/nacos/client/naming/event/InstancesDiffTest.java
index 0842558a847..af3f9ecf6d2 100644
--- a/client/src/test/java/com/alibaba/nacos/client/naming/event/InstancesDiffTest.java
+++ b/client/src/test/java/com/alibaba/nacos/client/naming/event/InstancesDiffTest.java
@@ -18,16 +18,27 @@
import com.alibaba.nacos.api.naming.pojo.Instance;
import com.alibaba.nacos.api.naming.pojo.builder.InstanceBuilder;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Random;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
public class InstancesDiffTest {
+ private static List getInstanceList(int count) {
+ ArrayList list = new ArrayList<>(count);
+ for (int i = 0; i < count; i++) {
+ list.add(new Instance());
+ }
+ return list;
+ }
+
@Test
public void testGetDiff() {
String serviceName = "testService";
@@ -40,13 +51,13 @@ public void testGetDiff() {
instancesDiff.setRemovedInstances(Collections.singletonList(removedIns));
instancesDiff.setModifiedInstances(Collections.singletonList(modifiedIns));
- Assert.assertTrue(instancesDiff.hasDifferent());
- Assert.assertTrue(instancesDiff.isAdded());
- Assert.assertTrue(instancesDiff.isRemoved());
- Assert.assertTrue(instancesDiff.isModified());
- Assert.assertEquals(addedIns, instancesDiff.getAddedInstances().get(0));
- Assert.assertEquals(removedIns, instancesDiff.getRemovedInstances().get(0));
- Assert.assertEquals(modifiedIns, instancesDiff.getModifiedInstances().get(0));
+ assertTrue(instancesDiff.hasDifferent());
+ assertTrue(instancesDiff.isAdded());
+ assertTrue(instancesDiff.isRemoved());
+ assertTrue(instancesDiff.isModified());
+ assertEquals(addedIns, instancesDiff.getAddedInstances().get(0));
+ assertEquals(removedIns, instancesDiff.getRemovedInstances().get(0));
+ assertEquals(modifiedIns, instancesDiff.getModifiedInstances().get(0));
}
@Test
@@ -58,21 +69,21 @@ public void testWithFullConstructor() {
InstancesDiff instancesDiff = new InstancesDiff(getInstanceList(addedCount), getInstanceList(removedCount),
getInstanceList(modifiedCount));
- Assert.assertTrue(instancesDiff.hasDifferent());
- Assert.assertTrue(instancesDiff.isAdded());
- Assert.assertTrue(instancesDiff.isRemoved());
- Assert.assertTrue(instancesDiff.isModified());
- Assert.assertEquals(addedCount, instancesDiff.getAddedInstances().size());
- Assert.assertEquals(removedCount, instancesDiff.getRemovedInstances().size());
- Assert.assertEquals(modifiedCount, instancesDiff.getModifiedInstances().size());
+ assertTrue(instancesDiff.hasDifferent());
+ assertTrue(instancesDiff.isAdded());
+ assertTrue(instancesDiff.isRemoved());
+ assertTrue(instancesDiff.isModified());
+ assertEquals(addedCount, instancesDiff.getAddedInstances().size());
+ assertEquals(removedCount, instancesDiff.getRemovedInstances().size());
+ assertEquals(modifiedCount, instancesDiff.getModifiedInstances().size());
instancesDiff.getAddedInstances().clear();
instancesDiff.getRemovedInstances().clear();
instancesDiff.getModifiedInstances().clear();
- Assert.assertFalse(instancesDiff.hasDifferent());
- Assert.assertFalse(instancesDiff.hasDifferent());
- Assert.assertFalse(instancesDiff.isAdded());
- Assert.assertFalse(instancesDiff.isRemoved());
- Assert.assertFalse(instancesDiff.isModified());
+ assertFalse(instancesDiff.hasDifferent());
+ assertFalse(instancesDiff.hasDifferent());
+ assertFalse(instancesDiff.isAdded());
+ assertFalse(instancesDiff.isRemoved());
+ assertFalse(instancesDiff.isModified());
}
@Test
@@ -86,24 +97,16 @@ public void testWithNoConstructor() {
instancesDiff.setRemovedInstances(getInstanceList(removedCount));
instancesDiff.setModifiedInstances(getInstanceList(modifiedCount));
- Assert.assertTrue(instancesDiff.hasDifferent());
- Assert.assertEquals(addedCount, instancesDiff.getAddedInstances().size());
- Assert.assertEquals(removedCount, instancesDiff.getRemovedInstances().size());
- Assert.assertEquals(modifiedCount, instancesDiff.getModifiedInstances().size());
+ assertTrue(instancesDiff.hasDifferent());
+ assertEquals(addedCount, instancesDiff.getAddedInstances().size());
+ assertEquals(removedCount, instancesDiff.getRemovedInstances().size());
+ assertEquals(modifiedCount, instancesDiff.getModifiedInstances().size());
instancesDiff.getAddedInstances().clear();
instancesDiff.getRemovedInstances().clear();
instancesDiff.getModifiedInstances().clear();
- Assert.assertFalse(instancesDiff.hasDifferent());
- Assert.assertFalse(instancesDiff.isAdded());
- Assert.assertFalse(instancesDiff.isRemoved());
- Assert.assertFalse(instancesDiff.isModified());
- }
-
- private static List getInstanceList(int count) {
- ArrayList list = new ArrayList<>(count);
- for (int i = 0; i < count; i++) {
- list.add(new Instance());
- }
- return list;
+ assertFalse(instancesDiff.hasDifferent());
+ assertFalse(instancesDiff.isAdded());
+ assertFalse(instancesDiff.isRemoved());
+ assertFalse(instancesDiff.isModified());
}
}
diff --git a/client/src/test/java/com/alibaba/nacos/client/naming/listener/NamingChangeEventTest.java b/client/src/test/java/com/alibaba/nacos/client/naming/listener/NamingChangeEventTest.java
index 66278c13a80..7f97bbcbb10 100644
--- a/client/src/test/java/com/alibaba/nacos/client/naming/listener/NamingChangeEventTest.java
+++ b/client/src/test/java/com/alibaba/nacos/client/naming/listener/NamingChangeEventTest.java
@@ -18,16 +18,16 @@
import com.alibaba.nacos.api.naming.pojo.Instance;
import com.alibaba.nacos.client.naming.event.InstancesDiff;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import java.util.Arrays;
import java.util.Collections;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
public class NamingChangeEventTest {
@@ -35,7 +35,7 @@ public class NamingChangeEventTest {
private InstancesDiff instancesDiff;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
eventListener = new MockNamingEventListener();
instancesDiff = new InstancesDiff();
diff --git a/client/src/test/java/com/alibaba/nacos/client/naming/selector/DefaultNamingSelectorTest.java b/client/src/test/java/com/alibaba/nacos/client/naming/selector/DefaultNamingSelectorTest.java
index 7860d511214..03fad8f3c16 100644
--- a/client/src/test/java/com/alibaba/nacos/client/naming/selector/DefaultNamingSelectorTest.java
+++ b/client/src/test/java/com/alibaba/nacos/client/naming/selector/DefaultNamingSelectorTest.java
@@ -19,14 +19,14 @@
import com.alibaba.nacos.api.naming.pojo.Instance;
import com.alibaba.nacos.api.naming.selector.NamingContext;
import com.alibaba.nacos.api.naming.selector.NamingResult;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
-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.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
diff --git a/client/src/test/java/com/alibaba/nacos/client/naming/selector/NamingListenerInvokerTest.java b/client/src/test/java/com/alibaba/nacos/client/naming/selector/NamingListenerInvokerTest.java
index 0614bca0c0a..8a62a1ea815 100644
--- a/client/src/test/java/com/alibaba/nacos/client/naming/selector/NamingListenerInvokerTest.java
+++ b/client/src/test/java/com/alibaba/nacos/client/naming/selector/NamingListenerInvokerTest.java
@@ -22,12 +22,12 @@
import com.alibaba.nacos.client.naming.event.InstancesDiff;
import com.alibaba.nacos.client.naming.listener.AbstractNamingChangeListener;
import com.alibaba.nacos.client.naming.listener.NamingChangeEvent;
-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.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
diff --git a/client/src/test/java/com/alibaba/nacos/client/naming/selector/NamingSelectorFactoryTest.java b/client/src/test/java/com/alibaba/nacos/client/naming/selector/NamingSelectorFactoryTest.java
index af4290d643b..3c3aa27ad95 100644
--- a/client/src/test/java/com/alibaba/nacos/client/naming/selector/NamingSelectorFactoryTest.java
+++ b/client/src/test/java/com/alibaba/nacos/client/naming/selector/NamingSelectorFactoryTest.java
@@ -20,16 +20,16 @@
import com.alibaba.nacos.api.naming.selector.NamingContext;
import com.alibaba.nacos.api.naming.selector.NamingResult;
import com.alibaba.nacos.api.naming.selector.NamingSelector;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
diff --git a/client/src/test/java/com/alibaba/nacos/client/naming/selector/NamingSelectorWrapperTest.java b/client/src/test/java/com/alibaba/nacos/client/naming/selector/NamingSelectorWrapperTest.java
index 205a662af49..2d941617ab9 100644
--- a/client/src/test/java/com/alibaba/nacos/client/naming/selector/NamingSelectorWrapperTest.java
+++ b/client/src/test/java/com/alibaba/nacos/client/naming/selector/NamingSelectorWrapperTest.java
@@ -22,17 +22,17 @@
import com.alibaba.nacos.client.naming.event.InstancesChangeEvent;
import com.alibaba.nacos.client.naming.event.InstancesDiff;
import com.alibaba.nacos.client.naming.listener.NamingChangeEvent;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.Collections;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.argThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
diff --git a/client/src/test/java/com/alibaba/nacos/client/selector/SelectorManagerTest.java b/client/src/test/java/com/alibaba/nacos/client/selector/SelectorManagerTest.java
index dd15a7ca750..0d68977111a 100644
--- a/client/src/test/java/com/alibaba/nacos/client/selector/SelectorManagerTest.java
+++ b/client/src/test/java/com/alibaba/nacos/client/selector/SelectorManagerTest.java
@@ -17,15 +17,15 @@
package com.alibaba.nacos.client.selector;
import com.alibaba.nacos.client.naming.selector.NamingSelectorWrapper;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.Set;
-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.mockito.Mockito.mock;
public class SelectorManagerTest {
diff --git a/cmdb/pom.xml b/cmdb/pom.xml
index 4aa45d2b099..3a0cda7cedf 100644
--- a/cmdb/pom.xml
+++ b/cmdb/pom.xml
@@ -52,11 +52,6 @@
org.springframework.boot
spring-boot-starter-web
-
- org.springframework.boot
- spring-boot-starter-test
- test
-
diff --git a/common/src/test/java/com/alibaba/nacos/common/trace/publisher/TraceEventPublisherTest.java b/common/src/test/java/com/alibaba/nacos/common/trace/publisher/TraceEventPublisherTest.java
index 824a3a3f505..4cf991267d9 100644
--- a/common/src/test/java/com/alibaba/nacos/common/trace/publisher/TraceEventPublisherTest.java
+++ b/common/src/test/java/com/alibaba/nacos/common/trace/publisher/TraceEventPublisherTest.java
@@ -27,8 +27,7 @@
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.verify;
@@ -100,13 +99,13 @@ void getStatus() throws NacosException {
traceEventPublisher.publish(new TraceTestEvent.TraceTestEvent1());
traceEventPublisher.publish(new TraceTestEvent.TraceTestEvent2());
String expectedStatus = "Publisher TraceTestEvent : shutdown=false, queue= 3/8 ";
- assertThat(traceEventPublisher.getStatus(), is(expectedStatus));
+ assertEquals(traceEventPublisher.getStatus(), expectedStatus);
traceEventPublisher.addSubscriber(subscriber, TraceTestEvent.TraceTestEvent1.class);
ThreadUtils.sleep(2000L);
expectedStatus = "Publisher TraceTestEvent : shutdown=false, queue= 0/8 ";
- assertThat(traceEventPublisher.getStatus(), is(expectedStatus));
+ assertEquals(traceEventPublisher.getStatus(), expectedStatus);
traceEventPublisher.shutdown();
expectedStatus = "Publisher TraceTestEvent : shutdown= true, queue= 0/8 ";
- assertThat(traceEventPublisher.getStatus(), is(expectedStatus));
+ assertEquals(traceEventPublisher.getStatus(), expectedStatus);
}
}
diff --git a/config/pom.xml b/config/pom.xml
index f37acf76067..c10e7df3796 100644
--- a/config/pom.xml
+++ b/config/pom.xml
@@ -124,6 +124,16 @@
spring-boot-test-autoconfigure
test
+
+ org.springframework
+ spring-test
+ test
+
+
+ org.hamcrest
+ hamcrest
+ test
+
diff --git a/config/src/test/java/com/alibaba/nacos/config/server/exception/GlobalExceptionHandlerTest.java b/config/src/test/java/com/alibaba/nacos/config/server/exception/GlobalExceptionHandlerTest.java
index 8f4f8ce2a60..34e193a0627 100644
--- a/config/src/test/java/com/alibaba/nacos/config/server/exception/GlobalExceptionHandlerTest.java
+++ b/config/src/test/java/com/alibaba/nacos/config/server/exception/GlobalExceptionHandlerTest.java
@@ -21,11 +21,9 @@
import com.alibaba.nacos.config.server.controller.v2.HistoryControllerV2;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.boot.test.mock.mockito.MockBean;
-import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.ResultActions;
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
@@ -35,7 +33,6 @@
import static org.mockito.Mockito.when;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
-@RunWith(SpringRunner.class)
@WebMvcTest(GlobalExceptionHandlerTest.class)
class GlobalExceptionHandlerTest {
@@ -71,4 +68,4 @@ void testNacosRunTimeExceptionHandler() throws Exception {
resultActions2.andExpect(MockMvcResultMatchers.status().is(503));
}
-}
\ No newline at end of file
+}
diff --git a/console/pom.xml b/console/pom.xml
index 7ae191d4aa5..d2dfca5629d 100644
--- a/console/pom.xml
+++ b/console/pom.xml
@@ -78,6 +78,16 @@
spring-boot-test-autoconfigure
test
+
+ org.springframework
+ spring-test
+ test
+
+
+ org.hamcrest
+ hamcrest
+ test
+
diff --git a/console/src/test/java/com/alibaba/nacos/console/exception/NacosApiExceptionHandlerTest.java b/console/src/test/java/com/alibaba/nacos/console/exception/NacosApiExceptionHandlerTest.java
index 920a1030333..be8b57a0626 100644
--- a/console/src/test/java/com/alibaba/nacos/console/exception/NacosApiExceptionHandlerTest.java
+++ b/console/src/test/java/com/alibaba/nacos/console/exception/NacosApiExceptionHandlerTest.java
@@ -21,11 +21,9 @@
import com.alibaba.nacos.console.controller.v2.NamespaceControllerV2;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.boot.test.mock.mockito.MockBean;
-import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.ResultActions;
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
@@ -36,7 +34,6 @@
import static org.mockito.Mockito.when;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
-@RunWith(SpringRunner.class)
@WebMvcTest(NacosApiExceptionHandler.class)
class NacosApiExceptionHandlerTest {
@@ -71,4 +68,4 @@ void testNacosRunTimeExceptionHandler() throws Exception {
ResultActions resultActions2 = mockMvc.perform(post("/v2/console/namespace"));
resultActions2.andExpect(MockMvcResultMatchers.status().is(503));
}
-}
\ No newline at end of file
+}
diff --git a/core/pom.xml b/core/pom.xml
index 934df6fea91..0187e0a4757 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -75,17 +75,6 @@
spring-boot-starter-security
-
- org.springframework.boot
- spring-boot-starter-test
- test
-
-
- org.junit.vintage
- junit-vintage-engine
-
-
-
org.springframework.security
spring-security-test
@@ -95,11 +84,13 @@
org.springframework
spring-test
+ test
org.springframework.boot
spring-boot-test
+ test
org.apache.tomcat.embed
diff --git a/persistence/pom.xml b/persistence/pom.xml
index a72c2f3f23a..fee4f4eba4a 100644
--- a/persistence/pom.xml
+++ b/persistence/pom.xml
@@ -62,6 +62,11 @@
org.apache.derby
derby
+
+ org.springframework
+ spring-test
+ test
+
-
\ No newline at end of file
+
diff --git a/plugin-default-impl/nacos-default-auth-plugin/pom.xml b/plugin-default-impl/nacos-default-auth-plugin/pom.xml
index 95b618c4686..11e4d389b11 100644
--- a/plugin-default-impl/nacos-default-auth-plugin/pom.xml
+++ b/plugin-default-impl/nacos-default-auth-plugin/pom.xml
@@ -54,5 +54,11 @@
org.springframework.ldap
spring-ldap-core
+
+
+ org.springframework
+ spring-test
+ test
+
-
\ No newline at end of file
+
diff --git a/pom.xml b/pom.xml
index 6257e8e7802..aeedc9999bc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -621,16 +621,6 @@
-
- junit
- junit
- test
-
-
- org.junit.vintage
- junit-vintage-engine
- test
-
org.junit.jupiter
junit-jupiter
diff --git a/prometheus/pom.xml b/prometheus/pom.xml
index f36bc67857a..fad764f2e38 100644
--- a/prometheus/pom.xml
+++ b/prometheus/pom.xml
@@ -48,6 +48,16 @@
spring-boot-test-autoconfigure
test
+
+ org.springframework
+ spring-test
+ test
+
+
+ org.hamcrest
+ hamcrest
+ test
+
diff --git a/prometheus/src/test/java/com/alibaba/nacos/prometheus/controller/PrometheusControllerTest.java b/prometheus/src/test/java/com/alibaba/nacos/prometheus/controller/PrometheusControllerTest.java
index 52f638d62c4..d8c9acfd617 100644
--- a/prometheus/src/test/java/com/alibaba/nacos/prometheus/controller/PrometheusControllerTest.java
+++ b/prometheus/src/test/java/com/alibaba/nacos/prometheus/controller/PrometheusControllerTest.java
@@ -24,14 +24,13 @@
import com.alibaba.nacos.naming.core.v2.ServiceManager;
import com.alibaba.nacos.naming.core.v2.pojo.Service;
import com.alibaba.nacos.prometheus.api.ApiConstants;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.mock.web.MockHttpServletResponse;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder;
@@ -43,7 +42,7 @@
import java.util.List;
import java.util.Map;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.when;
/**
@@ -52,9 +51,15 @@
* @author karsonto
* @date 2023-02-01 10:56
*/
-@RunWith(MockitoJUnitRunner.class)
+@ExtendWith(MockitoExtension.class)
public class PrometheusControllerTest {
+ private final String nameSpace = "A";
+
+ private final String group = "B";
+
+ private final String name = "C";
+
@InjectMocks
private PrometheusController prometheusController;
@@ -63,17 +68,11 @@ public class PrometheusControllerTest {
private Service service;
- private final String nameSpace = "A";
-
- private final String group = "B";
-
- private final String name = "C";
-
private List testInstanceList;
private MockMvc mockMvc;
- @Before
+ @BeforeEach
public void setUp() throws NoSuchFieldException, IllegalAccessException, NacosException {
ServiceManager serviceManager = ServiceManager.getInstance();
service = Service.newService(nameSpace, group, name);
@@ -83,7 +82,7 @@ public void setUp() throws NoSuchFieldException, IllegalAccessException, NacosEx
testInstanceList.add(prepareInstance("A", "127.0.0.1", 8081, Collections.singletonMap("__meta_key", "value2")));
mockMvc = MockMvcBuilders.standaloneSetup(prometheusController).build();
}
-
+
private Instance prepareInstance(String clusterName, String ip, int port, Map metadata) {
Instance instance = new Instance();
instance.setClusterName("A");
@@ -93,7 +92,7 @@ private Instance prepareInstance(String clusterName, String ip, int port, Mapspring-boot-starter
-
- org.springframework.boot
- spring-boot-starter-test
- test
-
-
- org.junit.vintage
- junit-vintage-engine
-
-
-
-
org.springframework
spring-test
+ test
org.springframework.boot
spring-boot-test
+ test
com.alibaba.nacos
diff --git a/sys/src/test/java/com/alibaba/nacos/sys/env/EnvUtilWithConfigTest.java b/sys/src/test/java/com/alibaba/nacos/sys/env/EnvUtilWithConfigTest.java
index c247773a2ad..97e6db6a43f 100644
--- a/sys/src/test/java/com/alibaba/nacos/sys/env/EnvUtilWithConfigTest.java
+++ b/sys/src/test/java/com/alibaba/nacos/sys/env/EnvUtilWithConfigTest.java
@@ -18,17 +18,14 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.env.Environment;
import org.springframework.test.context.ActiveProfiles;
-import org.springframework.test.context.junit4.SpringRunner;
import static org.junit.jupiter.api.Assertions.assertEquals;
-@RunWith(SpringRunner.class)
@ActiveProfiles("test")
@SpringBootTest(classes = EnvUtilWithConfigTest.class)
class EnvUtilWithConfigTest {
diff --git a/sys/src/test/java/com/alibaba/nacos/sys/env/EnvUtilWithoutConfigTest.java b/sys/src/test/java/com/alibaba/nacos/sys/env/EnvUtilWithoutConfigTest.java
index 65bbbc18c68..42f36c4ad05 100644
--- a/sys/src/test/java/com/alibaba/nacos/sys/env/EnvUtilWithoutConfigTest.java
+++ b/sys/src/test/java/com/alibaba/nacos/sys/env/EnvUtilWithoutConfigTest.java
@@ -19,17 +19,14 @@
import com.alibaba.nacos.common.utils.ThreadUtils;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.env.Environment;
import org.springframework.test.context.ActiveProfiles;
-import org.springframework.test.context.junit4.SpringRunner;
import static org.junit.jupiter.api.Assertions.assertEquals;
-@RunWith(SpringRunner.class)
@ActiveProfiles("empty")
@SpringBootTest(classes = EnvUtilWithConfigTest.class)
class EnvUtilWithoutConfigTest {
diff --git a/sys/src/test/java/com/alibaba/nacos/sys/utils/PropertiesUtilTest.java b/sys/src/test/java/com/alibaba/nacos/sys/utils/PropertiesUtilTest.java
index 78be84b5a65..659dee75ccf 100644
--- a/sys/src/test/java/com/alibaba/nacos/sys/utils/PropertiesUtilTest.java
+++ b/sys/src/test/java/com/alibaba/nacos/sys/utils/PropertiesUtilTest.java
@@ -17,19 +17,16 @@
package com.alibaba.nacos.sys.utils;
import org.junit.jupiter.api.Test;
-import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.test.context.ActiveProfiles;
-import org.springframework.test.context.junit4.SpringRunner;
import java.util.Map;
import java.util.Properties;
import static org.junit.jupiter.api.Assertions.assertEquals;
-@RunWith(SpringRunner.class)
@ActiveProfiles("prefix")
@SpringBootTest(classes = PropertiesUtilTest.class)
class PropertiesUtilTest {