This is an automated email from the ASF dual-hosted git repository.

albumenj pushed a commit to branch 3.2
in repository https://gitbox.apache.org/repos/asf/dubbo.git


The following commit(s) were added to refs/heads/3.2 by this push:
     new a0f4c6dc33 [3.2] Remove deprecated method invocation in tests (Common 
Module). (#11925)
a0f4c6dc33 is described below

commit a0f4c6dc338f0acfd59919b499fde4a16cf7384b
Author: Andy Cheung <[email protected]>
AuthorDate: Tue Mar 28 15:36:06 2023 +0800

    [3.2] Remove deprecated method invocation in tests (Common Module). (#11925)
    
    * Remove deprecated method invocation in EagerThreadPoolExecutorTest and 
ModuleServiceRepositoryTest.
    
    * Reformat ExtensionLoaderTest.
    
    * Optimize ApplicationModel, EnvironmentTest, JsonUtilsTest, JsonUtils.
    
    * Optimize ReflectUtils.
    
    * Remove test only methods in FileCacheStore, FileCacheStoreFactory.
    
    * Optimize tests in common module.
    
    * Optimize tests in common module (2).
    
    * Optimize tests in common module (3).
    
    * Remove setJson() method.
    
    * Remove blank test.
    
    * Revert "Remove setJson() method."
    
    * Revert "Remove test only methods in FileCacheStore, 
FileCacheStoreFactory.".
    
    * Revert "Remove blank test."
    
    * Revert the commit to original JsonUtils.
---
 .../dubbo/common/timer/HashedWheelTimer.java       |  2 +-
 .../java/org/apache/dubbo/common/utils/JRE.java    |  2 +-
 .../org/apache/dubbo/common/utils/PojoUtils.java   | 43 ++++++------
 .../apache/dubbo/common/utils/ReflectUtils.java    |  8 +--
 .../apache/dubbo/rpc/model/ApplicationModel.java   |  2 +-
 .../common/compiler/support/ClassUtilsTest.java    | 34 ++++-----
 .../dubbo/common/config/EnvironmentTest.java       |  4 +-
 .../DynamicConfigurationFactoryTest.java           |  9 ++-
 .../apache/dubbo/common/convert/ConverterTest.java |  9 ++-
 .../common/convert/StringToLongConverterTest.java  | 10 ++-
 .../common/extension/ExtensionLoaderTest.java      | 20 +++---
 .../extension/ExtensionLoader_Compatible_Test.java | 13 ++--
 .../NamedInternalThreadFactoryTest.java            |  8 +--
 .../support/eager/EagerThreadPoolExecutorTest.java |  8 ++-
 .../org/apache/dubbo/common/utils/JRETest.java     | 17 ++---
 .../apache/dubbo/common/utils/JsonUtilsTest.java   |  2 +-
 .../dubbo/common/utils/ReflectUtilsTest.java       | 80 ++++++++++++----------
 .../dubbo/config/context/ConfigManagerTest.java    | 24 +++++--
 .../rpc/model/ModuleServiceRepositoryTest.java     | 12 ++--
 19 files changed, 174 insertions(+), 133 deletions(-)

diff --git 
a/dubbo-common/src/main/java/org/apache/dubbo/common/timer/HashedWheelTimer.java
 
b/dubbo-common/src/main/java/org/apache/dubbo/common/timer/HashedWheelTimer.java
index b6589949d4..a5c255b2b8 100644
--- 
a/dubbo-common/src/main/java/org/apache/dubbo/common/timer/HashedWheelTimer.java
+++ 
b/dubbo-common/src/main/java/org/apache/dubbo/common/timer/HashedWheelTimer.java
@@ -422,7 +422,7 @@ public class HashedWheelTimer implements Timer {
     private static void reportTooManyInstances() {
         String resourceType = 
ClassUtils.simpleClassName(HashedWheelTimer.class);
         logger.error(COMMON_ERROR_TOO_MANY_INSTANCES, "", "", "You are 
creating too many " + resourceType + " instances. " +
-            resourceType + " is a shared resource that must be reused across 
the JVM," +
+            resourceType + " is a shared resource that must be reused across 
the JVM, " +
             "so that only a few instances are created.");
     }
 
diff --git a/dubbo-common/src/main/java/org/apache/dubbo/common/utils/JRE.java 
b/dubbo-common/src/main/java/org/apache/dubbo/common/utils/JRE.java
index 5bba8a70da..8bc095d61e 100644
--- a/dubbo-common/src/main/java/org/apache/dubbo/common/utils/JRE.java
+++ b/dubbo-common/src/main/java/org/apache/dubbo/common/utils/JRE.java
@@ -117,7 +117,7 @@ public enum JRE {
                     return OTHER;
             }
         } catch (Exception e) {
-            logger.debug("can't determine current JRE version, if JRE version 
is 8 but java.version is null", e);
+            logger.debug("Can't determine current JRE version (maybe 
java.version is null), assuming that JRE version is 8.", e);
         }
         // default java 8
         return JAVA_8;
diff --git 
a/dubbo-common/src/main/java/org/apache/dubbo/common/utils/PojoUtils.java 
b/dubbo-common/src/main/java/org/apache/dubbo/common/utils/PojoUtils.java
index 200aa7b1be..b290529ccb 100644
--- a/dubbo-common/src/main/java/org/apache/dubbo/common/utils/PojoUtils.java
+++ b/dubbo-common/src/main/java/org/apache/dubbo/common/utils/PojoUtils.java
@@ -16,6 +16,12 @@
  */
 package org.apache.dubbo.common.utils;
 
+import org.apache.dubbo.common.config.ConfigurationUtils;
+import org.apache.dubbo.common.constants.CommonConstants;
+import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
+import org.apache.dubbo.common.logger.LoggerFactory;
+import org.apache.dubbo.rpc.model.ApplicationModel;
+
 import java.lang.reflect.Array;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Field;
@@ -53,11 +59,6 @@ import java.util.concurrent.ConcurrentSkipListMap;
 import java.util.function.Consumer;
 import java.util.function.Supplier;
 
-import org.apache.dubbo.common.config.ConfigurationUtils;
-import org.apache.dubbo.common.constants.CommonConstants;
-import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
-import org.apache.dubbo.common.logger.LoggerFactory;
-
 import static 
org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_REFLECTIVE_OPERATION_FAILED;
 import static org.apache.dubbo.common.utils.ClassUtils.isAssignableFrom;
 
@@ -78,13 +79,15 @@ import static 
org.apache.dubbo.common.utils.ClassUtils.isAssignableFrom;
 public class PojoUtils {
 
     private static final ErrorTypeAwareLogger logger = 
LoggerFactory.getErrorTypeAwareLogger(PojoUtils.class);
-    private static final ConcurrentMap<String, Method> NAME_METHODS_CACHE = 
new ConcurrentHashMap<String, Method>();
-    private static final ConcurrentMap<Class<?>, ConcurrentMap<String, Field>> 
CLASS_FIELD_CACHE = new ConcurrentHashMap<Class<?>, ConcurrentMap<String, 
Field>>();
+    private static final ConcurrentMap<String, Method> NAME_METHODS_CACHE = 
new ConcurrentHashMap<>();
+    private static final ConcurrentMap<Class<?>, ConcurrentMap<String, Field>> 
CLASS_FIELD_CACHE = new ConcurrentHashMap<>();
 
-    private static final ConcurrentMap<String, Object> CLASS_NOT_FOUND_CACHE = 
new ConcurrentHashMap<String, Object>();
+    private static final ConcurrentMap<String, Object> CLASS_NOT_FOUND_CACHE = 
new ConcurrentHashMap<>();
 
     private static final Object NOT_FOUND_VALUE = new Object();
-    private static final boolean GENERIC_WITH_CLZ = 
Boolean.parseBoolean(ConfigurationUtils.getProperty(CommonConstants.GENERIC_WITH_CLZ_KEY,
 "true"));
+    private static final boolean GENERIC_WITH_CLZ = Boolean.parseBoolean(
+        ConfigurationUtils.getProperty(ApplicationModel.defaultModel(), 
CommonConstants.GENERIC_WITH_CLZ_KEY, "true"));
+
     private static final List<Class<?>> CLASS_CAN_BE_STRING = 
Arrays.asList(Byte.class, Short.class, Integer.class,
         Long.class, Float.class, Double.class, Boolean.class, Character.class);
 
@@ -121,7 +124,7 @@ public class PojoUtils {
     }
 
     public static Object generalize(Object pojo) {
-        return generalize(pojo, new IdentityHashMap<Object, Object>());
+        return generalize(pojo, new IdentityHashMap<>());
     }
 
     @SuppressWarnings("unchecked")
@@ -173,7 +176,7 @@ public class PojoUtils {
         if (pojo instanceof Collection<?>) {
             Collection<Object> src = (Collection<Object>) pojo;
             int len = src.size();
-            Collection<Object> dest = (pojo instanceof List<?>) ? new 
ArrayList<Object>(len) : new HashSet<Object>(len);
+            Collection<Object> dest = (pojo instanceof List<?>) ? new 
ArrayList<>(len) : new HashSet<>(len);
             history.put(pojo, dest);
             for (Object obj : src) {
                 dest.add(generalize(obj, history));
@@ -189,7 +192,7 @@ public class PojoUtils {
             }
             return dest;
         }
-        Map<String, Object> map = new HashMap<String, Object>();
+        Map<String, Object> map = new HashMap<>();
         history.put(pojo, map);
         if (GENERIC_WITH_CLZ) {
             map.put("class", pojo.getClass().getName());
@@ -228,16 +231,16 @@ public class PojoUtils {
     }
 
     public static Object realize(Object pojo, Class<?> type) {
-        return realize0(pojo, type, null, new IdentityHashMap<Object, 
Object>());
+        return realize0(pojo, type, null, new IdentityHashMap<>());
     }
 
     public static Object realize(Object pojo, Class<?> type, Type genericType) 
{
-        return realize0(pojo, type, genericType, new IdentityHashMap<Object, 
Object>());
+        return realize0(pojo, type, genericType, new IdentityHashMap<>());
     }
 
     private static class PojoInvocationHandler implements InvocationHandler {
 
-        private Map<Object, Object> map;
+        private final Map<Object, Object> map;
 
         public PojoInvocationHandler(Map<Object, Object> map) {
             this.map = map;
@@ -259,7 +262,7 @@ public class PojoUtils {
                 value = map.get(methodName.substring(0, 1).toLowerCase() + 
methodName.substring(1));
             }
             if (value instanceof Map<?, ?> && 
!Map.class.isAssignableFrom(method.getReturnType())) {
-                value = realize0((Map<String, Object>) value, 
method.getReturnType(), null, new IdentityHashMap<Object, Object>());
+                value = realize0(value, method.getReturnType(), null, new 
IdentityHashMap<>());
             }
             return value;
         }
@@ -268,10 +271,10 @@ public class PojoUtils {
     @SuppressWarnings("unchecked")
     private static Collection<Object> createCollection(Class<?> type, int len) 
{
         if (type.isAssignableFrom(ArrayList.class)) {
-            return new ArrayList<Object>(len);
+            return new ArrayList<>(len);
         }
         if (type.isAssignableFrom(HashSet.class)) {
-            return new HashSet<Object>(len);
+            return new HashSet<>(len);
         }
         if (!type.isInterface() && !Modifier.isAbstract(type.getModifiers())) {
             try {
@@ -280,7 +283,7 @@ public class PojoUtils {
                 // ignore
             }
         }
-        return new ArrayList<Object>();
+        return new ArrayList<>();
     }
 
     private static Map createMap(Map src) {
@@ -318,7 +321,7 @@ public class PojoUtils {
         }
 
         if (result == null) {
-            result = new HashMap<Object, Object>();
+            result = new HashMap<>();
         }
 
         return result;
diff --git 
a/dubbo-common/src/main/java/org/apache/dubbo/common/utils/ReflectUtils.java 
b/dubbo-common/src/main/java/org/apache/dubbo/common/utils/ReflectUtils.java
index 8f7339bf8d..b32cf2d1e4 100644
--- a/dubbo-common/src/main/java/org/apache/dubbo/common/utils/ReflectUtils.java
+++ b/dubbo-common/src/main/java/org/apache/dubbo/common/utils/ReflectUtils.java
@@ -872,7 +872,7 @@ public final class ReflectUtils {
             return EMPTY_CLASS_ARRAY;
         }
 
-        List<Class<?>> cs = new ArrayList<Class<?>>();
+        List<Class<?>> cs = new ArrayList<>();
         Matcher m = DESC_PATTERN.matcher(desc);
         while (m.find()) {
             cs.add(desc2class(cl, m.group()));
@@ -900,7 +900,7 @@ public final class ReflectUtils {
         }
         Method method;
         if (parameterTypes == null) {
-            List<Method> finded = new ArrayList<Method>();
+            List<Method> finded = new ArrayList<>();
             for (Method m : clazz.getMethods()) {
                 if (m.getName().equals(methodName)) {
                     finded.add(m);
@@ -1140,7 +1140,7 @@ public final class ReflectUtils {
     }
 
     public static Map<String, Field> getBeanPropertyFields(Class cl) {
-        Map<String, Field> properties = new HashMap<String, Field>();
+        Map<String, Field> properties = new HashMap<>();
         for (; cl != null; cl = cl.getSuperclass()) {
             Field[] fields = cl.getDeclaredFields();
             for (Field field : fields) {
@@ -1159,7 +1159,7 @@ public final class ReflectUtils {
     }
 
     public static Map<String, Method> getBeanPropertyReadMethods(Class cl) {
-        Map<String, Method> properties = new HashMap<String, Method>();
+        Map<String, Method> properties = new HashMap<>();
         for (; cl != null; cl = cl.getSuperclass()) {
             Method[] methods = cl.getDeclaredMethods();
             for (Method method : methods) {
diff --git 
a/dubbo-common/src/main/java/org/apache/dubbo/rpc/model/ApplicationModel.java 
b/dubbo-common/src/main/java/org/apache/dubbo/rpc/model/ApplicationModel.java
index c0f1e3cf10..0978143257 100644
--- 
a/dubbo-common/src/main/java/org/apache/dubbo/rpc/model/ApplicationModel.java
+++ 
b/dubbo-common/src/main/java/org/apache/dubbo/rpc/model/ApplicationModel.java
@@ -43,7 +43,7 @@ import java.util.concurrent.locks.Lock;
  * returned from them are of process scope. If you want to support multiple 
dubbo servers in one
  * single process, you may need to refactor those three classes.
  * <p>
- * Represent a application which is using Dubbo and store basic metadata info 
for using
+ * Represent an application which is using Dubbo and store basic metadata info 
for using
  * during the processing of RPC invoking.
  * <p>
  * ApplicationModel includes many ProviderModel which is about published 
services
diff --git 
a/dubbo-common/src/test/java/org/apache/dubbo/common/compiler/support/ClassUtilsTest.java
 
b/dubbo-common/src/test/java/org/apache/dubbo/common/compiler/support/ClassUtilsTest.java
index e2d990caf9..0e7c6b7a73 100644
--- 
a/dubbo-common/src/test/java/org/apache/dubbo/common/compiler/support/ClassUtilsTest.java
+++ 
b/dubbo-common/src/test/java/org/apache/dubbo/common/compiler/support/ClassUtilsTest.java
@@ -60,22 +60,22 @@ class ClassUtilsTest {
 
     @Test
     void testForName2() {
-        ClassUtils.forName("boolean");
-        ClassUtils.forName("byte");
-        ClassUtils.forName("char");
-        ClassUtils.forName("short");
-        ClassUtils.forName("int");
-        ClassUtils.forName("long");
-        ClassUtils.forName("float");
-        ClassUtils.forName("double");
-        ClassUtils.forName("boolean[]");
-        ClassUtils.forName("byte[]");
-        ClassUtils.forName("char[]");
-        ClassUtils.forName("short[]");
-        ClassUtils.forName("int[]");
-        ClassUtils.forName("long[]");
-        ClassUtils.forName("float[]");
-        ClassUtils.forName("double[]");
+        Assertions.assertEquals(boolean.class, ClassUtils.forName("boolean"));
+        Assertions.assertEquals(byte.class, ClassUtils.forName("byte"));
+        Assertions.assertEquals(char.class, ClassUtils.forName("char"));
+        Assertions.assertEquals(short.class, ClassUtils.forName("short"));
+        Assertions.assertEquals(int.class, ClassUtils.forName("int"));
+        Assertions.assertEquals(long.class, ClassUtils.forName("long"));
+        Assertions.assertEquals(float.class, ClassUtils.forName("float"));
+        Assertions.assertEquals(double.class, ClassUtils.forName("double"));
+        Assertions.assertEquals(boolean[].class, 
ClassUtils.forName("boolean[]"));
+        Assertions.assertEquals(byte[].class, ClassUtils.forName("byte[]"));
+        Assertions.assertEquals(char[].class, ClassUtils.forName("char[]"));
+        Assertions.assertEquals(short[].class, ClassUtils.forName("short[]"));
+        Assertions.assertEquals(int[].class, ClassUtils.forName("int[]"));
+        Assertions.assertEquals(long[].class, ClassUtils.forName("long[]"));
+        Assertions.assertEquals(float[].class, ClassUtils.forName("float[]"));
+        Assertions.assertEquals(double[].class, 
ClassUtils.forName("double[]"));
     }
 
     @Test
@@ -174,4 +174,4 @@ class ClassUtilsTest {
         }
     }
 
-}
\ No newline at end of file
+}
diff --git 
a/dubbo-common/src/test/java/org/apache/dubbo/common/config/EnvironmentTest.java
 
b/dubbo-common/src/test/java/org/apache/dubbo/common/config/EnvironmentTest.java
index 75c88306fc..5d502fffaa 100644
--- 
a/dubbo-common/src/test/java/org/apache/dubbo/common/config/EnvironmentTest.java
+++ 
b/dubbo-common/src/test/java/org/apache/dubbo/common/config/EnvironmentTest.java
@@ -77,11 +77,11 @@ class EnvironmentTest {
 
         // test getConfigurationMaps(AbstractConfig config, String prefix)
         List<Map<String, String>> configurationMaps = 
environment.getConfigurationMaps(registryConfig, prefix);
-        Assertions.assertEquals(configurationMaps.size(), 7);
+        Assertions.assertEquals(7, configurationMaps.size());
 
         // test getConfigurationMaps()
         configurationMaps = environment.getConfigurationMaps();
-        Assertions.assertEquals(configurationMaps.size(), 6);
+        Assertions.assertEquals(6, configurationMaps.size());
 
         CompositeConfiguration configuration1 = environment.getConfiguration();
         CompositeConfiguration configuration2 = environment.getConfiguration();
diff --git 
a/dubbo-common/src/test/java/org/apache/dubbo/common/config/configcenter/DynamicConfigurationFactoryTest.java
 
b/dubbo-common/src/test/java/org/apache/dubbo/common/config/configcenter/DynamicConfigurationFactoryTest.java
index f52b79e328..c5ef627379 100644
--- 
a/dubbo-common/src/test/java/org/apache/dubbo/common/config/configcenter/DynamicConfigurationFactoryTest.java
+++ 
b/dubbo-common/src/test/java/org/apache/dubbo/common/config/configcenter/DynamicConfigurationFactoryTest.java
@@ -17,10 +17,11 @@
 package org.apache.dubbo.common.config.configcenter;
 
 import 
org.apache.dubbo.common.config.configcenter.nop.NopDynamicConfigurationFactory;
+import org.apache.dubbo.common.extension.ExtensionLoader;
+import org.apache.dubbo.rpc.model.ApplicationModel;
 
 import org.junit.jupiter.api.Test;
 
-import static 
org.apache.dubbo.common.extension.ExtensionLoader.getExtensionLoader;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 
 /**
@@ -36,4 +37,8 @@ class DynamicConfigurationFactoryTest {
         assertEquals(NopDynamicConfigurationFactory.class, factory.getClass());
         assertEquals(NopDynamicConfigurationFactory.class, 
getExtensionLoader(DynamicConfigurationFactory.class).getExtension("nop").getClass());
     }
-}
\ No newline at end of file
+
+    private <T> ExtensionLoader<T> getExtensionLoader(Class<T> extClass) {
+        return 
ApplicationModel.defaultModel().getDefaultModule().getExtensionLoader(extClass);
+    }
+}
diff --git 
a/dubbo-common/src/test/java/org/apache/dubbo/common/convert/ConverterTest.java 
b/dubbo-common/src/test/java/org/apache/dubbo/common/convert/ConverterTest.java
index 2deaf7ebb6..3a1407c2d6 100644
--- 
a/dubbo-common/src/test/java/org/apache/dubbo/common/convert/ConverterTest.java
+++ 
b/dubbo-common/src/test/java/org/apache/dubbo/common/convert/ConverterTest.java
@@ -16,13 +16,14 @@
  */
 package org.apache.dubbo.common.convert;
 
+import org.apache.dubbo.common.extension.ExtensionLoader;
+import org.apache.dubbo.rpc.model.ApplicationModel;
 import org.apache.dubbo.rpc.model.FrameworkModel;
 
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
-import static 
org.apache.dubbo.common.extension.ExtensionLoader.getExtensionLoader;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertSame;
 
@@ -60,4 +61,8 @@ class ConverterTest {
         assertEquals(Boolean.FALSE, converterUtil.convertIfPossible("false", 
Boolean.class));
         assertEquals(Double.valueOf(1), converterUtil.convertIfPossible("1", 
Double.class));
     }
-}
\ No newline at end of file
+
+    private <T> ExtensionLoader<T> getExtensionLoader(Class<T> extClass) {
+        return 
ApplicationModel.defaultModel().getDefaultModule().getExtensionLoader(extClass);
+    }
+}
diff --git 
a/dubbo-common/src/test/java/org/apache/dubbo/common/convert/StringToLongConverterTest.java
 
b/dubbo-common/src/test/java/org/apache/dubbo/common/convert/StringToLongConverterTest.java
index cda878d1c5..ad98ed4a95 100644
--- 
a/dubbo-common/src/test/java/org/apache/dubbo/common/convert/StringToLongConverterTest.java
+++ 
b/dubbo-common/src/test/java/org/apache/dubbo/common/convert/StringToLongConverterTest.java
@@ -16,10 +16,12 @@
  */
 package org.apache.dubbo.common.convert;
 
+import org.apache.dubbo.common.extension.ExtensionLoader;
+import org.apache.dubbo.rpc.model.ApplicationModel;
+
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
-import static 
org.apache.dubbo.common.extension.ExtensionLoader.getExtensionLoader;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertNull;
 import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -52,4 +54,8 @@ class StringToLongConverterTest {
             converter.convert("ttt");
         });
     }
-}
\ No newline at end of file
+
+    private <T> ExtensionLoader<T> getExtensionLoader(Class<T> extClass) {
+        return 
ApplicationModel.defaultModel().getDefaultModule().getExtensionLoader(extClass);
+    }
+}
diff --git 
a/dubbo-common/src/test/java/org/apache/dubbo/common/extension/ExtensionLoaderTest.java
 
b/dubbo-common/src/test/java/org/apache/dubbo/common/extension/ExtensionLoaderTest.java
index 9913fbd966..4f8f1474f1 100644
--- 
a/dubbo-common/src/test/java/org/apache/dubbo/common/extension/ExtensionLoaderTest.java
+++ 
b/dubbo-common/src/test/java/org/apache/dubbo/common/extension/ExtensionLoaderTest.java
@@ -170,7 +170,7 @@ class ExtensionLoaderTest {
         // get origin instance from wrapper
         WrappedExt originImpl1 = impl1;
         while (originImpl1 instanceof WrappedExtWrapper) {
-            originImpl1 = ((WrappedExtWrapper)originImpl1).getOrigin();
+            originImpl1 = ((WrappedExtWrapper) originImpl1).getOrigin();
         }
 
         // test unwrapped instance
@@ -292,7 +292,7 @@ class ExtensionLoaderTest {
     void test_getSupportedExtensions() {
         Set<String> exts = 
getExtensionLoader(SimpleExt.class).getSupportedExtensions();
 
-        Set<String> expected = new HashSet<String>();
+        Set<String> expected = new HashSet<>();
         expected.add("impl1");
         expected.add("impl2");
         expected.add("impl3");
@@ -304,7 +304,7 @@ class ExtensionLoaderTest {
     void test_getSupportedExtensions_wrapperIsNotExt() {
         Set<String> exts = 
getExtensionLoader(WrappedExt.class).getSupportedExtensions();
 
-        Set<String> expected = new HashSet<String>();
+        Set<String> expected = new HashSet<>();
         expected.add("impl1");
         expected.add("impl2");
         expected.add("impl3");
@@ -728,7 +728,7 @@ class ExtensionLoaderTest {
         } catch (IllegalStateException expected) {
             assertThat(expected.getMessage(), containsString("Failed to load 
extension class (interface: interface 
org.apache.dubbo.common.extension.duplicated.DuplicatedWithoutOverriddenExt"));
             assertThat(expected.getMessage(), containsString("cause: Duplicate 
extension 
org.apache.dubbo.common.extension.duplicated.DuplicatedWithoutOverriddenExt 
name duplicated"));
-        }finally {
+        } finally {
             //recover the loading strategies
             ExtensionLoader.setLoadingStrategies(loadingStrategies.toArray(new 
LoadingStrategy[loadingStrategies.size()]));
         }
@@ -749,25 +749,25 @@ class ExtensionLoaderTest {
     @Test
     void testLoadByDubboInternalSPI() {
         ExtensionLoader<SPI1> extensionLoader = getExtensionLoader(SPI1.class);
-        SPI1 spi1 = extensionLoader.getExtension("1",true);
+        SPI1 spi1 = extensionLoader.getExtension("1", true);
         assertNotNull(spi1);
 
         ExtensionLoader<SPI2> extensionLoader2 = 
getExtensionLoader(SPI2.class);
-        SPI2 spi2 = extensionLoader2.getExtension("2",true);
+        SPI2 spi2 = extensionLoader2.getExtension("2", true);
         assertNotNull(spi2);
 
         try {
             ExtensionLoader<SPI3> extensionLoader3 = 
getExtensionLoader(SPI3.class);
-            SPI3 spi3 = extensionLoader3.getExtension("3",true);
+            SPI3 spi3 = extensionLoader3.getExtension("3", true);
             assertNotNull(spi3);
-        }catch (IllegalStateException illegalStateException){
+        } catch (IllegalStateException illegalStateException) {
             if (!illegalStateException.getMessage().contains("No such 
extension")) {
                 fail();
             }
         }
 
         ExtensionLoader<SPI4> extensionLoader4 = 
getExtensionLoader(SPI4.class);
-        SPI4 spi4 = extensionLoader4.getExtension("4",true);
+        SPI4 spi4 = extensionLoader4.getExtension("4", true);
         assertNotNull(spi4);
 
     }
@@ -780,7 +780,7 @@ class ExtensionLoaderTest {
     }
 
     /**
-     * The external {@link LoadingStrategy}, which can set if it support 
overridden
+     * The external {@link LoadingStrategy}, which can set if it supports 
overriding.
      */
     private static class DubboExternalLoadingStrategyTest implements 
LoadingStrategy {
 
diff --git 
a/dubbo-common/src/test/java/org/apache/dubbo/common/extension/ExtensionLoader_Compatible_Test.java
 
b/dubbo-common/src/test/java/org/apache/dubbo/common/extension/ExtensionLoader_Compatible_Test.java
index 967215037f..83596edb95 100644
--- 
a/dubbo-common/src/test/java/org/apache/dubbo/common/extension/ExtensionLoader_Compatible_Test.java
+++ 
b/dubbo-common/src/test/java/org/apache/dubbo/common/extension/ExtensionLoader_Compatible_Test.java
@@ -19,6 +19,8 @@ package org.apache.dubbo.common.extension;
 import org.apache.dubbo.common.extension.compatible.CompatibleExt;
 import org.apache.dubbo.common.extension.compatible.impl.CompatibleExtImpl1;
 import org.apache.dubbo.common.extension.compatible.impl.CompatibleExtImpl2;
+import org.apache.dubbo.rpc.model.ApplicationModel;
+import org.apache.dubbo.rpc.model.ModuleModel;
 
 import org.junit.jupiter.api.Test;
 
@@ -27,8 +29,11 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
 class ExtensionLoader_Compatible_Test {
 
     @Test
-    void test_getExtension() throws Exception {
-        
assertTrue(ExtensionLoader.getExtensionLoader(CompatibleExt.class).getExtension("impl1")
 instanceof CompatibleExtImpl1);
-        
assertTrue(ExtensionLoader.getExtensionLoader(CompatibleExt.class).getExtension("impl2")
 instanceof CompatibleExtImpl2);
+    void test_getExtension() {
+
+        ModuleModel moduleModel = 
ApplicationModel.defaultModel().getDefaultModule();
+
+        
assertTrue(moduleModel.getExtensionLoader(CompatibleExt.class).getExtension("impl1")
 instanceof CompatibleExtImpl1);
+        
assertTrue(moduleModel.getExtensionLoader(CompatibleExt.class).getExtension("impl2")
 instanceof CompatibleExtImpl2);
     }
-}
\ No newline at end of file
+}
diff --git 
a/dubbo-common/src/test/java/org/apache/dubbo/common/threadlocal/NamedInternalThreadFactoryTest.java
 
b/dubbo-common/src/test/java/org/apache/dubbo/common/threadlocal/NamedInternalThreadFactoryTest.java
index 92cd977a3b..3d0e34cacc 100644
--- 
a/dubbo-common/src/test/java/org/apache/dubbo/common/threadlocal/NamedInternalThreadFactoryTest.java
+++ 
b/dubbo-common/src/test/java/org/apache/dubbo/common/threadlocal/NamedInternalThreadFactoryTest.java
@@ -25,12 +25,8 @@ class NamedInternalThreadFactoryTest {
     @Test
     void newThread() throws Exception {
         NamedInternalThreadFactory namedInternalThreadFactory = new 
NamedInternalThreadFactory();
-        Thread t = namedInternalThreadFactory.newThread(new Runnable() {
-            @Override
-            public void run() {
+        Thread t = namedInternalThreadFactory.newThread(() -> { });
 
-            }
-        });
         Assertions.assertEquals(t.getClass(), InternalThread.class, "thread is 
not InternalThread");
     }
-}
\ No newline at end of file
+}
diff --git 
a/dubbo-common/src/test/java/org/apache/dubbo/common/threadpool/support/eager/EagerThreadPoolExecutorTest.java
 
b/dubbo-common/src/test/java/org/apache/dubbo/common/threadpool/support/eager/EagerThreadPoolExecutorTest.java
index 68b3735ff7..03e90eddc1 100644
--- 
a/dubbo-common/src/test/java/org/apache/dubbo/common/threadpool/support/eager/EagerThreadPoolExecutorTest.java
+++ 
b/dubbo-common/src/test/java/org/apache/dubbo/common/threadpool/support/eager/EagerThreadPoolExecutorTest.java
@@ -22,6 +22,7 @@ import org.apache.dubbo.common.threadpool.ThreadPool;
 import org.apache.dubbo.common.threadpool.support.AbortPolicyWithReport;
 import org.apache.dubbo.common.url.component.ServiceConfigURL;
 import org.apache.dubbo.common.utils.NamedThreadFactory;
+import org.apache.dubbo.rpc.model.ApplicationModel;
 
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.Disabled;
@@ -110,7 +111,7 @@ class EagerThreadPoolExecutorTest {
         long alive = 1000;
 
         //init queue and executor
-        TaskQueue<Runnable> taskQueue = new TaskQueue<Runnable>(queues);
+        TaskQueue<Runnable> taskQueue = new TaskQueue<>(queues);
         final EagerThreadPoolExecutor executor = new 
EagerThreadPoolExecutor(cores,
             threads,
             alive,
@@ -163,9 +164,12 @@ class EagerThreadPoolExecutorTest {
 
     @Test
     void testSPI() {
-        ExecutorService executorService = (ExecutorService) 
ExtensionLoader.getExtensionLoader(ThreadPool.class)
+        ExtensionLoader<ThreadPool> extensionLoader = 
ApplicationModel.defaultModel().getDefaultModule().getExtensionLoader(ThreadPool.class);
+
+        ExecutorService executorService = (ExecutorService) extensionLoader
             .getExtension("eager")
             .getExecutor(URL);
+
         Assertions.assertEquals("EagerThreadPoolExecutor", 
executorService.getClass()
             .getSimpleName(), "test spi fail!");
     }
diff --git 
a/dubbo-common/src/test/java/org/apache/dubbo/common/utils/JRETest.java 
b/dubbo-common/src/test/java/org/apache/dubbo/common/utils/JRETest.java
index 6250e75964..ec5f34b1c0 100644
--- a/dubbo-common/src/test/java/org/apache/dubbo/common/utils/JRETest.java
+++ b/dubbo-common/src/test/java/org/apache/dubbo/common/utils/JRETest.java
@@ -21,6 +21,8 @@ import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.Disabled;
 import org.junit.jupiter.api.Test;
 
+import javax.lang.model.SourceVersion;
+
 
 class JRETest {
 
@@ -33,17 +35,10 @@ class JRETest {
     }
 
     @Test
-    @Disabled
-    void java8Version() {
-        JRE jre = JRE.currentVersion();
-        Assertions.assertEquals(JRE.JAVA_8, jre);
-    }
+    void testCurrentVersion() {
+        // SourceVersion is an enum, which member name is RELEASE_XX.
 
-    @Test
-    @Disabled
-    void java19Version() {
-        JRE jre = JRE.currentVersion();
-        Assertions.assertNotEquals(JRE.JAVA_19, jre);
+        Assertions.assertEquals(SourceVersion.latest().name().split("_")[1],
+            JRE.currentVersion().name().split("_")[1]);
     }
-
 }
diff --git 
a/dubbo-common/src/test/java/org/apache/dubbo/common/utils/JsonUtilsTest.java 
b/dubbo-common/src/test/java/org/apache/dubbo/common/utils/JsonUtilsTest.java
index 0a2fd7216e..d237685eb2 100644
--- 
a/dubbo-common/src/test/java/org/apache/dubbo/common/utils/JsonUtilsTest.java
+++ 
b/dubbo-common/src/test/java/org/apache/dubbo/common/utils/JsonUtilsTest.java
@@ -110,7 +110,7 @@ class JsonUtilsTest {
     }
 
     @Test
-    public void consistentTest() {
+    void consistentTest() {
         List<Object> objs = new LinkedList<>();
 
         {
diff --git 
a/dubbo-common/src/test/java/org/apache/dubbo/common/utils/ReflectUtilsTest.java
 
b/dubbo-common/src/test/java/org/apache/dubbo/common/utils/ReflectUtilsTest.java
index 15257f253d..2da5fabfb1 100644
--- 
a/dubbo-common/src/test/java/org/apache/dubbo/common/utils/ReflectUtilsTest.java
+++ 
b/dubbo-common/src/test/java/org/apache/dubbo/common/utils/ReflectUtilsTest.java
@@ -14,6 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 package org.apache.dubbo.common.utils;
 
 import org.junit.jupiter.api.Assertions;
@@ -77,7 +78,7 @@ class ReflectUtilsTest {
     }
 
     @Test
-    void testIsCompatible() throws Exception {
+    void testIsCompatible() {
         assertTrue(ReflectUtils.isCompatible(short.class, (short) 1));
         assertTrue(ReflectUtils.isCompatible(int.class, 1));
         assertTrue(ReflectUtils.isCompatible(double.class, 1.2));
@@ -86,36 +87,45 @@ class ReflectUtilsTest {
     }
 
     @Test
-    void testIsCompatibleWithArray() throws Exception {
+    void testIsCompatibleWithArray() {
         assertFalse(ReflectUtils.isCompatible(new Class[]{short.class, 
int.class}, new Object[]{(short) 1}));
         assertFalse(ReflectUtils.isCompatible(new Class[]{double.class}, new 
Object[]{"hello"}));
         assertTrue(ReflectUtils.isCompatible(new Class[]{double.class}, new 
Object[]{1.2}));
     }
 
     @Test
-    void testGetCodeBase() throws Exception {
+    void testGetCodeBase() {
         assertNull(ReflectUtils.getCodeBase(null));
         assertNull(ReflectUtils.getCodeBase(String.class));
         assertNotNull(ReflectUtils.getCodeBase(ReflectUtils.class));
     }
 
     @Test
-    void testGetName() throws Exception {
+    void testGetName() {
         // getName
         assertEquals("boolean", ReflectUtils.getName(boolean.class));
         assertEquals("int[][][]", ReflectUtils.getName(int[][][].class));
         assertEquals("java.lang.Object[][]", 
ReflectUtils.getName(Object[][].class));
+    }
 
+    @Test
+    void testGetDesc() {
         // getDesc
         assertEquals("Z", ReflectUtils.getDesc(boolean.class));
         assertEquals("[[[I", ReflectUtils.getDesc(int[][][].class));
         assertEquals("[[Ljava/lang/Object;", 
ReflectUtils.getDesc(Object[][].class));
+    }
 
+    @Test
+    void testName2desc() {
         // name2desc
         assertEquals("Z", 
ReflectUtils.name2desc(ReflectUtils.getName(boolean.class)));
         assertEquals("[[[I", 
ReflectUtils.name2desc(ReflectUtils.getName(int[][][].class)));
         assertEquals("[[Ljava/lang/Object;", 
ReflectUtils.name2desc(ReflectUtils.getName(Object[][].class)));
+    }
 
+    @Test
+    void testDesc2name() {
         // desc2name
         assertEquals("short[]", 
ReflectUtils.desc2name(ReflectUtils.getDesc(short[].class)));
         assertEquals("boolean[]", 
ReflectUtils.desc2name(ReflectUtils.getDesc(boolean[].class)));
@@ -131,12 +141,12 @@ class ReflectUtilsTest {
     }
 
     @Test
-    void testGetGenericClass() throws Exception {
+    void testGetGenericClass() {
         assertThat(ReflectUtils.getGenericClass(Foo1.class), 
sameInstance(String.class));
     }
 
     @Test
-    void testGetGenericClassWithIndex() throws Exception {
+    void testGetGenericClassWithIndex() {
         assertThat(ReflectUtils.getGenericClass(Foo1.class, 0), 
sameInstance(String.class));
         assertThat(ReflectUtils.getGenericClass(Foo1.class, 1), 
sameInstance(Integer.class));
         assertThat(ReflectUtils.getGenericClass(Foo2.class, 0), 
sameInstance(List.class));
@@ -148,7 +158,7 @@ class ReflectUtilsTest {
     @Test
     void testGetMethodName() throws Exception {
         assertThat(ReflectUtils.getName(Foo2.class.getDeclaredMethod("hello", 
int[].class)),
-                equalTo("java.util.List hello(int[])"));
+            equalTo("java.util.List hello(int[])"));
     }
 
     @Test
@@ -158,7 +168,7 @@ class ReflectUtilsTest {
     }
 
     @Test
-    void testGetConstructorName() throws Exception {
+    void testGetConstructorName() {
         Constructor c = Foo2.class.getConstructors()[0];
         assertThat(ReflectUtils.getName(c), equalTo("(java.util.List,int[])"));
     }
@@ -174,18 +184,18 @@ class ReflectUtilsTest {
     @Test
     void testGetDescMethod() throws Exception {
         assertThat(ReflectUtils.getDesc(Foo2.class.getDeclaredMethod("hello", 
int[].class)),
-                equalTo("hello([I)Ljava/util/List;"));
+            equalTo("hello([I)Ljava/util/List;"));
     }
 
     @Test
-    void testGetDescConstructor() throws Exception {
+    void testGetDescConstructor() {
         assertThat(ReflectUtils.getDesc(Foo2.class.getConstructors()[0]), 
equalTo("(Ljava/util/List;[I)V"));
     }
 
     @Test
     void testGetDescWithoutMethodName() throws Exception {
         
assertThat(ReflectUtils.getDescWithoutMethodName(Foo2.class.getDeclaredMethod("hello",
 int[].class)),
-                equalTo("([I)Ljava/util/List;"));
+            equalTo("([I)Ljava/util/List;"));
     }
 
     @Test
@@ -208,7 +218,7 @@ class ReflectUtilsTest {
     }
 
     @Test
-    void testIsInstance() throws Exception {
+    void testIsInstance() {
         assertTrue(ReflectUtils.isInstance(new Foo1(), Foo.class.getName()));
     }
 
@@ -227,9 +237,9 @@ class ReflectUtilsTest {
     @Test
     void testGetPropertyNameFromBeanReadMethod() throws Exception {
         Method method = EmptyClass.class.getMethod("getProperty");
-        assertEquals(ReflectUtils.getPropertyNameFromBeanReadMethod(method), 
"property");
+        assertEquals("property", 
ReflectUtils.getPropertyNameFromBeanReadMethod(method));
         method = EmptyClass.class.getMethod("isSet");
-        assertEquals(ReflectUtils.getPropertyNameFromBeanReadMethod(method), 
"set");
+        assertEquals("set", 
ReflectUtils.getPropertyNameFromBeanReadMethod(method));
     }
 
     @Test
@@ -243,7 +253,7 @@ class ReflectUtilsTest {
     @Test
     void testGetPropertyNameFromBeanWriteMethod() throws Exception {
         Method method = EmptyClass.class.getMethod("setProperty", 
EmptyProperty.class);
-        assertEquals(ReflectUtils.getPropertyNameFromBeanWriteMethod(method), 
"property");
+        assertEquals("property", 
ReflectUtils.getPropertyNameFromBeanWriteMethod(method));
     }
 
     @Test
@@ -255,7 +265,7 @@ class ReflectUtilsTest {
     }
 
     @Test
-    void testGetBeanPropertyFields() throws Exception {
+    void testGetBeanPropertyFields() {
         Map<String, Field> map = 
ReflectUtils.getBeanPropertyFields(EmptyClass.class);
         assertThat(map.size(), is(2));
         assertThat(map, hasKey("set"));
@@ -268,7 +278,7 @@ class ReflectUtilsTest {
     }
 
     @Test
-    void testGetBeanPropertyReadMethods() throws Exception {
+    void testGetBeanPropertyReadMethods() {
         Map<String, Method> map = 
ReflectUtils.getBeanPropertyReadMethods(EmptyClass.class);
         assertThat(map.size(), is(2));
         assertThat(map, hasKey("set"));
@@ -332,7 +342,7 @@ class ReflectUtilsTest {
     void testFindMethodByMethodSignature_override() throws Exception {
         {
             Method m = 
ReflectUtils.findMethodByMethodSignature(TestedClass.class,
-                    "overrideMethod", new String[]{"int"});
+                "overrideMethod", new String[]{"int"});
 
             assertEquals("overrideMethod", m.getName());
             Class<?>[] parameterTypes = m.getParameterTypes();
@@ -341,7 +351,7 @@ class ReflectUtilsTest {
         }
         {
             Method m = 
ReflectUtils.findMethodByMethodSignature(TestedClass.class,
-                    "overrideMethod", new String[]{"java.lang.Integer"});
+                "overrideMethod", new String[]{"java.lang.Integer"});
 
             assertEquals("overrideMethod", m.getName());
             Class<?>[] parameterTypes = m.getParameterTypes();
@@ -363,7 +373,7 @@ class ReflectUtilsTest {
     @Test
     void testFindMethodByMethodSignatureNotFound() throws Exception {
         try {
-            ReflectUtils.findMethodByMethodSignature(TestedClass.class, 
"notExsited", null);
+            ReflectUtils.findMethodByMethodSignature(TestedClass.class, 
"doesNotExist", null);
             fail();
         } catch (NoSuchMethodException expected) {
             assertThat(expected.getMessage(), containsString("No such method 
"));
@@ -372,28 +382,30 @@ class ReflectUtilsTest {
     }
 
     @Test
-    void testGetEmptyObject() throws Exception {
+    void testGetEmptyObject() {
         assertTrue(ReflectUtils.getEmptyObject(Collection.class) instanceof 
Collection);
         assertTrue(ReflectUtils.getEmptyObject(List.class) instanceof List);
         assertTrue(ReflectUtils.getEmptyObject(Set.class) instanceof Set);
         assertTrue(ReflectUtils.getEmptyObject(Map.class) instanceof Map);
         assertTrue(ReflectUtils.getEmptyObject(Object[].class) instanceof 
Object[]);
-        assertEquals(ReflectUtils.getEmptyObject(String.class), "");
-        assertEquals(ReflectUtils.getEmptyObject(short.class), (short) 0);
-        assertEquals(ReflectUtils.getEmptyObject(byte.class), (byte) 0);
-        assertEquals(ReflectUtils.getEmptyObject(int.class), 0);
-        assertEquals(ReflectUtils.getEmptyObject(long.class), 0L);
-        assertEquals(ReflectUtils.getEmptyObject(float.class), (float) 0);
-        assertEquals(ReflectUtils.getEmptyObject(double.class), (double) 0);
-        assertEquals(ReflectUtils.getEmptyObject(char.class), '\0');
-        assertEquals(ReflectUtils.getEmptyObject(boolean.class), 
Boolean.FALSE);
+
+        assertEquals("", ReflectUtils.getEmptyObject(String.class));
+        assertEquals((short) 0, ReflectUtils.getEmptyObject(short.class));
+        assertEquals((byte) 0, ReflectUtils.getEmptyObject(byte.class));
+        assertEquals(0, ReflectUtils.getEmptyObject(int.class));
+        assertEquals(0L, ReflectUtils.getEmptyObject(long.class));
+        assertEquals((float) 0, ReflectUtils.getEmptyObject(float.class));
+        assertEquals((double) 0, ReflectUtils.getEmptyObject(double.class));
+        assertEquals('\0', ReflectUtils.getEmptyObject(char.class));
+        assertEquals(Boolean.FALSE, 
ReflectUtils.getEmptyObject(boolean.class));
+
         EmptyClass object = (EmptyClass) 
ReflectUtils.getEmptyObject(EmptyClass.class);
         assertNotNull(object);
         assertNotNull(object.getProperty());
     }
 
     @Test
-    void testForName1() throws Exception {
+    void testForName1() {
         assertThat(ReflectUtils.forName(ReflectUtils.class.getName()), 
sameInstance(ReflectUtils.class));
     }
 
@@ -405,8 +417,8 @@ class ReflectUtilsTest {
     }
 
     @Test
-    void testGetReturnTypes () throws Exception{
-        Class clazz = TypeClass.class;
+    void testGetReturnTypes() throws Exception {
+        Class<TypeClass> clazz = TypeClass.class;
 
         Type[] types = 
ReflectUtils.getReturnTypes(clazz.getMethod("getFuture"));
         Assertions.assertEquals("java.lang.String", types[0].getTypeName());
@@ -542,6 +554,4 @@ class ReflectUtilsTest {
             return null;
         }
     }
-
-
 }
diff --git 
a/dubbo-common/src/test/java/org/apache/dubbo/config/context/ConfigManagerTest.java
 
b/dubbo-common/src/test/java/org/apache/dubbo/config/context/ConfigManagerTest.java
index 95f3e2679e..5ddd74aad4 100644
--- 
a/dubbo-common/src/test/java/org/apache/dubbo/config/context/ConfigManagerTest.java
+++ 
b/dubbo-common/src/test/java/org/apache/dubbo/config/context/ConfigManagerTest.java
@@ -329,6 +329,7 @@ class ConfigManagerTest {
             
applicationConfig22.setParameters(CollectionUtils.toStringMap("k1", "v11", 
"k2", "v22", "k3", "v3"));
             configManager.addConfig(applicationConfig11);
             configManager.addConfig(applicationConfig22);
+
             assertEquals(applicationConfig11, 
configManager.getApplicationOrElseThrow());
             assertEquals(applicationConfig11.getName(), "app22");
             assertEquals(applicationConfig11.getParameters(), 
CollectionUtils.toStringMap("k1", "v11", "k2", "v22", "k3", "v3"));
@@ -345,9 +346,10 @@ class ConfigManagerTest {
             
applicationConfig44.setParameters(CollectionUtils.toStringMap("k1", "v11", 
"k2", "v22", "k3", "v3"));
             configManager.addConfig(applicationConfig33);
             configManager.addConfig(applicationConfig44);
+
             assertEquals(applicationConfig33, 
configManager.getApplicationOrElseThrow());
-            assertEquals(applicationConfig33.getName(), "app33");
-            assertEquals(applicationConfig33.getParameters(), 
CollectionUtils.toStringMap("k1", "v1", "k2", "v2", "k3", "v3"));
+            assertEquals("app33", applicationConfig33.getName());
+            assertEquals(CollectionUtils.toStringMap("k1", "v1", "k2", "v2", 
"k3", "v3"), applicationConfig33.getParameters());
         } finally {
             System.clearProperty(DUBBO_CONFIG_MODE);
         }
@@ -359,12 +361,22 @@ class ConfigManagerTest {
         registryConfig.setId("registryID_1");
         configManager.addRegistry(registryConfig);
         Optional<RegistryConfig> registryConfigOptional = 
configManager.getConfig(RegistryConfig.class, registryConfig.getId());
-        Assertions.assertEquals(registryConfigOptional.get(), registryConfig);
+
+        if (registryConfigOptional.isPresent()) {
+            Assertions.assertEquals(registryConfigOptional.get(), 
registryConfig);
+        } else {
+            fail("registryConfigOptional is empty! ");
+        }
 
         ProtocolConfig protocolConfig = new ProtocolConfig("dubbo");
         configManager.addProtocol(protocolConfig);
         Optional<ProtocolConfig> protocolConfigOptional = 
configManager.getConfig(ProtocolConfig.class, protocolConfig.getName());
-        Assertions.assertEquals(protocolConfigOptional.get(), protocolConfig);
+
+        if (protocolConfigOptional.isPresent()) {
+            Assertions.assertEquals(protocolConfigOptional.get(), 
protocolConfig);
+        } else {
+            fail("protocolConfigOptional is empty! ");
+        }
 
         // test multi config has same name(dubbo)
         ProtocolConfig protocolConfig2 = new ProtocolConfig("dubbo");
@@ -384,7 +396,7 @@ class ConfigManagerTest {
         moduleConfig.setId("moduleID_1");
         moduleConfigManager.setModule(moduleConfig);
         Optional<ModuleConfig> moduleConfigOptional = 
moduleConfigManager.getConfig(ModuleConfig.class, moduleConfig.getId());
-        Assertions.assertEquals(moduleConfigOptional.get(), moduleConfig);
+        Assertions.assertEquals(moduleConfig, moduleConfigOptional.get());
 
         Optional<RegistryConfig> config = 
moduleConfigManager.getConfig(RegistryConfig.class, registryConfig.getId());
         Assertions.assertEquals(config.get(), registryConfig);
@@ -405,7 +417,7 @@ class ConfigManagerTest {
             System.setProperty("dubbo.protocols.rest2.port", "8081");
             configManager.loadConfigsOfTypeFromProps(ProtocolConfig.class);
             Collection<ProtocolConfig> protocols = 
configManager.getProtocols();
-            Assertions.assertEquals(protocols.size(), 4);
+            Assertions.assertEquals(4, protocols.size());
 
             System.setProperty("dubbo.applications.app1.name", "app-demo1");
             System.setProperty("dubbo.applications.app2.name", "app-demo2");
diff --git 
a/dubbo-common/src/test/java/org/apache/dubbo/rpc/model/ModuleServiceRepositoryTest.java
 
b/dubbo-common/src/test/java/org/apache/dubbo/rpc/model/ModuleServiceRepositoryTest.java
index 04d1f4eac2..b78e6cbe82 100644
--- 
a/dubbo-common/src/test/java/org/apache/dubbo/rpc/model/ModuleServiceRepositoryTest.java
+++ 
b/dubbo-common/src/test/java/org/apache/dubbo/rpc/model/ModuleServiceRepositoryTest.java
@@ -62,7 +62,7 @@ class ModuleServiceRepositoryTest {
         Assertions.assertEquals(lookupServiceResult, serviceDescriptor);
 
         List<ServiceDescriptor> allServices = repository.getAllServices();
-        Assertions.assertEquals(allServices.size(), 1);
+        Assertions.assertEquals(1, allServices.size());
         Assertions.assertEquals(allServices.get(0), serviceDescriptor);
 
         ServiceDescriptor serviceDescriptor1 = 
repository.registerService(DemoService.class.getSimpleName(), 
DemoService.class);
@@ -76,14 +76,14 @@ class ModuleServiceRepositoryTest {
         repository.registerConsumer(consumerModel);
 
         List<ConsumerModel> allReferredServices = 
repository.getReferredServices();
-        Assertions.assertEquals(allReferredServices.size(), 1);
+        Assertions.assertEquals(1, allReferredServices.size());
         Assertions.assertEquals(allReferredServices.get(0), consumerModel);
 
         List<ConsumerModel> referredServices = 
repository.lookupReferredServices(DemoService.class.getName());
-        Assertions.assertEquals(referredServices.size(), 1);
+        Assertions.assertEquals(1, referredServices.size());
         Assertions.assertEquals(referredServices.get(0), consumerModel);
 
-        ConsumerModel referredService = 
repository.lookupReferredService(DemoService.class.getName());
+        ConsumerModel referredService = 
repository.lookupReferredServices(DemoService.class.getName()).get(0);
         Assertions.assertEquals(referredService, consumerModel);
 
         // 3.test providerModel
@@ -94,14 +94,14 @@ class ModuleServiceRepositoryTest {
             serviceMetadata, ClassUtils.getClassLoader(DemoService.class));
         repository.registerProvider(providerModel);
         List<ProviderModel> allExportedServices = 
repository.getExportedServices();
-        Assertions.assertEquals(allExportedServices.size(), 1);
+        Assertions.assertEquals(1, allExportedServices.size());
         Assertions.assertEquals(allExportedServices.get(0), providerModel);
 
         ProviderModel exportedService = 
repository.lookupExportedService(DemoService.class.getName());
         Assertions.assertEquals(exportedService, providerModel);
 
         List<ProviderModel> providerModels = 
frameworkModel.getServiceRepository().allProviderModels();
-        Assertions.assertEquals(providerModels.size(), 1);
+        Assertions.assertEquals(1, providerModels.size());
         Assertions.assertEquals(providerModels.get(0), providerModel);
 
         // 4.test destroy

Reply via email to