cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r774480 - in /cxf/trunk: rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/context/ systests/src/test/java/org/apache/cxf/systest/ws/addr_wsdl/
Date Wed, 13 May 2009 18:33:34 GMT
Author: dkulp
Date: Wed May 13 18:33:28 2009
New Revision: 774480

URL: http://svn.apache.org/viewvc?rev=774480&view=rev
Log:
[CXF-1591] Add testcase for non-wsdl based provider

Modified:
    cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/context/WrappedMessageContext.java
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_wsdl/Server.java
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_wsdl/WSAPureWsdlTest.java

Modified: cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/context/WrappedMessageContext.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/context/WrappedMessageContext.java?rev=774480&r1=774479&r2=774480&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/context/WrappedMessageContext.java
(original)
+++ cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/context/WrappedMessageContext.java
Wed May 13 18:33:28 2009
@@ -377,6 +377,12 @@
             authPolicy.setPassword((String)value);
         } else if (MessageContext.HTTP_REQUEST_HEADERS.equals(key)) {
             ret = message.put(Message.PROTOCOL_HEADERS, value);
+        } else if (SoapBindingConstants.SOAP_ACTION.equals(mappedKey)
+            && !isRequestor()) {
+            Message tmp = createResponseMessage();
+            if (tmp != null) {
+                tmp.put(mappedKey, value);
+            }
         } else {
             ret = message.put(mappedKey, value);
         }

Modified: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_wsdl/Server.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_wsdl/Server.java?rev=774480&r1=774479&r2=774480&view=diff
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_wsdl/Server.java (original)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_wsdl/Server.java Wed May
13 18:33:28 2009
@@ -23,14 +23,18 @@
 import java.util.HashMap;
 import java.util.Map;
 
+import javax.annotation.Resource;
 import javax.xml.transform.Source;
 import javax.xml.transform.dom.DOMSource;
 import javax.xml.transform.stream.StreamSource;
+import javax.xml.ws.BindingProvider;
 import javax.xml.ws.Endpoint;
 import javax.xml.ws.Provider;
+import javax.xml.ws.WebServiceContext;
 import javax.xml.ws.Service.Mode;
 import javax.xml.ws.ServiceMode;
 import javax.xml.ws.WebServiceProvider;
+import javax.xml.ws.soap.Addressing;
 import javax.xml.xpath.XPathConstants;
 
 import org.w3c.dom.Document;
@@ -55,6 +59,7 @@
         ep.publish(address);
         
         Endpoint.publish(address + "-provider", new AddNumberProvider());
+        Endpoint.publish(address + "-providernows", new AddNumberProviderNoWsdl());
     }
     
     private String getWsdl() {
@@ -103,6 +108,37 @@
                 + "<return>" + (i + i2) + "</return></addNumbersResponse>";
             return new StreamSource(new StringReader(resp));
         }
+    }
+
+    @WebServiceProvider(serviceName = "AddNumbersService",
+                        targetNamespace = "http://apache.org/cxf/systest/ws/addr_feature/")
+    @ServiceMode(Mode.PAYLOAD)
+    @Addressing(enabled = true, required = true)
+    public static class AddNumberProviderNoWsdl implements Provider<Source> {
+        @Resource
+        WebServiceContext ctx;
         
+        public Source invoke(Source obj) {
+            //CHECK the incoming
+            DOMSource ds = (DOMSource)obj;
+            
+            Element el = ((Document)ds.getNode()).getDocumentElement();
+            Map<String, String> ns = new HashMap<String, String>();
+            ns.put("ns", "http://apache.org/cxf/systest/ws/addr_feature/");
+            XPathUtils xp = new XPathUtils(ns);
+            String o = (String)xp.getValue("/ns:addNumbers/ns:number1", el, XPathConstants.STRING);
+            String o2 = (String)xp.getValue("/ns:addNumbers/ns:number2", el, XPathConstants.STRING);
+            int i = Integer.parseInt(o);
+            int i2 = Integer.parseInt(o2);
+            
+            
+            ctx.getMessageContext()
+                .put(BindingProvider.SOAPACTION_URI_PROPERTY,
+                    "http://apache.org/cxf/systest/ws/addr_feature/AddNumbersPortType/addNumbersResponse");
+
+            String resp = "<addNumbersResponse xmlns=\"http://apache.org/cxf/systest/ws/addr_feature/\">"
+                + "<return>" + (i + i2) + "</return></addNumbersResponse>";
+            return new StreamSource(new StringReader(resp));
+        }
     }
 }

Modified: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_wsdl/WSAPureWsdlTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_wsdl/WSAPureWsdlTest.java?rev=774480&r1=774479&r2=774480&view=diff
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_wsdl/WSAPureWsdlTest.java
(original)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_wsdl/WSAPureWsdlTest.java
Wed May 13 18:33:28 2009
@@ -49,7 +49,7 @@
 
     @BeforeClass
     public static void startServers() throws Exception {
-        assertTrue("server did not launch correctly", launchServer(Server.class));
+        assertTrue("server did not launch correctly", launchServer(Server.class, true));
     }
 
     @Test
@@ -73,19 +73,28 @@
     }
     @Test
     public void testProviderEndpoint() throws Exception {
+        String base = "http://apache.org/cxf/systest/ws/addr_feature/AddNumbersPortType/";
+        String expectedOut = base + "addNumbersRequest</Action>";
+        String expectedIn = base + "addNumbersResponse</Action>";
+
         ByteArrayOutputStream input = setupInLogging();
         ByteArrayOutputStream output = setupOutLogging();
 
         AddNumbersPortType port = getPort();
-
         ((BindingProvider)port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,

                                                         "http://localhost:9094/jaxws/add-provider");
-
         assertEquals(3, port.addNumbers(1, 2));
 
-        String base = "http://apache.org/cxf/systest/ws/addr_feature/AddNumbersPortType/";
-        String expectedOut = base + "addNumbersRequest</Action>";
-        String expectedIn = base + "addNumbersResponse</Action>";
+
+        assertTrue(output.toString().indexOf(expectedOut) != -1);
+        assertTrue(input.toString().indexOf(expectedIn) != -1);
+
+        output.reset();
+        input.reset();
+        
+        ((BindingProvider)port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,

+            "http://localhost:9094/jaxws/add-providernows");
+        assertEquals(3, port.addNumbers(1, 2));
 
         assertTrue(output.toString().indexOf(expectedOut) != -1);
         assertTrue(input.toString().indexOf(expectedIn) != -1);



Mime
View raw message