cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r774462 - in /cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_wsdl: Server.java WSAPureWsdlTest.java
Date Wed, 13 May 2009 18:15:27 GMT
Author: dkulp
Date: Wed May 13 18:15:25 2009
New Revision: 774462

URL: http://svn.apache.org/viewvc?rev=774462&view=rev
Log:
Add a testcase for WS-Addressing with a Provider based service

Modified:
    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/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=774462&r1=774461&r2=774462&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:15:25 2009
@@ -19,7 +19,25 @@
 
 package org.apache.cxf.systest.ws.addr_wsdl;
 
+import java.io.StringReader;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.transform.Source;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.ws.Endpoint;
+import javax.xml.ws.Provider;
+import javax.xml.ws.Service.Mode;
+import javax.xml.ws.ServiceMode;
+import javax.xml.ws.WebServiceProvider;
+import javax.xml.xpath.XPathConstants;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
 import org.apache.cxf.BusFactory;
+import org.apache.cxf.helpers.XPathUtils;
 import org.apache.cxf.jaxws.EndpointImpl;
 import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
 
@@ -34,8 +52,9 @@
                                            null, 
                                            getWsdl());
 
-        //EndpointImpl ep = (EndpointImpl) Endpoint.create(implementor);
         ep.publish(address);
+        
+        Endpoint.publish(address + "-provider", new AddNumberProvider());
     }
     
     private String getWsdl() {
@@ -59,4 +78,31 @@
             System.out.println("done!");
         }
     }
+    
+    
+    @WebServiceProvider(serviceName = "AddNumbersService",
+                        targetNamespace = "http://apache.org/cxf/systest/ws/addr_feature/",
+                        wsdlLocation = "/wsdl_systest/add_numbers.wsdl")
+    @ServiceMode(Mode.PAYLOAD)
+    public static class AddNumberProvider implements Provider<Source> {
+
+        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);
+            
+            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=774462&r1=774461&r2=774462&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:15:25 2009
@@ -72,6 +72,26 @@
         assertTrue(input.toString().indexOf(expectedIn) != -1);
     }
     @Test
+    public void testProviderEndpoint() throws Exception {
+        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);
+    }
+
+    @Test
     public void testBasicDispatchInvocation() throws Exception {
         String req = "<addNumbers xmlns=\"http://apache.org/cxf/systest/ws/addr_feature/\">"
             + "<number1>1</number1><number2>2</number2></addNumbers>";



Mime
View raw message