cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dval...@apache.org
Subject svn commit: r1044127 - in /cxf/branches/2.3.x-fixes: ./ rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/ rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/ rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/
Date Thu, 09 Dec 2010 21:03:05 GMT
Author: dvaleri
Date: Thu Dec  9 21:03:05 2010
New Revision: 1044127

URL: http://svn.apache.org/viewvc?rev=1044127&view=rev
Log:
Merged revisions 1044085 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1044085 | dvaleri | 2010-12-09 13:55:43 -0500 (Thu, 09 Dec 2010) | 1 line
  
  [CXF-3062] Added enforcement for the presence of the MessageId MAP in Req/Resp MEP.  Added
inclusion of RelatesTo MAP when MessageId is missing in request.
........

Modified:
    cxf/branches/2.3.x-fixes/   (props changed)
    cxf/branches/2.3.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/MAPAggregator.java
    cxf/branches/2.3.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/Names.java
    cxf/branches/2.3.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/MAPCodec.java
    cxf/branches/2.3.x-fixes/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/MAPAggregatorTest.java

Propchange: cxf/branches/2.3.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Dec  9 21:03:05 2010
@@ -1 +1 @@
-/cxf/trunk:1041183,1041790,1041993,1042346,1042571,1042724,1042805,1042821,1043225,1043229,1043902,1043907,1043954
+/cxf/trunk:1041183,1041790,1041993,1042346,1042571,1042724,1042805,1042821,1043225,1043229,1043902,1043907,1043954,1044085

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

Modified: cxf/branches/2.3.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/MAPAggregator.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/MAPAggregator.java?rev=1044127&r1=1044126&r2=1044127&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/MAPAggregator.java
(original)
+++ cxf/branches/2.3.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/MAPAggregator.java
Thu Dec  9 21:03:05 2010
@@ -945,6 +945,9 @@ public class MAPAggregator extends Abstr
                 && !Boolean.TRUE.equals(message.get(Message.PARTIAL_RESPONSE_MESSAGE)))
{
                 String inMessageID = inMAPs.getMessageID().getValue();
                 maps.setRelatesTo(ContextUtils.getRelatesTo(inMessageID));
+            } else {
+                maps.setRelatesTo(ContextUtils
+                                  .getRelatesTo(Names.WSA_UNSPECIFIED_RELATIONSHIP));
             }
 
             // fallback fault action
@@ -1164,9 +1167,10 @@ public class MAPAggregator extends Abstr
                 ContextUtils.storeMAPFaultName(Names.HEADER_REQUIRED_NAME,
                                                message);
                 ContextUtils.storeMAPFaultReason(reason, message);
-                return false;
+                valid = false;
             }
