Return-Path: X-Original-To: apmail-cxf-commits-archive@www.apache.org Delivered-To: apmail-cxf-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5D98CE1EA for ; Mon, 26 Nov 2012 14:54:59 +0000 (UTC) Received: (qmail 78561 invoked by uid 500); 26 Nov 2012 14:54:59 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 78428 invoked by uid 500); 26 Nov 2012 14:54:58 -0000 Mailing-List: contact commits-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list commits@cxf.apache.org Received: (qmail 78391 invoked by uid 99); 26 Nov 2012 14:54:57 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 26 Nov 2012 14:54:57 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 26 Nov 2012 14:54:54 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 31E9E2388900; Mon, 26 Nov 2012 14:54:33 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1413664 - in /cxf/branches/2.6.x-fixes: ./ rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/impl/InternalContextUtils.java rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/impl/ContextUtilsTest.java Date: Mon, 26 Nov 2012 14:54:32 -0000 To: commits@cxf.apache.org From: ay@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20121126145433.31E9E2388900@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: ay Date: Mon Nov 26 14:54:32 2012 New Revision: 1413664 URL: http://svn.apache.org/viewvc?rev=1413664&view=rev Log: 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.6.x-fixes/ (props changed) cxf/branches/2.6.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/impl/InternalContextUtils.java cxf/branches/2.6.x-fixes/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/impl/ContextUtilsTest.java Propchange: cxf/branches/2.6.x-fixes/ ('svn:mergeinfo' removed) Propchange: cxf/branches/2.6.x-fixes/ ------------------------------------------------------------------------------ Binary property 'svnmerge-integrated' - no diff available. Modified: cxf/branches/2.6.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/impl/InternalContextUtils.java URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/impl/InternalContextUtils.java?rev=1413664&r1=1413663&r2=1413664&view=diff ============================================================================== --- cxf/branches/2.6.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/impl/InternalContextUtils.java (original) +++ cxf/branches/2.6.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/impl/InternalContextUtils.java Mon Nov 26 14:54:32 2012 @@ -365,11 +365,17 @@ final class InternalContextUtils { 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 ? ContextUtils.getAttributedURI(action) : null; } @@ -418,6 +424,9 @@ final class InternalContextUtils { // 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.6.x-fixes/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/impl/ContextUtilsTest.java URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/impl/ContextUtilsTest.java?rev=1413664&r1=1413663&r2=1413664&view=diff ============================================================================== --- cxf/branches/2.6.x-fixes/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/impl/ContextUtilsTest.java (original) +++ cxf/branches/2.6.x-fixes/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/impl/ContextUtilsTest.java Mon Nov 26 14:54:32 2012 @@ -26,7 +26,19 @@ 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.apache.cxf.ws.addressing.AttributedURIType; +import org.apache.cxf.ws.addressing.ContextUtils; import org.apache.cxf.ws.addressing.JAXWSAConstants; import org.apache.cxf.ws.addressing.Names; import org.easymock.EasyMock; @@ -97,4 +109,92 @@ public class ContextUtilsTest extends As action = InternalContextUtils.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 = InternalContextUtils.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 = InternalContextUtils.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 = InternalContextUtils.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 = InternalContextUtils.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 = InternalContextUtils.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 = InternalContextUtils.getAction(msg); + assertNotNull(action); + assertEquals(Names.WSA_DEFAULT_FAULT_ACTION, action.getValue()); + + } }