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 2007/11/30 08:21:17 UTC

svn commit: r599709 - in /incubator/cxf/trunk: systests/src/test/java/org/apache/cxf/systest/nested_callback/ testutils/ testutils/src/main/resources/wsdl/

Author: mmao
Date: Thu Nov 29 23:21:15 2007
New Revision: 599709

URL: http://svn.apache.org/viewvc?rev=599709&view=rev
Log:
CXF-1239
 addition test for JAXBcontext when callback is used 
    but only reference to Endpoint reference is nested in a complex type

Thanks Gary for the patch


Added:
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/nested_callback/
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/nested_callback/CallbackClientServerTest.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/nested_callback/CallbackImpl.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/nested_callback/Server.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/nested_callback/ServerImpl.java
    incubator/cxf/trunk/testutils/src/main/resources/wsdl/nested_callback.wsdl
Modified:
    incubator/cxf/trunk/testutils/pom.xml

Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/nested_callback/CallbackClientServerTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/nested_callback/CallbackClientServerTest.java?rev=599709&view=auto
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/nested_callback/CallbackClientServerTest.java (added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/nested_callback/CallbackClientServerTest.java Thu Nov 29 23:21:15 2007
@@ -0,0 +1,90 @@
+/**
+ * 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.nested_callback;
+
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.Endpoint;
+
+import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
+import org.apache.cxf.ws.addressing.EndpointReferenceType;
+import org.apache.cxf.wsdl.EndpointReferenceUtils;
+import org.apache.nested_callback.NestedCallback;
+import org.apache.nested_callback.SOAPService;
+import org.apache.nested_callback.ServerPortType;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class CallbackClientServerTest extends AbstractBusClientServerTestBase {
+    private static final QName SERVICE_NAME 
+        = new QName("http://apache.org/nested_callback", "SOAPService");
+    private static final QName SERVICE_NAME_CALLBACK 
+        = new QName("http://apache.org/nested_callback", "CallbackService");
+
+    private static final QName PORT_NAME 
+        = new QName("http://apache.org/nested_callback", "SOAPPort");
+
+    private static final QName PORT_NAME_CALLBACK 
+        = new QName("http://apache.org/nested_callback", "CallbackPort");
+    
+    private static final QName PORT_TYPE_CALLBACK
+        = new QName("http://apache.org/nested_callback", "CallbackPortType");
+    
+    
+    @BeforeClass
+    public static void startServers() throws Exception {
+        assertTrue("server did not launch correctly", launchServer(Server.class));
+    }
+
+    @Test
+    public void testCallback() throws Exception {
+
+                    
+        Object implementor = new CallbackImpl();
+        String address = "http://localhost:9005/CallbackContext/NestedCallbackPort";
+        Endpoint.publish(address, implementor);
+    
+        URL wsdlURL = getClass().getResource("/wsdl/nested_callback.wsdl");
+    
+        SOAPService ss = new SOAPService(wsdlURL, SERVICE_NAME);
+        ServerPortType port = ss.getPort(PORT_NAME, ServerPortType.class);
+   
+        EndpointReferenceType ref = null;
+        try {
+            ref = EndpointReferenceUtils.getEndpointReference(wsdlURL, 
+                                                              SERVICE_NAME_CALLBACK, 
+                                                              PORT_NAME_CALLBACK.getLocalPart());
+            EndpointReferenceUtils.setInterfaceName(ref, PORT_TYPE_CALLBACK);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    
+        NestedCallback callbackObject = new NestedCallback();
+        callbackObject.setCallback(ref);
+        String resp = port.registerCallback(callbackObject);
+
+        assertEquals("registerCallback called", resp);
+            
+    }
+    
+    
+}

Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/nested_callback/CallbackImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/nested_callback/CallbackImpl.java?rev=599709&view=auto
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/nested_callback/CallbackImpl.java (added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/nested_callback/CallbackImpl.java Thu Nov 29 23:21:15 2007
@@ -0,0 +1,42 @@
+/**
+ * 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.nested_callback;
+
+import org.apache.callback.CallbackPortType;
+
+
+@javax.jws.WebService(serviceName = "CallbackService", 
+                      portName = "CallbackPort",
+                      endpointInterface = "org.apache.callback.CallbackPortType",
+                      targetNamespace = "http://apache.org/nested_callback", 
+                      wsdlLocation = "testutils/nested_callback.wsdl")
+                  
+public class CallbackImpl implements CallbackPortType  {
+
+    /**
+     * serverSayHi
+     * @param: return_message (String)
+     * @return: String
+     */
+    public String serverSayHi(String message) {
+        return new String("Hi " + message);
+    }
+    
+}

Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/nested_callback/Server.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/nested_callback/Server.java?rev=599709&view=auto
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/nested_callback/Server.java (added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/nested_callback/Server.java Thu Nov 29 23:21:15 2007
@@ -0,0 +1,47 @@
+/**
+ * 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.nested_callback;
+
+import javax.xml.ws.Endpoint;
+
+import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
+
+public class Server extends AbstractBusTestServerBase {
+
+    protected void run() {
+        Object implementor = new ServerImpl();
+        String address = "http://localhost:9007/SoapContext/SoapPort";
+        Endpoint.publish(address, implementor);
+        
+    }
+
+    public static void main(String[] args) {
+        try { 
+            Server s = new Server(); 
+            s.start();
+        } catch (Exception ex) {
+            ex.printStackTrace();
+            System.exit(-1);
+        } finally { 
+            System.out.println("done!");
+        }
+    }
+}

Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/nested_callback/ServerImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/nested_callback/ServerImpl.java?rev=599709&view=auto
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/nested_callback/ServerImpl.java (added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/nested_callback/ServerImpl.java Thu Nov 29 23:21:15 2007
@@ -0,0 +1,95 @@
+/**
+ * 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.nested_callback;
+
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+
+import org.apache.cxf.jaxb.JAXBUtils;
+import org.apache.cxf.ws.addressing.EndpointReferenceType;
+import org.apache.cxf.wsdl.EndpointReferenceUtils;
+import org.apache.cxf.wsdl.WSDLManager;
+import org.apache.cxf.wsdl11.WSDLManagerImpl;
+import org.apache.nested_callback.CallbackPortType;
+import org.apache.nested_callback.NestedCallback;
+import org.apache.nested_callback.ServerPortType;
+
+@javax.jws.WebService(serviceName = "SOAPService", 
+                      portName = "SOAPPort",
+                      targetNamespace = "http://apache.org/nested_callback",
+                      endpointInterface = "org.apache.nested_callback.ServerPortType",
+                      wsdlLocation = "testutils/nested_callback.wsdl") 
+                      
+                  
+public class ServerImpl implements ServerPortType  {
+    
+    public String foo(String s) {
+        return s;
+    }
+
+    public String registerCallback(NestedCallback callbackObject) {
+        try {
+            EndpointReferenceType callback = callbackObject.getCallback();
+            WSDLManager manager = new WSDLManagerImpl();
+        
+            QName interfaceName = EndpointReferenceUtils.getInterfaceName(callback);
+            String wsdlLocation = EndpointReferenceUtils.getWSDLLocation(callback);
+            QName serviceName = EndpointReferenceUtils.getServiceName(callback);
+
+            
+            String portString = EndpointReferenceUtils.getPortName(callback);
+            
+            QName portName = new QName(serviceName.getNamespaceURI(), portString);
+            
+            StringBuffer seiName = new StringBuffer();
+            seiName.append(JAXBUtils.namespaceURIToPackage(interfaceName.getNamespaceURI()));
+            seiName.append(".");
+            seiName.append(JAXBUtils.nameToIdentifier(interfaceName.getLocalPart(),
+                                                      JAXBUtils.IdentifierType.INTERFACE));
+            
+            Class<?> sei = null; 
+            try {
+                sei = Class.forName(seiName.toString(), 
+                                    true, manager.getClass().getClassLoader());
+            } catch (ClassNotFoundException ex) {
+                ex.printStackTrace();
+            }
+            
+            URL wsdlURL = new URL(wsdlLocation);            
+            Service service = Service.create(wsdlURL, serviceName);
+            CallbackPortType port =  (CallbackPortType)service.getPort(portName, sei);
+
+            port.serverSayHi("Sean");
+
+            
+        } catch (Exception ex) {
+            ex.printStackTrace();
+            return null;
+        }
+        
+        return "registerCallback called";     
+    }
+
+    
+        
+}    
\ No newline at end of file

Modified: incubator/cxf/trunk/testutils/pom.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/testutils/pom.xml?rev=599709&r1=599708&r2=599709&view=diff
==============================================================================
--- incubator/cxf/trunk/testutils/pom.xml (original)
+++ incubator/cxf/trunk/testutils/pom.xml Thu Nov 29 23:21:15 2007
@@ -269,7 +269,9 @@
                                 <wsdlOption>
                                     <wsdl>${basedir}/src/main/resources/wsdl/basic_callback_test.wsdl</wsdl>
                                 </wsdlOption>
-
+                                <wsdlOption>
+                                    <wsdl>${basedir}/src/main/resources/wsdl/nested_callback.wsdl</wsdl>
+                                </wsdlOption>
                                 <wsdlOption>
                                     <wsdl>
                                         ${basedir}/src/main/resources/wsdl/hello_world_underscore.wsdl

Added: incubator/cxf/trunk/testutils/src/main/resources/wsdl/nested_callback.wsdl
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/testutils/src/main/resources/wsdl/nested_callback.wsdl?rev=599709&view=auto
==============================================================================
--- incubator/cxf/trunk/testutils/src/main/resources/wsdl/nested_callback.wsdl (added)
+++ incubator/cxf/trunk/testutils/src/main/resources/wsdl/nested_callback.wsdl Thu Nov 29 23:21:15 2007
@@ -0,0 +1,106 @@
+<?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.
+-->
+
+<wsdl:definitions name="nested_callback" targetNamespace="http://apache.org/nested_callback"
+		  xmlns="http://schemas.xmlsoap.org/wsdl/" 
+		  xmlns:references="http://www.w3.org/2005/08/addressing" 
+		  xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
+		  xmlns:tns="http://apache.org/nested_callback" 
+		  xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
+		  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+		  xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" jaxb:version="2.0">
+    <wsdl:types> 
+
+	<schema targetNamespace="http://apache.org/nested_callback" 
+		xmlns="http://www.w3.org/2001/XMLSchema" 
+      	        xmlns:tns="http://apache.org/nested_callback" 
+		xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+		xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" 
+		jaxb:version="2.0"
+		elementFormDefault="qualified">
+
+	    <xsd:import namespace="http://www.w3.org/2005/08/addressing" schemaLocation="/schemas/wsdl/ws-addr.xsd"/>
+            <complexType name="NestedCallback">
+              <sequence>
+                <element name="name" type="xsd:string"/>
+                <element name="callback" type="references:EndpointReferenceType"/>
+              </sequence>
+            </complexType>
+            <element name="NestedCallback" type="tns:NestedCallback"/>
+	    <element name="callback_message" type="xsd:string"/>
+	    <element name="returnType" type="xsd:string"/>
+	</schema>
+    </wsdl:types>
+    <wsdl:message name="server_sayHi">
+	<wsdl:part element="tns:callback_message" name="return_message"/>
+    </wsdl:message>
+    <wsdl:message name="register_callback">
+	<wsdl:part element="tns:NestedCallback" name="callback_object"/>
+    </wsdl:message>
+    <wsdl:message name="returnMessage">
+	<wsdl:part element="tns:returnType" name="the_return"/>
+    </wsdl:message>
+    <wsdl:portType name="CallbackPortType">
+	<wsdl:operation name="ServerSayHi">
+	    <wsdl:input message="tns:server_sayHi" name="ServerSayHiRequest"/>
+	    <wsdl:output message="tns:returnMessage" name="ServerSayHiResponse"/>
+	</wsdl:operation>
+    </wsdl:portType>
+    <wsdl:portType name="ServerPortType">
+	<wsdl:operation name="RegisterCallback">
+	    <wsdl:input message="tns:register_callback" name="RegisterCallbackRequest"/>
+	    <wsdl:output message="tns:returnMessage" name="RegisterCallbackResponse"/>
+	</wsdl:operation>
+    </wsdl:portType>
+    <wsdl:binding name="CallbackPortType_SOAPBinding" type="tns:CallbackPortType">
+	<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+	<wsdl:operation name="ServerSayHi">
+	    <soap:operation soapAction="" style="document"/>
+	    <wsdl:input name="ServerSayHiRequest">
+		<soap:body use="literal"/>
+	    </wsdl:input>
+	    <wsdl:output name="ServerSayHiResponse">
+		<soap:body use="literal"/>
+	    </wsdl:output>
+	</wsdl:operation>
+    </wsdl:binding>
+    <wsdl:binding name="ServerPortType_SOAPBinding" type="tns:ServerPortType">
+	<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+	<wsdl:operation name="RegisterCallback">
+	    <soap:operation soapAction="" style="document"/>
+	    <wsdl:input name="RegisterCallbackRequest">
+		<soap:body use="literal"/>
+	    </wsdl:input>
+	    <wsdl:output name="RegisterCallbackResponse">
+		<soap:body use="literal"/>
+	    </wsdl:output>
+	</wsdl:operation>
+    </wsdl:binding>
+    <wsdl:service name="CallbackService">
+	<wsdl:port binding="tns:CallbackPortType_SOAPBinding" name="CallbackPort">
+	    <soap:address location="http://localhost:9005/CallbackContext/NestedCallbackPort"/>
+	</wsdl:port>
+    </wsdl:service>
+    <wsdl:service name="SOAPService">
+	<wsdl:port binding="tns:ServerPortType_SOAPBinding" name="SOAPPort">
+	    <soap:address location="http://localhost:9007/SoapContext/SoapPort"/>
+	</wsdl:port>
+    </wsdl:service>
+</wsdl:definitions>