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

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


The following commit(s) were added to refs/heads/master by this push:
     new 259c072  update CXF to latest version and add test case for webservice 
protocol (#1564)
259c072 is described below

commit 259c07228c9fe14285c7101e7e2d070acdbfa5ce
Author: kimmking <kimmking...@gmail.com>
AuthorDate: Mon May 28 14:46:09 2018 +0800

    update CXF to latest version and add test case for webservice protocol 
(#1564)
    
    * update cxf version and add test cases
    
    * support jdk7
    
    * add profile for dependency in jdk9
    
    * modify profile location
    
    * fix jaxb version
    
    * add dependency for jdk9
    
    * extract dependencies to dependencies bom project
---
 dependencies-bom/pom.xml                           | 33 ++++++++-
 dubbo-rpc/dubbo-rpc-webservice/pom.xml             | 21 ++++++
 .../protocol/webservice/WebServiceProtocol.java    |  7 +-
 .../dubbo/rpc/protocol/webservice/DemoService.java | 43 ++++++++++++
 .../rpc/protocol/webservice/DemoServiceImpl.java   | 80 ++++++++++++++++++++++
 .../dubbo/rpc/protocol/webservice/User.java        | 38 ++++++++++
 .../webservice/WebserviceProtocolTest.java         | 71 +++++++++++++++++++
 7 files changed, 291 insertions(+), 2 deletions(-)

diff --git a/dependencies-bom/pom.xml b/dependencies-bom/pom.xml
index 94bfa1e..89de3c3 100644
--- a/dependencies-bom/pom.xml
+++ b/dependencies-bom/pom.xml
@@ -84,7 +84,7 @@
         <curator_version>2.12.0</curator_version>
         <jedis_version>2.9.0</jedis_version>
         <xmemcached_version>1.3.6</xmemcached_version>
-        <cxf_version>3.0.14</cxf_version>
+        <cxf_version>3.1.15</cxf_version>
         <thrift_version>0.8.0</thrift_version>
         <hessian_version>4.0.38</hessian_version>
         <servlet_version>3.1.0</servlet_version>
@@ -107,6 +107,9 @@
         <logback_version>1.2.2</logback_version>
         <commons_lang3_version>3.4</commons_lang3_version>
         <embedded_redis_version>0.6</embedded_redis_version>
+
+        <jaxb_version>2.2.7</jaxb_version>
+        <activation_version>1.2.0</activation_version>
     </properties>
 
     <dependencyManagement>
@@ -321,6 +324,34 @@
                 <artifactId>commons-lang3</artifactId>
                 <version>${commons_lang3_version}</version>
             </dependency>
+
+            <!-- for dubbo-rpc-webservice -->
+            <dependency>
+                <groupId>javax.xml.bind</groupId>
+                <artifactId>jaxb-api</artifactId>
+                <version>${jaxb_version}</version>
+            </dependency>
+            <dependency>
+                <groupId>com.sun.xml.bind</groupId>
+                <artifactId>jaxb-impl</artifactId>
+                <version>${jaxb_version}</version>
+            </dependency>
+            <dependency>
+                <groupId>com.sun.xml.bind</groupId>
+                <artifactId>jaxb-core</artifactId>
+                <version>${jaxb_version}</version>
+            </dependency>
+            <dependency>
+                <groupId>javax.activation</groupId>
+                <artifactId>javax.activation-api</artifactId>
+                <version>${activation_version}</version>
+            </dependency>
+            <dependency>
+                <groupId>com.sun.activation</groupId>
+                <artifactId>javax.activation</artifactId>
+                <version>${activation_version}</version>
+            </dependency>
+
             <!-- Test lib -->
             <dependency>
                 <groupId>org.apache.curator</groupId>
diff --git a/dubbo-rpc/dubbo-rpc-webservice/pom.xml 
b/dubbo-rpc/dubbo-rpc-webservice/pom.xml
index a2b656d..cdb5403 100644
--- a/dubbo-rpc/dubbo-rpc-webservice/pom.xml
+++ b/dubbo-rpc/dubbo-rpc-webservice/pom.xml
@@ -41,6 +41,26 @@
             <version>${project.parent.version}</version>
         </dependency>
         <dependency>
+            <groupId>javax.xml.bind</groupId>
+            <artifactId>jaxb-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.sun.xml.bind</groupId>
+            <artifactId>jaxb-impl</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.sun.xml.bind</groupId>
+            <artifactId>jaxb-core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>javax.activation</groupId>
+            <artifactId>javax.activation-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.sun.activation</groupId>
+            <artifactId>javax.activation</artifactId>
+        </dependency>
+        <dependency>
             <groupId>org.apache.cxf</groupId>
             <artifactId>cxf-rt-frontend-simple</artifactId>
         </dependency>
@@ -53,4 +73,5 @@
             <artifactId>spring-context</artifactId>
         </dependency>
     </dependencies>
+
 </project>
\ No newline at end of file
diff --git 
a/dubbo-rpc/dubbo-rpc-webservice/src/main/java/com/alibaba/dubbo/rpc/protocol/webservice/WebServiceProtocol.java
 
b/dubbo-rpc/dubbo-rpc-webservice/src/main/java/com/alibaba/dubbo/rpc/protocol/webservice/WebServiceProtocol.java
index 995f5c5..f501a42 100644
--- 
a/dubbo-rpc/dubbo-rpc-webservice/src/main/java/com/alibaba/dubbo/rpc/protocol/webservice/WebServiceProtocol.java
+++ 
b/dubbo-rpc/dubbo-rpc-webservice/src/main/java/com/alibaba/dubbo/rpc/protocol/webservice/WebServiceProtocol.java
@@ -95,7 +95,12 @@ public class WebServiceProtocol extends 
AbstractProxyProtocol {
         return new Runnable() {
             @Override
             public void run() {
-                serverFactoryBean.destroy();
+                if(serverFactoryBean.getServer()!= null) {
+                    serverFactoryBean.getServer().destroy();
+                }
+                if(serverFactoryBean.getBus()!=null) {
+                    serverFactoryBean.getBus().shutdown(true);
+                }
             }
         };
     }
diff --git 
a/dubbo-rpc/dubbo-rpc-webservice/src/test/java/com/alibaba/dubbo/rpc/protocol/webservice/DemoService.java
 
b/dubbo-rpc/dubbo-rpc-webservice/src/test/java/com/alibaba/dubbo/rpc/protocol/webservice/DemoService.java
new file mode 100644
index 0000000..d3c664c
--- /dev/null
+++ 
b/dubbo-rpc/dubbo-rpc-webservice/src/test/java/com/alibaba/dubbo/rpc/protocol/webservice/DemoService.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.alibaba.dubbo.rpc.protocol.webservice;
+
+/**
+ * <code>TestService</code>
+ */
+
+public interface DemoService {
+    void sayHello(String name);
+
+    String echo(String text);
+
+    long timestamp();
+
+    void throwTimeout();
+
+    String getThreadName();
+
+    int getSize(String[] strs);
+
+    int getSize(Object[] os);
+
+    Object invoke(String service, String method) throws Exception;
+
+    int stringLength(String str);
+
+    User create(int age, String name);
+}
\ No newline at end of file
diff --git 
a/dubbo-rpc/dubbo-rpc-webservice/src/test/java/com/alibaba/dubbo/rpc/protocol/webservice/DemoServiceImpl.java
 
b/dubbo-rpc/dubbo-rpc-webservice/src/test/java/com/alibaba/dubbo/rpc/protocol/webservice/DemoServiceImpl.java
new file mode 100644
index 0000000..96e02c8
--- /dev/null
+++ 
b/dubbo-rpc/dubbo-rpc-webservice/src/test/java/com/alibaba/dubbo/rpc/protocol/webservice/DemoServiceImpl.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.alibaba.dubbo.rpc.protocol.webservice;
+
+import com.alibaba.dubbo.rpc.RpcContext;
+
+/**
+ * DemoServiceImpl
+ */
+
+public class DemoServiceImpl implements DemoService {
+    public DemoServiceImpl() {
+        super();
+    }
+
+    public void sayHello(String name) {
+        System.out.println("hello " + name);
+    }
+
+    public String echo(String text) {
+        return text;
+    }
+
+    public long timestamp() {
+        return System.currentTimeMillis();
+    }
+
+    public String getThreadName() {
+        return Thread.currentThread().getName();
+    }
+
+    public int getSize(String[] strs) {
+        if (strs == null)
+            return -1;
+        return strs.length;
+    }
+
+    public int getSize(Object[] os) {
+        if (os == null)
+            return -1;
+        return os.length;
+    }
+
+    public Object invoke(String service, String method) throws Exception {
+        System.out.println("RpcContext.getContext().getRemoteHost()=" + 
RpcContext.getContext().getRemoteHost());
+        return service + ":" + method;
+    }
+
+    public User create(int age, String name){
+        User user = new User();
+        user.setAge(age);
+        user.setName(name);
+        return user;
+    }
+
+    public int stringLength(String str) {
+        return str.length();
+    }
+
+    public void throwTimeout() {
+        try {
+            Thread.sleep(6000);
+        } catch (InterruptedException e) {
+        }
+    }
+}
\ No newline at end of file
diff --git 
a/dubbo-rpc/dubbo-rpc-webservice/src/test/java/com/alibaba/dubbo/rpc/protocol/webservice/User.java
 
b/dubbo-rpc/dubbo-rpc-webservice/src/test/java/com/alibaba/dubbo/rpc/protocol/webservice/User.java
new file mode 100644
index 0000000..866e36b
--- /dev/null
+++ 
b/dubbo-rpc/dubbo-rpc-webservice/src/test/java/com/alibaba/dubbo/rpc/protocol/webservice/User.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.alibaba.dubbo.rpc.protocol.webservice;
+
+public class User {
+    private int age;
+    private  String name;
+
+    public int getAge() {
+        return age;
+    }
+
+    public void setAge(int age) {
+        this.age = age;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+}
\ No newline at end of file
diff --git 
a/dubbo-rpc/dubbo-rpc-webservice/src/test/java/com/alibaba/dubbo/rpc/protocol/webservice/WebserviceProtocolTest.java
 
b/dubbo-rpc/dubbo-rpc-webservice/src/test/java/com/alibaba/dubbo/rpc/protocol/webservice/WebserviceProtocolTest.java
new file mode 100644
index 0000000..98e7738
--- /dev/null
+++ 
b/dubbo-rpc/dubbo-rpc-webservice/src/test/java/com/alibaba/dubbo/rpc/protocol/webservice/WebserviceProtocolTest.java
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.alibaba.dubbo.rpc.protocol.webservice;
+
+import com.alibaba.dubbo.common.URL;
+import com.alibaba.dubbo.common.extension.ExtensionLoader;
+import com.alibaba.dubbo.rpc.Protocol;
+import com.alibaba.dubbo.rpc.ProxyFactory;
+import com.alibaba.dubbo.rpc.service.EchoService;
+import org.junit.Test;
+
+import static junit.framework.Assert.assertEquals;
+
+/**
+ * @author kimmking
+ */
+
+public class WebserviceProtocolTest {
+    private Protocol protocol = 
ExtensionLoader.getExtensionLoader(Protocol.class).getAdaptiveExtension();
+    private ProxyFactory proxy = 
ExtensionLoader.getExtensionLoader(ProxyFactory.class).getAdaptiveExtension();
+
+    @Test
+    public void testDemoProtocol() throws Exception {
+        DemoService service = new DemoServiceImpl();
+        protocol.export(proxy.getInvoker(service, DemoService.class, 
URL.valueOf("webservice://127.0.0.1:9019/" + DemoService.class.getName() + 
"?codec=exchange")));
+        service = proxy.getProxy(protocol.refer(DemoService.class, 
URL.valueOf("webservice://127.0.0.1:9019/" + DemoService.class.getName() + 
"?codec=exchange")));
+        assertEquals(service.getSize(new String[]{"", "", ""}), 3);
+    }
+
+    @Test
+    public void testWebserviceProtocol() throws Exception {
+        DemoService service = new DemoServiceImpl();
+        protocol.export(proxy.getInvoker(service, DemoService.class, 
URL.valueOf("webservice://127.0.0.1:9019/" + DemoService.class.getName())));
+        service = proxy.getProxy(protocol.refer(DemoService.class, 
URL.valueOf("webservice://127.0.0.1:9019/" + DemoService.class.getName())));
+        assertEquals(service.create(1,"kk").getName(), "kk");
+        assertEquals(service.getSize(null), -1);
+        assertEquals(service.getSize(new String[]{"", "", ""}), 3);
+        Object object = service.invoke("webservice://127.0.0.1:9019/" + 
DemoService.class.getName() + "", "invoke");
+        System.out.println(object);
+        
assertEquals("webservice://127.0.0.1:9019/com.alibaba.dubbo.rpc.protocol.webservice.DemoService:invoke",
 object);
+
+        StringBuffer buf = new StringBuffer();
+        for (int i = 0; i < 1024 * 32 + 32; i++)
+            buf.append('A');
+        assertEquals(32800,service.stringLength(buf.toString()));
+
+//  a method start with $ is illegal in soap
+//        // cast to EchoService
+//        EchoService echo = proxy.getProxy(protocol.refer(EchoService.class, 
URL.valueOf("webservice://127.0.0.1:9010/" + DemoService.class.getName() + 
"?client=netty")));
+//        assertEquals(echo.echo(buf.toString()), buf.toString());
+//        assertEquals(echo.$echo("test"), "test");
+//        assertEquals(echo.$echo("abcdefg"), "abcdefg");
+//        assertEquals(echo.$echo(1234), 1234);
+    }
+
+
+}
\ No newline at end of file

-- 
To stop receiving notification emails like this one, please contact
wang...@apache.org.

Reply via email to