You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by mm...@apache.org on 2006/10/30 09:26:49 UTC

svn commit: r469089 [2/2] - in /incubator/cxf/trunk: api/src/main/java/org/apache/cxf/message/ api/src/main/java/org/apache/cxf/phase/ common/common/src/main/java/org/apache/cxf/common/util/ common/common/src/test/java/org/apache/cxf/common/util/ rt/bi...

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerTest.java?view=diff&rev=469089&r1=469088&r2=469089
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerTest.java (original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerTest.java Mon Oct 30 00:26:47 2006
@@ -19,8 +19,11 @@
 
 package org.apache.cxf.systest.jaxws;
 
+import java.io.InputStream;
 import java.lang.reflect.UndeclaredThrowableException;
+import java.net.HttpURLConnection;
 import java.net.URL;
+import java.util.HashMap;
 import java.util.Map;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.ExecutorService;
@@ -33,10 +36,17 @@
 import javax.xml.ws.Endpoint;
 import javax.xml.ws.Response;
 import javax.xml.ws.Service;
+import javax.xml.xpath.XPathConstants;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
 
 import junit.framework.Test;
 import junit.framework.TestSuite;
 
+import org.apache.cxf.binding.soap.Soap11;
+import org.apache.cxf.helpers.XMLUtils;
+import org.apache.cxf.helpers.XPathUtils;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.systest.common.ClientServerSetupBase;
 import org.apache.cxf.systest.common.ClientServerTestBase;
@@ -462,8 +472,67 @@
                 assertEquals("BadRecordLitFault", brlf.getFaultInfo());
             }
         }
-    } 
+    }
+    
+    public void testGetSayHi() throws Exception {
+        HttpURLConnection httpConnection = 
+            getHttpConnection("http://localhost:9000/SoapContext/SoapPort/sayHi");    
+        httpConnection.connect(); 
+        
+        httpConnection.connect();
+        
+        assertEquals(200, httpConnection.getResponseCode());
+        
+        assertEquals("text/xml", httpConnection.getContentType());
+        assertEquals("OK", httpConnection.getResponseMessage());
+        
+        InputStream in = httpConnection.getInputStream();
+        assertNotNull(in);        
+       
+        Document doc = XMLUtils.parse(in);
+        assertNotNull(doc);
+        
+        Map<String, String> ns = new HashMap<String, String>();
+        ns.put("soap", Soap11.SOAP_NAMESPACE);
+        ns.put("ns2", "http://apache.org/hello_world_soap_http/types");
+        XPathUtils xu = new XPathUtils(ns);
+        Node body = (Node) xu.getValue("/soap:Envelope/soap:Body", doc, XPathConstants.NODE);
+        assertNotNull(body);
+        String response = (String) xu.getValue("//ns2:sayHiResponse/ns2:responseType/text()", 
+                                               body, 
+                                               XPathConstants.STRING);
+        assertEquals("Bonjour", response);
+    }
 