-            if (s != null && s.size() > 0) {
+            
+            if (s != null && s.size() > 0 && valid) {
                 String sa = s.get(0);
                 if (sa.startsWith("\"")) {
                     sa = sa.substring(1, sa.lastIndexOf('"'));
@@ -1181,7 +1185,7 @@ public class MAPAggregator extends Abstr
                     ContextUtils.storeMAPFaultName(Names.ACTION_MISMATCH_NAME,
                                                    message);
                     ContextUtils.storeMAPFaultReason(reason, message);
-                    return false;
+                    valid = false;
                 } else if (!StringUtils.isEmpty(s1)
                     && !action.equals(s1)
                     && !action.equals(s1 + "Request")
@@ -1198,19 +1202,37 @@ public class MAPAggregator extends Abstr
                     ContextUtils.storeMAPFaultName(Names.ACTION_NOT_SUPPORTED_NAME,
                                                    message);
                     ContextUtils.storeMAPFaultReason(reason, message);
-                    return false;
+                    valid = false;
                 }
-                
             }
             
+            AttributedURIType messageID = maps.getMessageID();
+            
+            if (!message.getExchange().isOneWay() 
+                    && (messageID == null || messageID.getValue() == null)
+                    && valid) {
+                String reason =
+                    BUNDLE.getString("MISSING_ACTION_MESSAGE");
+
+                ContextUtils.storeMAPFaultName(Names.HEADER_REQUIRED_NAME,
+                                               message);
+                ContextUtils.storeMAPFaultReason(reason, message);
+                
+                valid = false;
+            }
         
-            if (!allowDuplicates) {
-                AttributedURIType messageID = maps.getMessageID();
-                if (messageID != null
-                    && !messageIdCache.checkUniquenessAndCacheId(messageID.getValue()))
{
-                    LOG.log(Level.WARNING,
-                            "DUPLICATE_MESSAGE_ID_MSG",
-                            messageID.getValue());
+            // Always cache message IDs, even when the message is not valid for some
+            // other reason.
+            if (!allowDuplicates && messageID != null && messageID.getValue()
!= null
+                && !messageIdCache.checkUniquenessAndCacheId(messageID.getValue()))
{
+
+                LOG.log(Level.WARNING,
+                        "DUPLICATE_MESSAGE_ID_MSG",
+                        messageID.getValue());
+                
+                // Only throw the fault if something else has not already marked the
+                // message as invalid.
+                if (valid) {
                     String reason =
                         BUNDLE.getString("DUPLICATE_MESSAGE_ID_MSG");
                     String l7dReason = 
@@ -1218,8 +1240,9 @@ public class MAPAggregator extends Abstr
                     ContextUtils.storeMAPFaultName(Names.DUPLICATE_MESSAGE_ID_NAME,
                                                    message);
                     ContextUtils.storeMAPFaultReason(l7dReason, message);
-                    valid = false;
                 }
+                
+                valid = false;
             }
         } else if (usingAddressingAdvisory) {
             String reason =
@@ -1228,8 +1251,9 @@ public class MAPAggregator extends Abstr
             ContextUtils.storeMAPFaultName(Names.HEADER_REQUIRED_NAME,
                                            message);
             ContextUtils.storeMAPFaultReason(reason, message);
-            return false;
+            valid = false;
         }
+        
         return valid;
     }
 }

