You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by li...@apache.org on 2021/06/08 09:20:38 UTC

[dubbo] branch master updated: feat: Add testcase for DubboService#parameters to verify issue#3072 (#8001)

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 56367d5  feat: Add testcase for DubboService#parameters to verify issue#3072 (#8001)
56367d5 is described below

commit 56367d5e07fa6faabb1bafe3fbf64cc39a83ae2c
Author: Xiong, Pin <pi...@foxmail.com>
AuthorDate: Tue Jun 8 04:20:01 2021 -0500

    feat: Add testcase for DubboService#parameters to verify issue#3072 (#8001)
---
 .../annotation/ServiceClassPostProcessorTest.java  | 23 +++++++++++++++++++---
 .../annotation/provider/DefaultHelloService.java   |  2 +-
 2 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/beans/factory/annotation/ServiceClassPostProcessorTest.java b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/beans/factory/annotation/ServiceClassPostProcessorTest.java
index 2d343c6..478eb3b 100644
--- a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/beans/factory/annotation/ServiceClassPostProcessorTest.java
+++ b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/beans/factory/annotation/ServiceClassPostProcessorTest.java
@@ -16,6 +16,7 @@
  */
 package org.apache.dubbo.config.spring.beans.factory.annotation;
 
+import org.apache.dubbo.config.annotation.DubboService;
 import org.apache.dubbo.config.bootstrap.DubboBootstrap;
 import org.apache.dubbo.config.spring.ServiceBean;
 import org.apache.dubbo.config.spring.api.HelloService;
@@ -117,11 +118,27 @@ public class ServiceClassPostProcessorTest {
      * Lazy-init for Dubbo Service
      */
     @Test
-    public void testLazyInitDubboService(){
+    public void testLazyInitDubboService() {
         /**
          * The class {@link org.apache.dubbo.config.spring.context.annotation.provider.DefaultLazyInitHelloService} has Lazy annotation
          * */
-        BeanDefinition beanDefinition=beanFactory.getBeanDefinition("defaultLazyInitHelloService");
-        Assertions.assertEquals(beanDefinition.isLazyInit(),true);
+        BeanDefinition beanDefinition = beanFactory.getBeanDefinition("defaultLazyInitHelloService");
+        Assertions.assertEquals(beanDefinition.isLazyInit(), true);
+    }
+
+    /**
+     * Test if the {@link DubboService#parameters()} works well
+     * see issue: https://github.com/apache/dubbo/issues/3072
+     */
+    @Test
+    public void testDubboServiceParameter() {
+        /**
+         * get the {@link ServiceBean} of {@link org.apache.dubbo.config.spring.context.annotation.provider.DefaultHelloService}
+         * */
+        ServiceBean serviceBean = beanFactory.getBean("ServiceBean:org.apache.dubbo.config.spring.api.HelloService", ServiceBean.class);
+        Assertions.assertNotNull(serviceBean);
+        Assertions.assertNotNull(serviceBean.getParameters());
+        Assertions.assertTrue(serviceBean.getParameters().size() == 1);
+        Assertions.assertEquals(serviceBean.toUrl().getParameter("sayHello.timeout"), "3000");
     }
 }
diff --git a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/context/annotation/provider/DefaultHelloService.java b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/context/annotation/provider/DefaultHelloService.java
index 0384baf..0b0bc6c 100644
--- a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/context/annotation/provider/DefaultHelloService.java
+++ b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/context/annotation/provider/DefaultHelloService.java
@@ -28,7 +28,7 @@ import org.springframework.stereotype.Service;
  * @since TODO
  */
 @Service
-@DubboService
+@DubboService(parameters = {"sayHello.timeout", "3000"})
 public class DefaultHelloService implements HelloService {
 
     @Override