+    public void testGetGreetMe() throws Exception {
+        HttpURLConnection httpConnection = 
+            getHttpConnection("http://localhost:9000/SoapContext/SoapPort/greetMe/me/cxf");    
+        httpConnection.connect();        
+        
+        assertEquals(200, httpConnection.getResponseCode());
+    
+        assertEquals("text/xml", httpConnection.getContentType());
+        assertEquals("OK", httpConnection.getResponseMessage());
+        
+        InputStream in = httpConnection.getInputStream();
+        assertNotNull(in);
+        
+        Document doc = XMLUtils.parse(in);
+        assertNotNull(doc);
+        
+        Map<String, String> ns = new HashMap<String, String>();
+        ns.put("soap", Soap11.SOAP_NAMESPACE);
+        ns.put("ns2", "http://apache.org/hello_world_soap_http/types");
+        XPathUtils xu = new XPathUtils(ns);
+        Node body = (Node) xu.getValue("/soap:Envelope/soap:Body", doc, XPathConstants.NODE);
+        assertNotNull(body);
+        String response = (String) xu.getValue("//ns2:greetMeResponse/ns2:responseType/text()", 
+                                               body, 
+                                               XPathConstants.STRING);
+        // TODO:wrong return type, should Hello cxf
+        assertEquals("Hello null", response);
+    }
+    
     public static void main(String[] args) {
         junit.textui.TestRunner.run(ClientServerTest.class);
     }

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerXMLBareTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerXMLBareTest.java?view=diff&rev=469089&r1=469088&r2=469089
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerXMLBareTest.java (original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerXMLBareTest.java Mon Oct 30 00:26:47 2006
@@ -19,23 +19,32 @@
 
 package org.apache.cxf.systest.jaxws;
 
+import java.io.InputStream;
 import java.lang.reflect.UndeclaredThrowableException;
+import java.net.HttpURLConnection;
+import java.util.HashMap;
+import java.util.Map;
 
 import javax.xml.namespace.QName;
 import javax.xml.ws.Endpoint;
+import javax.xml.xpath.XPathConstants;
+
+import org.w3c.dom.Document;
 
 import junit.framework.Test;
-import junit.framework.TestCase;
 import junit.framework.TestSuite;
 
+import org.apache.cxf.helpers.XMLUtils;
+import org.apache.cxf.helpers.XPathUtils;
 import org.apache.cxf.systest.common.ClientServerSetupBase;
+import org.apache.cxf.systest.common.ClientServerTestBase;
 import org.apache.cxf.systest.common.TestServerBase;
 import org.apache.hello_world_xml_http.bare.Greeter;
 import org.apache.hello_world_xml_http.bare.GreeterImpl;
 import org.apache.hello_world_xml_http.bare.XMLService;
 import org.apache.hello_world_xml_http.bare.types.MyComplexStructType;
 
-public class ClientServerXMLBareTest extends TestCase {
+public class ClientServerXMLBareTest extends ClientServerTestBase {
 
     private final QName portName = new QName("http://apache.org/hello_world_xml_http/bare", "XMLPort");
 
@@ -106,6 +115,31 @@
         } catch (UndeclaredThrowableException ex) {
             throw (Exception) ex.getCause();
         }
+    }
+    
+    public void testGetGreetMe() throws Exception {
+        HttpURLConnection httpConnection = 
+            getHttpConnection("http://localhost:9031/XMLService/XMLPort/greetMe/me/cxf");    
+        httpConnection.connect();        
+        
+        assertEquals(200, httpConnection.getResponseCode());
+    
+        assertEquals("text/xml", httpConnection.getContentType());
+        assertEquals("OK", httpConnection.getResponseMessage());
+        
+        InputStream in = httpConnection.getInputStream();
+        assertNotNull(in);
+        
+        Document doc = XMLUtils.parse(in);
+        assertNotNull(doc);
+        
+        Map<String, String> ns = new HashMap<String, String>();       
+        ns.put("ns2", "http://apache.org/hello_world_xml_http/bare/types");
+        XPathUtils xu = new XPathUtils(ns);        
+        String response = (String) xu.getValue("//ns2:responseType/text()", 
+                                               doc, 
+                                               XPathConstants.STRING);
+        assertEquals("Hello cxf", response);
     }
 
 }

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/soap12/Soap12ClientServerTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/soap12/Soap12ClientServerTest.java?view=diff&rev=469089&r1=469088&r2=469089
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/soap12/Soap12ClientServerTest.java (original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/soap12/Soap12ClientServerTest.java Mon Oct 30 00:26:47 2006
@@ -21,12 +21,24 @@
 
 package org.apache.cxf.systest.soap12;
 
+import java.io.InputStream;
+import java.net.HttpURLConnection;
 import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
 
 import javax.xml.namespace.QName;
+import javax.xml.xpath.XPathConstants;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
 
 import junit.framework.Test;
 import junit.framework.TestSuite;
+
+import org.apache.cxf.binding.soap.Soap12;
+import org.apache.cxf.helpers.XMLUtils;
+import org.apache.cxf.helpers.XPathUtils;
 import org.apache.cxf.systest.common.ClientServerSetupBase;
 import org.apache.cxf.systest.common.ClientServerTestBase;
 import org.apache.hello_world_soap12_http.Greeter;
@@ -47,7 +59,6 @@
                 assertTrue("server did not launch correctly", launchServer(Server.class));
             }
         };
-        
     }
 
     public void testBasicConnection() throws Exception {
@@ -71,6 +82,101 @@
             assertEquals("PingMeFault raised by server", ex.getMessage());            
         }
     }
