cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject svn commit: r1413679 - in /cxf/branches/2.5.x-fixes: ./ rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/ContextUtils.java rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/ContextUtilsTest.java
Date Mon, 26 Nov 2012 15:23:43 GMT
Author: ay
Date: Mon Nov 26 15:23:40 2012
New Revision: 1413679

URL: http://svn.apache.org/viewvc?rev=1413679&view=rev
Log:
Merged revisions 1413664 via  svn merge from
https://svn.apache.org/repos/asf/cxf/branches/2.6.x-fixes

........
  r1413664 | ay | 2012-11-26 15:54:32 +0100 (Mon, 26 Nov 2012) | 9 lines
  
  Merged revisions 1412851 via  svn merge from
  https://svn.apache.org/repos/asf/cxf/trunk
  
  ........
    r1412851 | ay | 2012-11-23 13:06:57 +0100 (Fri, 23 Nov 2012) | 1 line
    
    [CXF-4647] A wrong soap action when using ws-addressing may lead to an empty response
or the wrong fault
  ........
  
........

Modified:
    cxf/branches/2.5.x-fixes/   (props changed)
    cxf/branches/2.5.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/ContextUtils.java
    cxf/branches/2.5.x-fixes/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/ContextUtilsTest.java

Propchange: cxf/branches/2.5.x-fixes/
            ('svn:mergeinfo' removed)

Propchange: cxf/branches/2.5.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.5.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/ContextUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/ContextUtils.java?rev=1413679&r1=1413678&r2=1413679&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/ContextUtils.java
(original)
+++ cxf/branches/2.5.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/ContextUtils.java
Mon Nov 26 15:23:40 2012
@@ -830,11 +830,17 @@ public final class ContextUtils {
         LOG.fine("Determining action");
         Exception fault = message.getContent(Exception.class);
 
+        if (fault instanceof Fault 
+            && Names.WSA_NAMESPACE_NAME.equals(((Fault)fault).getFaultCode().getNamespaceURI()))
{
+            // wsa relevant faults should use the wsa-fault action value
+            action = Names.WSA_DEFAULT_FAULT_ACTION;
+        } else {
+            action = getActionFromServiceModel(message, fault);    
+        }
         // REVISIT: add support for @{Fault}Action annotation (generated
         // from the wsaw:Action WSDL element). For the moment we just
         // pick up the wsaw:Action attribute by walking the WSDL model
         // directly 
-        action = getActionFromServiceModel(message, fault);
         LOG.fine("action: " + action);
         return action != null ? getAttributedURI(action) : null;
     }