Modified: cxf/branches/2.3.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/Names.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/Names.java?rev=1044127&r1=1044126&r2=1044127&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/Names.java
(original)
+++ cxf/branches/2.3.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/Names.java
Thu Dec  9 21:03:05 2010
@@ -103,6 +103,9 @@ public final class Names {
         WSA_NAMESPACE_NAME + "/anonymous";
     public static final String WSA_NONE_ADDRESS =
         WSA_NAMESPACE_NAME + "/none";
+    
+    public static final String WSA_UNSPECIFIED_RELATIONSHIP =
+        WSA_NAMESPACE_NAME + "/unspecified";
 
     public static final String WSA_FAULT_DELIMITER =
         "/fault";

Modified: cxf/branches/2.3.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/MAPCodec.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/MAPCodec.java?rev=1044127&r1=1044126&r2=1044127&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/MAPCodec.java
(original)
+++ cxf/branches/2.3.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/MAPCodec.java
Thu Dec  9 21:03:05 2010
@@ -788,6 +788,7 @@ public class MAPCodec extends AbstractSo
     private void restoreExchange(SoapMessage message, AddressingProperties maps) {
         if (maps != null
             && maps.getRelatesTo() != null
+            && !Names.WSA_UNSPECIFIED_RELATIONSHIP.equals(maps.getRelatesTo().getValue())
             && isRelationshipReply(maps.getRelatesTo())) { 
             Exchange correlatedExchange =
                 uncorrelatedExchanges.remove(maps.getRelatesTo().getValue());
@@ -834,7 +835,10 @@ public class MAPCodec extends AbstractSo
      * @param message the current message
      */
     private void markPartialResponse(SoapMessage message, AddressingProperties maps) {
-        if (ContextUtils.isRequestor(message) && null != maps && null ==
maps.getRelatesTo()) {
+        if (ContextUtils.isRequestor(message) && null != maps
+            && (null == maps.getRelatesTo() 
+                || (null != maps.getRelatesTo()
+                    && Names.WSA_UNSPECIFIED_RELATIONSHIP.equals(maps.getRelatesTo().getValue()))))
{
             message.put(Message.PARTIAL_RESPONSE_MESSAGE, Boolean.TRUE);
         } 
     }

Modified: cxf/branches/2.3.x-fixes/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/MAPAggregatorTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/MAPAggregatorTest.java?rev=1044127&r1=1044126&r2=1044127&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/MAPAggregatorTest.java
(original)
+++ cxf/branches/2.3.x-fixes/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/MAPAggregatorTest.java
Thu Dec  9 21:03:05 2010
@@ -268,6 +268,46 @@ public class MAPAggregatorTest extends A
         control.verify();
         verifyMessage(message, false, false, false /*check*/);
     }
+    
+    @Test(expected = SoapFault.class)
+    public void testResponderInboundInvalidMAPsNoMessageIdReqResp() throws Exception {
+        SetupMessageArgs args = new SetupMessageArgs();
+        args.requestor = false;
+        args.outbound = false;
+        args.oneway = false;
+        args.usingAddressing = false;
+        args.mapsInContext = false;
+        args.decoupled = false;
+        args.zeroLengthAction = true;
+        args.fault = false;
+        args.noMessageId = true;
+        
+        Message message = setUpMessage(args);
+        aggregator.setAllowDuplicates(false);
+        aggregator.mediate(message, true);
+        control.verify();
+        verifyMessage(message, false, false, false /*check*/);
+    }
+    
+    @Test()
+    public void testResponderInboundNoMessageIdOneWay() throws Exception {
+        SetupMessageArgs args = new SetupMessageArgs();
+        args.requestor = false;
+        args.outbound = false;
+        args.oneway = true;
+        args.usingAddressing = false;
+        args.mapsInContext = false;
+        args.decoupled = false;
+        args.zeroLengthAction = true;
+        args.fault = false;
+        args.noMessageId = true;
+        
+        Message message = setUpMessage(args);
+        aggregator.setAllowDuplicates(false);
+        aggregator.mediate(message, true);
+        control.verify();
+        verifyMessage(message, false, false, false /*check*/);
+    }
 
     @Test
     public void testResponderOutbound() throws Exception {
@@ -285,18 +325,42 @@ public class MAPAggregatorTest extends A
         control.verify();
         verifyMessage(message, false, true, true);
     }
+    
+    @Test
+    public void testResponderOutboundNoMessageId() throws Exception {
+        SetupMessageArgs args = new SetupMessageArgs();
+        args.requestor = false;
+        args.outbound = true;
+        args.oneway = false;
+        args.usingAddressing = false;
+        args.mapsInContext = false;
+        args.decoupled = false;
+        args.zeroLengthAction = false;
+        args.fault = false;
+        args.noMessageId = true;
+        
+        Message message = 
+            setUpMessage(args);
+        aggregator.mediate(message, false);
+        control.verify();
+        verifyMessage(message, false, true, true);
+    }
 
     @Test
     public void testResponderOutboundFault() throws Exception {
-        Message message = setUpMessage(new boolean[] {false,
-                                                      true,
-                                                      false,
-                                                      false,
-                                                      false,
-                                                      true,
-                                                      false,
-                                                      true});
+        SetupMessageArgs args = new SetupMessageArgs();
+        args.requestor = false;
+        args.outbound = true;
+        args.oneway = false;
+        args.usingAddressing = false;
+        args.mapsInContext = false;
+        args.decoupled = true;
+        args.zeroLengthAction = false;
+        args.fault = true;
+        args.noMessageId = false;
         
+        Message message = setUpMessage(args);
+                
         aggregator.mediate(message, true);
         control.verify();
         verifyMessage(message, false, true, true);
@@ -439,59 +503,55 @@ public class MAPAggregatorTest extends A
                                  boolean decoupled,
                                  boolean zeroLengthAction) 
         throws Exception {
-        boolean[] params = {requestor, 
-                            outbound,
-                            oneway,
-                            usingAddressing,
-                            mapsInContext,
-                            decoupled,
-                            zeroLengthAction,
-                            false};  
-        return setUpMessage(params);
+        
+        SetupMessageArgs args = new SetupMessageArgs();
+        args.requestor = requestor;
+        args.outbound = outbound;
+        args.oneway = oneway;
+        args.usingAddressing = usingAddressing;
+        args.mapsInContext = mapsInContext;
+        args.decoupled = decoupled;
+        args.zeroLengthAction = zeroLengthAction;
+        args.fault = false;
+        args.noMessageId = false;
+        
+        return setUpMessage(args);
     }
 
-    /**
-     * Boolean array is used to work around checkstyle rule limiting
-     * parameter cardinality to 7. 
-     */
-    private Message setUpMessage(boolean[] params)
+    private Message setUpMessage(SetupMessageArgs args)
         throws Exception {
-        boolean requestor = params[0]; 
-        boolean outbound = params[1];
-        boolean oneway = params[2];
-        boolean usingAddressing = params[3];
-        boolean mapsInContext = params[4];
-        boolean decoupled = params[5];
-        boolean zeroLengthAction = params[6];
-        boolean fault = params[7];
         
         Message message = getMessage();        
         Exchange exchange = getExchange();
-        setUpOutbound(message, exchange, outbound, fault);
+        setUpOutbound(message, exchange, args.outbound, args.fault);
         setUpMessageProperty(message,
                              REQUESTOR_ROLE,
-                             Boolean.valueOf(requestor));
-        if (outbound && requestor) {
-            if (usingAddressing) {
+                             Boolean.valueOf(args.requestor));
+        if (args.outbound && args.requestor) {
+            if (args.usingAddressing) {
                 setUpConduit(message, exchange);
             }
-            setUpUsingAddressing(message, exchange, usingAddressing);
-            if (usingAddressing) {
+            setUpUsingAddressing(message, exchange, args.usingAddressing);
+            if (args.usingAddressing) {
                 setUpRequestor(message,
                                exchange,
-                               oneway, 
-                               mapsInContext,
-                               decoupled,
-                               zeroLengthAction);
+                               args.oneway, 
+                               args.mapsInContext,
+                               args.decoupled,
+                               args.zeroLengthAction);
             } 
-        } else if (!requestor) {
+        } else if (!args.requestor) {
+            SetupResponderArgs srArgs = new SetupResponderArgs();
+            srArgs.oneway = args.oneway;
+            srArgs.outbound = args.outbound;
+            srArgs.decoupled = args.decoupled;
+            srArgs.zeroLengthAction = args.zeroLengthAction;
+            srArgs.fault = args.fault;
+            srArgs.noMessageId = args.noMessageId;
+            
             setUpResponder(message,
                            exchange,
-                           oneway,
-                           outbound,
-                           decoupled,
-                           zeroLengthAction,
-                           fault);
+                           srArgs);
             
             Endpoint endpoint = control.createMock(Endpoint.class);
             endpoint.getOutInterceptors();
@@ -593,52 +653,54 @@ public class MAPAggregatorTest extends A
 
     private void setUpResponder(Message message,
                                 Exchange exchange,
-                                boolean oneway,
-                                boolean outbound,
-                                boolean decoupled,
-                                boolean zeroLengthAction,
-                                boolean fault) throws Exception {
+                                SetupResponderArgs args) throws Exception {
+
         setUpMessageProperty(message,
                              REQUESTOR_ROLE,
                              Boolean.FALSE);
         AddressingPropertiesImpl maps = new AddressingPropertiesImpl();
         EndpointReferenceType replyTo = new EndpointReferenceType();
         replyTo.setAddress(
-            ContextUtils.getAttributedURI(decoupled
+            ContextUtils.getAttributedURI(args.decoupled
                                           ? "http://localhost:9999/decoupled"
                                           : Names.WSA_ANONYMOUS_ADDRESS));
         maps.setReplyTo(replyTo);
         EndpointReferenceType faultTo = new EndpointReferenceType();
         faultTo.setAddress(
-            ContextUtils.getAttributedURI(decoupled
+            ContextUtils.getAttributedURI(args.decoupled
                                           ? "http://localhost:9999/fault"
                                           : Names.WSA_ANONYMOUS_ADDRESS));
         maps.setFaultTo(faultTo);
-        AttributedURIType id = 
-            ContextUtils.getAttributedURI("urn:uuid:12345");
-        maps.setMessageID(id);
-        if (zeroLengthAction) {
+        
+        if (!args.noMessageId) {
+            AttributedURIType id = 
+                ContextUtils.getAttributedURI("urn:uuid:12345");
+            maps.setMessageID(id);
+        }
+        
+        if (args.zeroLengthAction) {
             maps.setAction(ContextUtils.getAttributedURI(""));
         }
         setUpMessageProperty(message,
                              SERVER_ADDRESSING_PROPERTIES_INBOUND,
                              maps);
-        if (!outbound) {
-            setUpOneway(message, exchange, oneway);
-            if (oneway || decoupled) {
+        if (!args.outbound) {
+            setUpOneway(message, exchange, args.oneway);
+            if (args.oneway || args.decoupled) {
                 setUpRebase(message, exchange);
             }
         }
-        if (outbound || ((DefaultMessageIdCache) aggregator.getMessageIdCache())
+        
+        if (args.outbound || ((DefaultMessageIdCache) aggregator.getMessageIdCache())
             .getMessageIdSet().size() > 0) {
-            if (!zeroLengthAction) {
+            if (!args.zeroLengthAction) {
                 Method method = SEI.class.getMethod("op", new Class[0]);
                 setUpMethod(message, exchange, method);
                 setUpMessageProperty(message,
                                      REQUESTOR_ROLE,
                                      Boolean.FALSE);
                 
-                if (fault) {
+                if (args.fault) {
                     message.setContent(Exception.class, new SoapFault("blah",
                             (Throwable) new Exception(), Fault.FAULT_CODE_SERVER));
                     expectedAction = "http://foo/bar/SEI/op/Fault/Exception";
@@ -652,16 +714,21 @@ public class MAPAggregatorTest extends A
             setUpMessageProperty(message,
                                  SERVER_ADDRESSING_PROPERTIES_INBOUND,
                                  maps);            
-            if (fault) {
+            if (args.fault) {
                 // REVISIT test double rebase does not occur
                 setUpRebase(message, exchange);
             }
-            expectedTo = decoupled
-                         ? fault
+            expectedTo = args.decoupled
+                         ? args.fault
                            ? "http://localhost:9999/fault"
                            : "http://localhost:9999/decoupled"
                          : Names.WSA_ANONYMOUS_ADDRESS;
-            expectedRelatesTo = maps.getMessageID().getValue();
+            
+            if (maps.getMessageID() != null && maps.getMessageID().getValue() !=
null) {
+                expectedRelatesTo = maps.getMessageID().getValue();
+            } else {
+                expectedRelatesTo = Names.WSA_UNSPECIFIED_RELATIONSHIP;
+            }
             // Now verified via verifyMessage()
             //EasyMock.eq(SERVER_ADDRESSING_PROPERTIES_OUTBOUND);
             //EasyMock.reportMatcher(new MAPMatcher());
@@ -786,7 +853,7 @@ public class MAPAggregatorTest extends A
 
     private void setUpExchangeOneway(Exchange exchange, boolean oneway) {
         exchange.isOneWay();
-        EasyMock.expectLastCall().andReturn(oneway);
+        EasyMock.expectLastCall().andReturn(oneway).anyTimes();
         //exchange.setOneWay(oneway);
     }
 
@@ -903,4 +970,25 @@ public class MAPAggregatorTest extends A
             return Collections.unmodifiableCollection(this.faults.values());
         }        
     }
+    
+    private static class SetupMessageArgs {
+        boolean requestor; 
+        boolean outbound;
+        boolean oneway;
+        boolean usingAddressing;
+        boolean mapsInContext;
+        boolean decoupled;
+        boolean zeroLengthAction;
+        boolean fault;
+        boolean noMessageId; 
+    }
+    
+    private static class SetupResponderArgs {
+        boolean outbound; 
+        boolean oneway;
+        boolean decoupled;
+        boolean zeroLengthAction;
+        boolean fault;
+        boolean noMessageId;
+    }
 }



Mime
View raw message