+    
+    public void testGetSayHi() throws Exception {
+        HttpURLConnection httpConnection = 
+            getHttpConnection("http://localhost:9012/SoapContext/SoapPort/sayHi");    
+        httpConnection.connect();        
+        
+        InputStream in = httpConnection.getInputStream();        
+        assertNotNull(in);
+        assertEquals("application/soap+xml", httpConnection.getContentType());
+       
+        Document doc = XMLUtils.parse(in);
+        assertNotNull(doc);
+        Map<String, String> ns = new HashMap<String, String>();
+        ns.put("soap12", Soap12.SOAP_NAMESPACE);
+        ns.put("ns2", "http://apache.org/hello_world_soap12_http/types");
+        XPathUtils xu = new XPathUtils(ns);
+        Node body = (Node) xu.getValue("/soap12:Envelope/soap12:Body", doc, XPathConstants.NODE);
+        assertNotNull(body);
+        String response = (String) xu.getValue("//ns2:sayHiResponse/ns2:responseType/text()", 
+                                               body, 
+                                               XPathConstants.STRING);
+        assertEquals("Bonjour", response);
+    }
+
+    public void testGetPingMe() throws Exception  {
+        HttpURLConnection httpConnection = 
+            getHttpConnection("http://localhost:9012/SoapContext/SoapPort/pingMe");    
+        httpConnection.connect();
+        
+        assertEquals(500, httpConnection.getResponseCode());
+        
+        assertEquals("Fault+Occurred", httpConnection.getResponseMessage());
+
+        InputStream in = httpConnection.getErrorStream();                  
+        assertNotNull(in);     
+        assertEquals("application/soap+xml", httpConnection.getContentType());
+        
+        Document doc = XMLUtils.parse(in);
+        assertNotNull(doc);        
+
+        Map<String, String> ns = new HashMap<String, String>();
+        ns.put("s", Soap12.SOAP_NAMESPACE);
+        ns.put("ns2", "http://apache.org/hello_world_soap12_http/types");
+        XPathUtils xu = new XPathUtils(ns);
+        String codeValue  = (String) xu.getValue("/s:Envelope/s:Body/s:Fault/s:Code/s:Value/text()", 
+                                                 doc, 
+                                                 XPathConstants.STRING);
+       
+        assertEquals("soap:Receiver", codeValue);
+        String reason = (String) xu.getValue("//s:Reason//text()", 
+                                             doc, 
+                                             XPathConstants.STRING);
+        assertEquals("PingMeFault raised by server", reason);
+        
+        String minor = (String) xu.getValue("//s:Detail//ns2:faultDetail/ns2:minor/text()", 
+                                               doc, 
+                                               XPathConstants.STRING);
+        assertEquals("1", minor);
+        String major = (String) xu.getValue("//s:Detail//ns2:faultDetail/ns2:major/text()", 
+                                            doc, 
+                                            XPathConstants.STRING);
+        assertEquals("2", major);
+    }
+    
+    public void testGetMethodNotExist() throws Exception  {
+        HttpURLConnection httpConnection = 
+            getHttpConnection("http://localhost:9012/SoapContext/SoapPort/greetMe");
+        httpConnection.connect();
+        
+        assertEquals(500, httpConnection.getResponseCode());
+
+        assertEquals("application/soap+xml", httpConnection.getContentType());
+        
+        assertEquals("Fault+Occurred", httpConnection.getResponseMessage());
+
+        InputStream in = httpConnection.getErrorStream();                  
+        assertNotNull(in);        
+            
+        Document doc = XMLUtils.parse(in);
+        assertNotNull(doc);
+        Map<String, String> ns = new HashMap<String, String>();
+        ns.put("s", Soap12.SOAP_NAMESPACE);
+        ns.put("ns2", "http://apache.org/hello_world_soap12_http/types");
+        XPathUtils xu = new XPathUtils(ns);
+        String codeValue  = (String) xu.getValue("/s:Envelope/s:Body/s:Fault/s:Code/s:Value/text()", 
+                                                 doc, 
+                                                 XPathConstants.STRING);
+       
+        assertEquals("soap:Receiver", codeValue);
+        String reason = (String) xu.getValue("//s:Reason//text()", 
+                                             doc, 
+                                             XPathConstants.STRING);
+        assertEquals("No such operation: greetMe", reason);        
+    }
+    
 
     private Greeter getGreeter() {
         URL wsdl = getClass().getResource("/wsdl/hello_world_soap12.wsdl");
@@ -78,9 +184,8 @@
 
         SOAPService service = new SOAPService(wsdl, serviceName);
         assertNotNull("Service is ull ", service);
-
-        return service.getPort(portName,
-                               Greeter.class);
+        
+        return service.getPort(portName, Greeter.class);
     }
 
     public static void main(String[] args) {

Modified: incubator/cxf/trunk/testutils/pom.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/testutils/pom.xml?view=diff&rev=469089&r1=469088&r2=469089
==============================================================================
--- incubator/cxf/trunk/testutils/pom.xml (original)
+++ incubator/cxf/trunk/testutils/pom.xml Mon Oct 30 00:26:47 2006
@@ -303,6 +303,10 @@
                                 <wsdlOption>
                                     <wsdl>${basedir}/src/main/resources/wsdl/addNumbers.wsdl</wsdl>
                                 </wsdlOption>
+                                <wsdlOption>
+                                    <wsdl>${basedir}/src/main/resources/wsdl/calculator.wsdl</wsdl>
+                                </wsdlOption>
+
                             </wsdlOptions>
                         </configuration>
                         <goals>

Added: incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/calculator/CalculatorImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/calculator/CalculatorImpl.java?view=auto&rev=469089
==============================================================================
--- incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/calculator/CalculatorImpl.java (added)
+++ incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/calculator/CalculatorImpl.java Mon Oct 30 00:26:47 2006
@@ -0,0 +1,41 @@
+/**
+ * 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.calculator;
+
+import javax.jws.WebService;
+
+import org.apache.cxf.calculator.types.CalculatorFault;
+
+@WebService(serviceName = "CalculatorService", 
+            portName = "CalculatorPort", 
+            targetNamespace = "http://apache.org/cxf/calculator", 
+            endpointInterface = "org.apache.cxf.calculator.CalculatorPortType")
+public class CalculatorImpl implements CalculatorPortType {
+    public int add(int number1, int number2) throws AddNumbersFault {
+        if (number1 < 0 || number2 < 0) {
+            CalculatorFault fault = new CalculatorFault();
+            fault.setMessage("Negative number cant be added!");
+            fault.setFaultInfo("Numbers: " + number1 + ", " + number2);
+            throw new AddNumbersFault("Negative number cant be added!", fault);
+        }
+        return number1 + number2;
+    }
+
+}

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

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

Added: incubator/cxf/trunk/testutils/src/main/resources/wsdl/calculator.wsdl
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/testutils/src/main/resources/wsdl/calculator.wsdl?view=auto&rev=469089
==============================================================================
--- incubator/cxf/trunk/testutils/src/main/resources/wsdl/calculator.wsdl (added)
+++ incubator/cxf/trunk/testutils/src/main/resources/wsdl/calculator.wsdl Mon Oct 30 00:26:47 2006
@@ -0,0 +1,94 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+
+<definitions name="Calculator"  
+	     targetNamespace="http://apache.org/cxf/calculator"
+	     xmlns:tns="http://apache.org/cxf/calculator"
+	     xmlns="http://schemas.xmlsoap.org/wsdl/" 
+	     xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+	     xmlns:x1="http://apache.org/cxf/calculator/types"
+	     xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/">
+    <types>
+	<xsd:schema xmlns="http://www.w3.org/2001/XMLSchema" 
+		    elementFormDefault="qualified" 
+		    targetNamespace="http://apache.org/cxf/calculator/types">
+
+	    <complexType name="addNumbersResponse">
+		<sequence>
+		    <element name="return" type="xsd:int" />
+		</sequence>
+	    </complexType>
+	    <element name="addNumbersResponse" type="x1:addNumbersResponse" />
+
+	    <complexType name="addNumbers">
+		<sequence>
+		    <element name="arg0" type="xsd:int" />
+		    <element name="arg1" type="xsd:int" />
+		</sequence>
+	    </complexType>
+	    <element name="add" type="x1:addNumbers" />
+
+	    <element name="CalculatorFault" type="x1:CalculatorFault" />
+	    <complexType name="CalculatorFault">
+		<sequence>
+		    <element name="faultInfo" type="xsd:string" />
+		    <element name="message" type="xsd:string" />
+		</sequence>
+	    </complexType>
+	</xsd:schema>
+    </types>
+    <message name="add">
+	<part name="parameters" element="x1:add" />
+    </message>
+    <message name="addNumbersResponse">
+	<part name="result" element="x1:addNumbersResponse" />
+    </message>
+    <message name="addNumbersFault">
+	<part name="CalculatorFault" element="x1:CalculatorFault" />
+    </message>
+    <portType name="CalculatorPortType">
+	<operation name="add">
+	    <input message="tns:add"/>
+	    <output message="tns:addNumbersResponse"/>
+	    <fault name="addNumbersFault" message="tns:addNumbersFault"/>
+	</operation>
+    </portType>
+
+    <binding name="CalculatorBinding" type="tns:CalculatorPortType">
+	<soap12:binding transport="http://www.w3.org/2003/05/soap/bindings/HTTP/" style="document" />
+	<operation name="add">
+	    <soap12:operation soapAction="" />
+	    <input>
+		<soap12:body use="literal" />
+	    </input>
+	    <output>
+		<soap12:body use="literal" />
+	    </output>
+	    <fault name="addNumbersFault">
+		<soap12:fault name="addNumbersFault" use="literal" />
+	    </fault>
+	</operation>
+    </binding>
+    <service name="CalculatorService">
+	<port name="CalculatorPort" binding="tns:CalculatorBinding">
+	    <soap12:address location="http://localhost:9000/CalculatorService/SoapPort" />
+	</port>
+    </service>
+</definitions>
\ No newline at end of file

Propchange: incubator/cxf/trunk/testutils/src/main/resources/wsdl/calculator.wsdl
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/testutils/src/main/resources/wsdl/calculator.wsdl
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: incubator/cxf/trunk/testutils/src/main/resources/wsdl/calculator.wsdl
------------------------------------------------------------------------------
    svn:mime-type = text/xml