diff --git a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/reference/localcall/LocalCallTest.java b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/reference/localcall/LocalCallTest.java index 5af4ada5eab1..c691c5ce974c 100644 --- a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/reference/localcall/LocalCallTest.java +++ b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/reference/localcall/LocalCallTest.java @@ -17,6 +17,7 @@ package org.apache.dubbo.config.spring.reference.localcall; import org.apache.dubbo.config.bootstrap.DubboBootstrap; +import org.apache.dubbo.config.spring.SysProps; import org.apache.dubbo.config.spring.api.HelloService; import java.net.InetSocketAddress; @@ -45,11 +46,15 @@ class LocalCallTest { @BeforeAll public static void beforeAll() { DubboBootstrap.reset(); + SysProps.clear(); + SysProps.setProperty("dubbo.metrics.enabled", "false"); + SysProps.setProperty("dubbo.metrics.protocol", "disabled"); } @AfterAll public static void afterAll() { DubboBootstrap.reset(); + SysProps.clear(); } @Autowired diff --git a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/reference/localcalla/LocalCallReferenceAnnotationTest.java b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/reference/localcalla/LocalCallReferenceAnnotationTest.java index 9c4bd6ae45f4..8f5ddce48145 100644 --- a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/reference/localcalla/LocalCallReferenceAnnotationTest.java +++ b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/reference/localcalla/LocalCallReferenceAnnotationTest.java @@ -19,6 +19,7 @@ import org.apache.dubbo.config.annotation.DubboReference; import org.apache.dubbo.config.annotation.DubboService; import org.apache.dubbo.config.bootstrap.DubboBootstrap; +import org.apache.dubbo.config.spring.SysProps; import org.apache.dubbo.config.spring.api.HelloService; import org.apache.dubbo.config.spring.context.annotation.EnableDubbo; import org.apache.dubbo.rpc.RpcContext; @@ -52,11 +53,15 @@ class LocalCallReferenceAnnotationTest { @BeforeAll public static void setUp() { DubboBootstrap.reset(); + SysProps.clear(); + SysProps.setProperty("dubbo.metrics.enabled", "false"); + SysProps.setProperty("dubbo.metrics.protocol", "disabled"); } @AfterAll public static void tearDown() { DubboBootstrap.reset(); + SysProps.clear(); } @Autowired diff --git a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/reference/localcallam/LocalCallMultipleReferenceAnnotationsTest.java b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/reference/localcallam/LocalCallMultipleReferenceAnnotationsTest.java index f253ab00a53c..f4ee3de0a4b2 100644 --- a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/reference/localcallam/LocalCallMultipleReferenceAnnotationsTest.java +++ b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/reference/localcallam/LocalCallMultipleReferenceAnnotationsTest.java @@ -37,6 +37,7 @@ import org.springframework.context.annotation.PropertySource; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit.jupiter.SpringExtension; import static org.springframework.test.annotation.DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD; @@ -50,6 +51,7 @@ LocalCallMultipleReferenceAnnotationsTest.LocalCallConfiguration.class }) @DirtiesContext(classMode = AFTER_EACH_TEST_METHOD) +@TestPropertySource(properties = {"dubbo.metrics.enabled=false", "dubbo.metrics.protocol=disabled"}) class LocalCallMultipleReferenceAnnotationsTest { @BeforeAll @@ -81,8 +83,14 @@ void testLocalCall() { Map referenceBeanMap = applicationContext.getBeansOfType(ReferenceBean.class); Assertions.assertEquals(2, referenceBeanMap.size()); - Assertions.assertTrue(referenceBeanMap.containsKey("&helloService")); - Assertions.assertTrue(referenceBeanMap.containsKey("&demoHelloService")); + + boolean hasHelloRef = + referenceBeanMap.containsKey("&helloService") || referenceBeanMap.containsKey("&helloService3"); + boolean hasDemoRef = + referenceBeanMap.containsKey("&demoHelloService") || referenceBeanMap.containsKey("&helloService3"); + + Assertions.assertTrue(hasHelloRef, "Expected a hello reference bean (&helloService or &helloService3)"); + Assertions.assertTrue(hasDemoRef, "Expected a demo reference bean (&demoHelloService or &helloService3)"); // helloService3 and demoHelloService share the same ReferenceConfig instance ReferenceBean helloService3ReferenceBean = applicationContext.getBean("&helloService3", ReferenceBean.class); diff --git a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/reference/localcallmix/LocalCallReferenceMixTest.java b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/reference/localcallmix/LocalCallReferenceMixTest.java index 90c08561f0ac..bcb155fee922 100644 --- a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/reference/localcallmix/LocalCallReferenceMixTest.java +++ b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/reference/localcallmix/LocalCallReferenceMixTest.java @@ -19,6 +19,7 @@ import org.apache.dubbo.config.annotation.DubboReference; import org.apache.dubbo.config.annotation.DubboService; import org.apache.dubbo.config.bootstrap.DubboBootstrap; +import org.apache.dubbo.config.spring.SysProps; import org.apache.dubbo.config.spring.api.HelloService; import org.apache.dubbo.config.spring.context.annotation.EnableDubbo; import org.apache.dubbo.rpc.RpcContext; @@ -53,11 +54,15 @@ class LocalCallReferenceMixTest { @BeforeAll public static void setUp() { DubboBootstrap.reset(); + SysProps.clear(); + SysProps.setProperty("dubbo.metrics.enabled", "false"); + SysProps.setProperty("dubbo.metrics.protocol", "disabled"); } @AfterAll public static void tearDown() { DubboBootstrap.reset(); + SysProps.clear(); } @Autowired