Author: nagy
Date: Fri Mar  5 21:14:01 2010
New Revision: 919621

URL: http://svn.apache.org/viewvc?rev=919621&view=rev
Log:
Added new tests to verify the RespectBindingFeature JAX-WS API functionality. 

Contributor: Roy Wood

Modified:
    
axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/AddressingProviderTests.java
    
axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/addressing/AddressingProvider.java
    
axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/addressing/META-INF/AddressingProvider.wsdl

Modified: 
axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/AddressingProviderTests.java
URL: 
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/AddressingProviderTests.java?rev=919621&r1=919620&r2=919621&view=diff
==============================================================================
--- 
axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/AddressingProviderTests.java
 (original)
+++ 
axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/AddressingProviderTests.java
 Fri Mar  5 21:14:01 2010
@@ -31,11 +31,14 @@
 import javax.xml.soap.SOAPBody;
 import javax.xml.soap.SOAPElement;
 import javax.xml.soap.SOAPMessage;
+
+import org.apache.axis2.jaxws.spi.Binding;
 import javax.xml.ws.BindingProvider;
 import javax.xml.ws.Dispatch;
 import javax.xml.ws.Service;
 import javax.xml.ws.WebServiceFeature;
 import javax.xml.ws.soap.AddressingFeature;
+import javax.xml.ws.RespectBindingFeature;
 
 import junit.framework.Test;
 import junit.framework.TestSuite;
@@ -130,6 +133,51 @@
         System.out.println(response.toString());
     }
     
+    /**
+     * Message already contains wsa headers. Make sure there is no mismatch 
between 
+     * SOAPAction and wsa:Action. 
+     */
+    public void testWithRespectBinding() throws Exception {
+
+        Dispatch<SOAPMessage> dispatch = createDispatchWithRespectBinding();
+             
+        BindingProvider bp = (BindingProvider) dispatch;
+        Binding binding = (Binding) bp.getBinding();
+
+        WebServiceFeature addressingFeature = 
binding.getFeature(AddressingFeature.ID);
+        assertNotNull(addressingFeature);
+        assertTrue("Expecting AddressingFeature to be enabled.", 
addressingFeature.isEnabled());
+        
+        WebServiceFeature respectBindingFeature = 
binding.getFeature(RespectBindingFeature.ID);
+        assertNotNull(respectBindingFeature);
+        assertTrue("Expecting RespectBindingFeature to be enabled.", 
respectBindingFeature.isEnabled());
+        
+        bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, 
endpointUrl);
+
+        String msg = MessageFormat.format(SOAP_MESSAGE_2, 
+                                          endpointUrl,
+                                          "urn:" + UUID.randomUUID(),
+                                          ACTION);
+        
+        System.out.println(msg);
+        
+        MessageFactory factory = MessageFactory.newInstance();
+        SOAPMessage request = factory.createMessage(null, new 
ByteArrayInputStream(msg.getBytes()));
+                        
+        SOAPMessage response = dispatch.invoke(request);
+                     
+        assertResponseXML(response, "Hello Response");
+        
+        System.out.println(response.toString());
+        
+        // Try again to verify
+        response = dispatch.invoke(request);
+        
+        assertResponseXML(response, "Hello Response");
+        
+        System.out.println(response.toString());
+    }
+    
     private SOAPElement assertResponseXML(SOAPMessage msg, String 
expectedText) throws Exception {
         assertTrue(msg != null);
         SOAPBody body = msg.getSOAPBody();
@@ -163,6 +211,19 @@
         return dispatch;
     }
     
+    private Dispatch<SOAPMessage> createDispatchWithRespectBinding() throws 
Exception {
+        URL wsdlURL = getWsdl();
+        assertNotNull(wsdlURL);
+        Service svc = Service.create(wsdlURL, serviceName);
+        
+        WebServiceFeature[] wsf = {new AddressingFeature(true), new 
RespectBindingFeature(true)};
+        
+        Dispatch<SOAPMessage> dispatch =
+            svc.createDispatch(portName, SOAPMessage.class, 
Service.Mode.MESSAGE, wsf);
+        
+        return dispatch;
+    }
+    
     private URL getWsdl() throws Exception {
         String wsdlLocation = 
"/test/org/apache/axis2/jaxws/provider/addressing/META-INF/AddressingProvider.wsdl";
         String baseDir = new 
File(System.getProperty("basedir",".")).getCanonicalPath();

Modified: 
axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/addressing/AddressingProvider.java
URL: 
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/addressing/AddressingProvider.java?rev=919621&r1=919620&r2=919621&view=diff
==============================================================================
--- 
axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/addressing/AddressingProvider.java
 (original)
+++ 
axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/addressing/AddressingProvider.java
 Fri Mar  5 21:14:01 2010
@@ -29,6 +29,7 @@
 import javax.xml.ws.ServiceMode;
 import javax.xml.ws.WebServiceProvider;
 import javax.xml.ws.soap.Addressing;
+import javax.xml.ws.RespectBinding;
 import javax.xml.ws.soap.SOAPBinding;
 import javax.xml.ws.soap.SOAPFaultException;
 
@@ -38,6 +39,7 @@
                    portName="AddressingProviderPort")
 @BindingType(SOAPBinding.SOAP11HTTP_BINDING)
 @Addressing(enabled=true)
+...@respectbinding
 @ServiceMode(value=Service.Mode.MESSAGE)
 public class AddressingProvider implements Provider<SOAPMessage> {
       

Modified: 
axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/addressing/META-INF/AddressingProvider.wsdl
URL: 
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/addressing/META-INF/AddressingProvider.wsdl?rev=919621&r1=919620&r2=919621&view=diff
==============================================================================
--- 
axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/addressing/META-INF/AddressingProvider.wsdl
 (original)
+++ 
axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/addressing/META-INF/AddressingProvider.wsdl
 Fri Mar  5 21:14:01 2010
@@ -25,6 +25,8 @@
     xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"; 
     xmlns:s="http://www.w3.org/2001/XMLSchema"; 
     xmlns:tns="http://addressing.provider.jaxws.axis2.apache.org";
+    xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl";
+    
     targetNamespace="http://addressing.provider.jaxws.axis2.apache.org";
     xmlns="http://schemas.xmlsoap.org/wsdl/";>
   <types>
@@ -65,6 +67,8 @@
         <soap:body use="literal" />
       </output>
     </operation>
+      <wsaw:UsingAddressing required="true" /> 
+    
   </binding>
 
   <service name="AddressingProviderService">


Reply via email to