@@ -883,6 +889,9 @@ public final class ContextUtils {
                 // http://www.w3.org/2005/02/addressing/wsdl schema
                 for (BindingFaultInfo bfi : bindingOpInfo.getFaults()) {
                     FaultInfo fi = bfi.getFaultInfo();
+                    if (fi.size() == 0) {
+                        continue;
+                    }
                     Class<?> fiTypeClass = fi.getMessagePart(0).getTypeClass();
                     if (t != null 
                             && fiTypeClass != null

Modified: cxf/branches/2.5.x-fixes/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/ContextUtilsTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/ContextUtilsTest.java?rev=1413679&r1=1413678&r2=1413679&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/ContextUtilsTest.java
(original)
+++ cxf/branches/2.5.x-fixes/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/ContextUtilsTest.java
Mon Nov 26 15:23:40 2012
@@ -26,7 +26,17 @@ import javax.xml.namespace.QName;
 
 import junit.framework.Assert;
 
+import org.apache.cxf.binding.soap.SoapBindingConstants;
+import org.apache.cxf.binding.soap.SoapFault;
+import org.apache.cxf.message.Exchange;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.service.model.BindingOperationInfo;
 import org.apache.cxf.service.model.Extensible;
+import org.apache.cxf.service.model.FaultInfo;
+import org.apache.cxf.service.model.MessageInfo;
+import org.apache.cxf.service.model.MessageInfo.Type;
+import org.apache.cxf.service.model.MessagePartInfo;
+import org.apache.cxf.service.model.OperationInfo;
 import org.easymock.EasyMock;
 import org.easymock.IMocksControl;
 
@@ -95,4 +105,92 @@ public class ContextUtilsTest extends As
         action = ContextUtils.getAction(ext);
         assertEquals(null, action);
     }
+    
+    @Test
+    public void testGetActionFromMessage() {
+        Message msg = control.createMock(Message.class);
+        Exchange exchange = control.createMock(Exchange.class);
+
+        QName mqname = new QName("http://foo.com", "bar");
+        QName fqname = new QName("urn:foo:test:4", "fault");
+        OperationInfo operationInfo = new OperationInfo();
+        MessageInfo messageInfo = new MessageInfo(operationInfo, Type.OUTPUT, mqname); 
+        messageInfo.addMessagePart(new MessagePartInfo(new QName("http://foo.com", "partInfo"),
null));
+        operationInfo.setOutput("outputName", messageInfo);
+        FaultInfo faultInfo = new FaultInfo(fqname, mqname, operationInfo);
+        operationInfo.addFault(faultInfo);
+        BindingOperationInfo boi = new BindingOperationInfo(null, operationInfo);
+
+        // test 1 : retrieving the normal action prop from the message
+        EasyMock.expect(msg.getExchange()).andReturn(exchange).anyTimes();
+        EasyMock.expect(exchange.get(BindingOperationInfo.class)).andReturn(boi);
+        EasyMock.expect(msg.get(ContextUtils.ACTION)).andReturn("urn:foo:test:1");
+        control.replay();
+        
+        AttributedURIType action = ContextUtils.getAction(msg);
+        assertNotNull(action);
+        assertEquals("urn:foo:test:1", action.getValue());
+        control.reset();
+
+        // test 2 : retrieving the normal soap action prop from the message
+        EasyMock.expect(msg.getExchange()).andReturn(exchange).anyTimes();
+        EasyMock.expect(exchange.get(BindingOperationInfo.class)).andReturn(boi);
+        EasyMock.expect(msg.get(SoapBindingConstants.SOAP_ACTION)).andReturn("urn:foo:test:2");
+        control.replay();
+        
+        action = ContextUtils.getAction(msg);
+        assertNotNull(action);
+        assertEquals("urn:foo:test:2", action.getValue());
+        control.reset();
+
+        // test 3 : retrieving the action prop from the message info
+        EasyMock.expect(msg.getExchange()).andReturn(exchange).anyTimes();
+        EasyMock.expect(exchange.get(BindingOperationInfo.class)).andReturn(boi);
+        messageInfo.setProperty(ContextUtils.ACTION, "urn:foo:test:3");
+        control.replay();
+        
+        action = ContextUtils.getAction(msg);
+        assertNotNull(action);
+        assertEquals("urn:foo:test:3", action.getValue());
+        control.reset();
+        
+        // test 4 : retrieving the action for a fault without message part
+        SoapFault fault = new SoapFault("faulty service", new RuntimeException(), fqname);
+        EasyMock.expect(msg.getExchange()).andReturn(exchange).anyTimes();
+        EasyMock.expect(msg.getContent(Exception.class)).andReturn(fault).anyTimes();
+        EasyMock.expect(exchange.get(BindingOperationInfo.class)).andReturn(boi);
+        control.replay();
+        
+        action = ContextUtils.getAction(msg);
+        assertNull(action);
+        control.reset();
+        
+        // test 5 : retrieving the action for a fault with matching message part
+        faultInfo.addMessagePart(new MessagePartInfo(new QName("http://foo.com", "faultInfo"),
null));
+        faultInfo.getMessagePart(0).setTypeClass(RuntimeException.class);
+        faultInfo.addExtensionAttribute(Names.WSAW_ACTION_QNAME, "urn:foo:test:4");
+        EasyMock.expect(msg.getExchange()).andReturn(exchange).anyTimes();
+        EasyMock.expect(msg.getContent(Exception.class)).andReturn(fault).anyTimes();
+        EasyMock.expect(exchange.get(BindingOperationInfo.class)).andReturn(boi);
+        control.replay();
+        
+        action = ContextUtils.getAction(msg);
+        assertNotNull(action);
+        assertEquals("urn:foo:test:4", action.getValue());
+        control.reset();
+
+        // test 6 : retrieving the action for a ws-addr fault with matching message part
+        fault = new SoapFault("Action Mismatch",
+                              new QName(Names.WSA_NAMESPACE_NAME,
+                                        Names.ACTION_MISMATCH_NAME));
+        EasyMock.expect(msg.getExchange()).andReturn(exchange).anyTimes();
+        EasyMock.expect(msg.getContent(Exception.class)).andReturn(fault).anyTimes();
+        EasyMock.expect(exchange.get(BindingOperationInfo.class)).andReturn(boi);
+        control.replay();
+        
+        action = ContextUtils.getAction(msg);
+        assertNotNull(action);
+        assertEquals(Names.WSA_DEFAULT_FAULT_ACTION, action.getValue());
+
+    }
 }



Mime
View raw message