You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by il...@apache.org on 2019/08/20 05:04:29 UTC

[dubbo-samples] branch master updated: integration test for https://github.com/apache/dubbo/issues/4889

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 9ba8ebd  integration test for https://github.com/apache/dubbo/issues/4889
9ba8ebd is described below

commit 9ba8ebdb333af84c1f96c9c8a4f4a1deabb6a016
Author: Ian Luo <ia...@gmail.com>
AuthorDate: Tue Aug 20 13:03:58 2019 +0800

    integration test for https://github.com/apache/dubbo/issues/4889
---
 .../resources/spring/dubbo-direct-consumer.xml     |  2 +-
 .../resources/spring/dubbo-direct-provider.xml     |  2 +-
 .../dubbo/samples/direct/DirectServiceIT.java      | 40 +++++++++++++++++++++-
 3 files changed, 41 insertions(+), 3 deletions(-)

diff --git a/dubbo-samples-direct/src/main/resources/spring/dubbo-direct-consumer.xml b/dubbo-samples-direct/src/main/resources/spring/dubbo-direct-consumer.xml
index 14a7dad..a65f213 100644
--- a/dubbo-samples-direct/src/main/resources/spring/dubbo-direct-consumer.xml
+++ b/dubbo-samples-direct/src/main/resources/spring/dubbo-direct-consumer.xml
@@ -26,5 +26,5 @@
     <dubbo:application name="direct-consumer"/>
 
     <dubbo:reference id="directService" check="false" interface="org.apache.dubbo.samples.direct.api.DirectService"
-                     url="${target.address:localhost}:20880"/>
+                     url="${target.address:localhost}:20880" group="test" version="1.0.0-daily"/>
 </beans>
diff --git a/dubbo-samples-direct/src/main/resources/spring/dubbo-direct-provider.xml b/dubbo-samples-direct/src/main/resources/spring/dubbo-direct-provider.xml
index 9200f29..a514f34 100644
--- a/dubbo-samples-direct/src/main/resources/spring/dubbo-direct-provider.xml
+++ b/dubbo-samples-direct/src/main/resources/spring/dubbo-direct-provider.xml
@@ -31,6 +31,6 @@
 
     <bean id="directService" class="org.apache.dubbo.samples.direct.impl.DirectServiceImpl"/>
 
-    <dubbo:service interface="org.apache.dubbo.samples.direct.api.DirectService" ref="directService"/>
+    <dubbo:service interface="org.apache.dubbo.samples.direct.api.DirectService" ref="directService" group="test" version="1.0.0-daily"/>
 
 </beans>
diff --git a/dubbo-samples-direct/src/test/java/org/apache/dubbo/samples/direct/DirectServiceIT.java b/dubbo-samples-direct/src/test/java/org/apache/dubbo/samples/direct/DirectServiceIT.java
index 6a5a25c..d28373e 100644
--- a/dubbo-samples-direct/src/test/java/org/apache/dubbo/samples/direct/DirectServiceIT.java
+++ b/dubbo-samples-direct/src/test/java/org/apache/dubbo/samples/direct/DirectServiceIT.java
@@ -17,6 +17,10 @@
 
 package org.apache.dubbo.samples.direct;
 
+import junit.framework.TestCase;
+import org.apache.dubbo.config.ApplicationConfig;
+import org.apache.dubbo.config.ReferenceConfig;
+import org.apache.dubbo.rpc.service.GenericService;
 import org.apache.dubbo.samples.direct.api.DirectService;
 
 import org.junit.Assert;
@@ -29,11 +33,45 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 @RunWith(SpringJUnit4ClassRunner.class)
 @ContextConfiguration(locations = {"classpath*:/spring/dubbo-direct-consumer.xml"})
 public class DirectServiceIT {
+    private static String providerAddress = System.getProperty("target.address", "localhost");
+
     @Autowired
     private DirectService directService;
 
     @Test
-    public void test() throws Exception {
+    public void testXml() throws Exception {
         Assert.assertTrue(directService.sayHello("dubbo").startsWith("Hello dubbo"));
     }
+
+    @Test
+    public void testGeneric() throws Exception {
+        ApplicationConfig application = new ApplicationConfig();
+        application.setName("direct-consumer");
+        ReferenceConfig<GenericService> reference = new ReferenceConfig<>();
+        reference.setUrl("dubbo://" + providerAddress + ":20880/" + DirectService.class.getName());
+        reference.setVersion("1.0.0-daily");
+        reference.setGroup("test");
+        reference.setGeneric(true);
+        reference.setApplication(application);
+        reference.setInterface(DirectService.class.getName());
+        GenericService genericService = reference.get();
+        Object obj = genericService.$invoke("sayHello", new String[]{String.class.getName()}, new Object[]{ "generic" });
+        String str = (String) obj;
+        TestCase.assertTrue(str.startsWith("Hello generic"));
+    }
+
+    @Test
+    public void testApi() throws Exception {
+        ApplicationConfig application = new ApplicationConfig();
+        application.setName("direct-consumer");
+        ReferenceConfig<DirectService> reference = new ReferenceConfig<>();
+        reference.setUrl("dubbo://" + providerAddress + ":20880/" + DirectService.class.getName());
+        reference.setVersion("1.0.0-daily");
+        reference.setGroup("test");
+        reference.setApplication(application);
+        reference.setInterface(DirectService.class.getName());
+        DirectService service = reference.get();
+        String result = service.sayHello("api");
+        TestCase.assertTrue(result.startsWith("Hello api"));
+    }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org