cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ff...@apache.org
Subject svn commit: r540058 - in /incubator/cxf/trunk: systests/src/test/java/org/apache/cxf/systest/multitransport/ testutils/src/main/java/org/apache/hello_world_doc_lit/ testutils/src/main/resources/wsdl/
Date Mon, 21 May 2007 08:31:12 GMT
Author: ffang
Date: Mon May 21 01:31:10 2007
New Revision: 540058

URL: http://svn.apache.org/viewvc?view=rev&rev=540058
Log:
add systest to show how one service include two ports with different transport work

Added:
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/multitransport/
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/multitransport/MultiTransportClientServerTest.java
  (with props)
    incubator/cxf/trunk/testutils/src/main/java/org/apache/hello_world_doc_lit/HTTPGreeterImpl.java
  (with props)
    incubator/cxf/trunk/testutils/src/main/java/org/apache/hello_world_doc_lit/JMSGreeterImpl.java
  (with props)
    incubator/cxf/trunk/testutils/src/main/java/org/apache/hello_world_doc_lit/MultiTransportGreeter.java
  (with props)
Modified:
    incubator/cxf/trunk/testutils/src/main/resources/wsdl/hello_world_doc_lit.wsdl

Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/multitransport/MultiTransportClientServerTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/multitransport/MultiTransportClientServerTest.java?view=auto&rev=540058
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/multitransport/MultiTransportClientServerTest.java
(added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/multitransport/MultiTransportClientServerTest.java
Mon May 21 01:31:10 2007
@@ -0,0 +1,150 @@
+/**
+ * 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 org.apache.cxf.systest.multitransport;
+
+import java.lang.reflect.UndeclaredThrowableException;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.logging.Logger;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.Endpoint;
+
+import org.apache.cxf.systest.jms.EmbeddedJMSBrokerLauncher;
+import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
+import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
+import org.apache.hello_world_doc_lit.Greeter;
+import org.apache.hello_world_doc_lit.HTTPGreeterImpl;
+import org.apache.hello_world_doc_lit.JMSGreeterImpl;
+import org.apache.hello_world_doc_lit.MultiTransportService;
+import org.apache.hello_world_doc_lit.PingMeFault;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class MultiTransportClientServerTest extends AbstractBusClientServerTestBase {
+    static final Logger LOG = Logger.getLogger(MultiTransportClientServerTest.class.getName());
+    private final QName serviceName = new QName(
+                                      "http://apache.org/hello_world_doc_lit",
+                                                "MultiTransportService");
+
+    public static class MyServer extends AbstractBusTestServerBase {
+
+        protected void run() {
+            Object implementor = new HTTPGreeterImpl();
+            String address = "http://localhost:9001/SOAPDocLitService/SoapPort";
+            Endpoint.publish(address, implementor);
+            implementor = new JMSGreeterImpl();
+            Endpoint.publish(null, implementor);
+        }
+
+        public static void main(String[] args) {
+            try {
+                MyServer s = new MyServer();
+                s.start();
+            } catch (Exception ex) {
+                ex.printStackTrace();
+                System.exit(-1);
+            } finally {
+                LOG.info("done!");
+            }
+        }
+    }
+
+    @BeforeClass
+    public static void startServers() throws Exception {
+        Map<String, String> props = new HashMap<String, String>();          
     
+        if (System.getProperty("activemq.store.dir") != null) {
+            props.put("activemq.store.dir", System.getProperty("activemq.store.dir"));
+        }
+        props.put("java.util.logging.config.file", 
+                  System.getProperty("java.util.logging.config.file"));
+        
+        assertTrue("server did not launch correctly", 
+                   launchServer(EmbeddedJMSBrokerLauncher.class, props, null));
+
+        assertTrue("server did not launch correctly", launchServer(MyServer.class));
+        
+    }
+    
+    // the purpose of this test shows how one service include two ports with different
+    // transport work
+    @Test
+    public void testMultiTransportInOneService() throws Exception {
+        
+        QName portName1 = new QName("http://apache.org/hello_world_doc_lit", "HttpPort");
+        QName portName2 = new QName("http://apache.org/hello_world_doc_lit", "JMSPort");
+        URL wsdl = getClass().getResource("/wsdl/hello_world_doc_lit.wsdl");
+        assertNotNull(wsdl);
+
+        MultiTransportService service = new MultiTransportService(wsdl, serviceName);
+        assertNotNull(service);
+
+        String response1 = new String("Hello Milestone-");
+        String response2 = new String("Bonjour");
+        try {
+            Greeter greeter = service.getPort(portName1, Greeter.class);
+            for (int idx = 0; idx < 5; idx++) {
+                String greeting = greeter.greetMe("Milestone-" + idx);
+                assertNotNull("no response received from service", greeting);
+                String exResponse = response1 + idx;
+                assertEquals(exResponse, greeting);
+
+                String reply = greeter.sayHi();
+                assertNotNull("no response received from service", reply);
+                assertEquals(response2, reply);
+                
+                try {
+                    greeter.pingMe();
+                    fail("Should have thrown FaultException");
+                } catch (PingMeFault ex) {
+                    assertNotNull(ex.getFaultInfo());
+                }                
+              
+            }
+            
+            greeter = service.getPort(portName2, Greeter.class);
+            for (int idx = 0; idx < 5; idx++) {
+                String greeting = greeter.greetMe("Milestone-" + idx);
+                assertNotNull("no response received from service", greeting);
+                String exResponse = response1 + idx;
+                assertEquals(exResponse, greeting);
+
+                String reply = greeter.sayHi();
+                assertNotNull("no response received from service", reply);
+                assertEquals(response2, reply);
+                
+                try {
+                    greeter.pingMe();
+                    fail("Should have thrown FaultException");
+                } catch (PingMeFault ex) {
+                    assertNotNull(ex.getFaultInfo());
+                }                
+              
+            }
+
+            
+        } catch (UndeclaredThrowableException ex) {
+            throw (Exception)ex.getCause();
+        }
+    }
+
+
+}

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/multitransport/MultiTransportClientServerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/multitransport/MultiTransportClientServerTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/testutils/src/main/java/org/apache/hello_world_doc_lit/HTTPGreeterImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/testutils/src/main/java/org/apache/hello_world_doc_lit/HTTPGreeterImpl.java?view=auto&rev=540058
==============================================================================
--- incubator/cxf/trunk/testutils/src/main/java/org/apache/hello_world_doc_lit/HTTPGreeterImpl.java
(added)
+++ incubator/cxf/trunk/testutils/src/main/java/org/apache/hello_world_doc_lit/HTTPGreeterImpl.java
Mon May 21 01:31:10 2007
@@ -0,0 +1,30 @@
+/**
+ * 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 org.apache.hello_world_doc_lit;
+
+import javax.jws.WebService;
+
+@WebService(serviceName = "MultiTransportService", 
+            portName = "HttpPort", 
+            endpointInterface = "org.apache.hello_world_doc_lit.Greeter",
+            targetNamespace = "http://apache.org/hello_world_doc_lit",
+            wsdlLocation = "testutils/hello_world_doc_lit.wsdl")
+public class HTTPGreeterImpl extends MultiTransportGreeter {
+}

Propchange: incubator/cxf/trunk/testutils/src/main/java/org/apache/hello_world_doc_lit/HTTPGreeterImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/testutils/src/main/java/org/apache/hello_world_doc_lit/HTTPGreeterImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/testutils/src/main/java/org/apache/hello_world_doc_lit/JMSGreeterImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/testutils/src/main/java/org/apache/hello_world_doc_lit/JMSGreeterImpl.java?view=auto&rev=540058
==============================================================================
--- incubator/cxf/trunk/testutils/src/main/java/org/apache/hello_world_doc_lit/JMSGreeterImpl.java
(added)
+++ incubator/cxf/trunk/testutils/src/main/java/org/apache/hello_world_doc_lit/JMSGreeterImpl.java
Mon May 21 01:31:10 2007
@@ -0,0 +1,30 @@
+/**
+ * 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 org.apache.hello_world_doc_lit;
+
+import javax.jws.WebService;
+
+@WebService(serviceName = "MultiTransportService", 
+            portName = "JMSPort", 
+            endpointInterface = "org.apache.hello_world_doc_lit.Greeter",
+            targetNamespace = "http://apache.org/hello_world_doc_lit",
+            wsdlLocation = "testutils/hello_world_doc_lit.wsdl")
+public class JMSGreeterImpl extends MultiTransportGreeter {
+}

Propchange: incubator/cxf/trunk/testutils/src/main/java/org/apache/hello_world_doc_lit/JMSGreeterImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/testutils/src/main/java/org/apache/hello_world_doc_lit/JMSGreeterImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/testutils/src/main/java/org/apache/hello_world_doc_lit/MultiTransportGreeter.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/testutils/src/main/java/org/apache/hello_world_doc_lit/MultiTransportGreeter.java?view=auto&rev=540058
==============================================================================
--- incubator/cxf/trunk/testutils/src/main/java/org/apache/hello_world_doc_lit/MultiTransportGreeter.java
(added)
+++ incubator/cxf/trunk/testutils/src/main/java/org/apache/hello_world_doc_lit/MultiTransportGreeter.java
Mon May 21 01:31:10 2007
@@ -0,0 +1,52 @@
+/**
+ * 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 org.apache.hello_world_doc_lit;
+
+
+import org.apache.hello_world_doc_lit.types.FaultDetail;
+
+public class MultiTransportGreeter implements Greeter {
+
+    public String sayHi() {
+        System.out.println("Call sayHi here ");
+        return "Bonjour";
+    }
+
+    public String greetMe(String requestType) {
+        System.out.println("Reached here :" + requestType);
+        return "Hello " + requestType;
+    }
+
+    public void greetMeOneWay(String requestType) {
+        System.out.println("*********  greetMeOneWay: " + requestType);        
+    }
+
+    public void pingMe() throws PingMeFault {
+        FaultDetail faultDetail = new FaultDetail();
+        faultDetail.setMajor((short)2);
+        faultDetail.setMinor((short)1);
+        throw new PingMeFault("PingMeFault raised by server", faultDetail);
+        
+    }
+
+}
+
+
+

Propchange: incubator/cxf/trunk/testutils/src/main/java/org/apache/hello_world_doc_lit/MultiTransportGreeter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/testutils/src/main/java/org/apache/hello_world_doc_lit/MultiTransportGreeter.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/cxf/trunk/testutils/src/main/resources/wsdl/hello_world_doc_lit.wsdl
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/testutils/src/main/resources/wsdl/hello_world_doc_lit.wsdl?view=diff&rev=540058&r1=540057&r2=540058
==============================================================================
--- incubator/cxf/trunk/testutils/src/main/resources/wsdl/hello_world_doc_lit.wsdl (original)
+++ incubator/cxf/trunk/testutils/src/main/resources/wsdl/hello_world_doc_lit.wsdl Mon May
21 01:31:10 2007
@@ -182,6 +182,21 @@
             <soap:address location="http://localhost:9001/SOAPDocLitService/SoapPort"/>
         </wsdl:port>
     </wsdl:service>
+    <wsdl:service name="MultiTransportService">
+        <wsdl:port name="HttpPort" binding="tns:Greeter_SOAPBinding">
+            <soap:address location="http://localhost:9001/SOAPDocLitService/SoapPort"/>
+        </wsdl:port>
+        <wsdl:port name="JMSPort" binding="tns:Greeter_SOAPBinding">
+               <jms:address
+                   jndiConnectionFactoryName="ConnectionFactory"
+                   jndiDestinationName="dynamicQueues/routertest.MultiTransportServiceQ.text">
+                   <jms:JMSNamingProperty name="java.naming.factory.initial" value="org.apache.activemq.jndi.ActiveMQInitialContextFactory"/>
+                   <jms:JMSNamingProperty name="java.naming.provider.url" value="tcp://localhost:61500"/>
+               </jms:address>
+        </wsdl:port>
+    </wsdl:service>
+     
+
     <wsdl:service name="SOAPService2">
         <wsdl:port name="SoapPort2" binding="tns:Greeter_SOAPBinding">
                <jms:address



Mime
View raw message