cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From egl...@apache.org
Subject svn commit: r763931 - in /cxf/trunk/rt/ws/addr/src: main/java/org/apache/cxf/ws/addressing/VersionTransformer.java main/java/org/apache/cxf/ws/addressing/soap/MAPCodec.java test/java/org/apache/cxf/ws/addressing/soap/MAPCodecTest.java
Date Fri, 10 Apr 2009 13:36:23 GMT
Author: eglynn
Date: Fri Apr 10 13:36:22 2009
New Revision: 763931

URL: http://svn.apache.org/viewvc?rev=763931&view=rev
Log:
Commited patch for CXF-2167 on behalf of Andrew Dinn. Added unit test coverage also.

Modified:
    cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/VersionTransformer.java
    cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/MAPCodec.java
    cxf/trunk/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/soap/MAPCodecTest.java

Modified: cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/VersionTransformer.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/VersionTransformer.java?rev=763931&r1=763930&r2=763931&view=diff
==============================================================================
--- cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/VersionTransformer.java
(original)
+++ cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/VersionTransformer.java
Fri Apr 10 13:36:22 2009
@@ -425,7 +425,7 @@
             QName exposedRelationshipType = exposed.getRelationshipType();
             if (exposedRelationshipType != null) {
                 String internalRelationshipType = 
-                    Names.WSA_REPLY_NAME.equals(
+                    Names.WSA_REPLY_NAME.equalsIgnoreCase(
                                       exposedRelationshipType.getLocalPart())
                     ? Names.WSA_RELATIONSHIP_REPLY
                     : exposedRelationshipType.toString();

Modified: cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/MAPCodec.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/MAPCodec.java?rev=763931&r1=763930&r2=763931&view=diff
==============================================================================
--- cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/MAPCodec.java (original)
+++ cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/MAPCodec.java Fri
Apr 10 13:36:22 2009
@@ -733,7 +733,9 @@
      * @param maps the addressing properties
      */
     private void restoreExchange(SoapMessage message, AddressingProperties maps) {
-        if (maps != null && maps.getRelatesTo() != null) {
+        if (maps != null
+            && maps.getRelatesTo() != null
+            && isRelationshipReply(maps.getRelatesTo())) { 
             Exchange correlatedExchange =
                 uncorrelatedExchanges.remove(maps.getRelatesTo().getValue());
             if (correlatedExchange != null) {
@@ -763,6 +765,14 @@
         
     }
 
+    /** 
+     * @param relatesTo the current RelatesTo
+     * @return true iff the relationship type is reply
+     */
+    private boolean isRelationshipReply(RelatesToType relatesTo) {
+        return Names.WSA_RELATIONSHIP_REPLY.equals(relatesTo.getRelationshipType());
+    }
+ 
     /**
      * Marks a message as partial response
      * 

Modified: cxf/trunk/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/soap/MAPCodecTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/soap/MAPCodecTest.java?rev=763931&r1=763930&r2=763931&view=diff
==============================================================================
--- cxf/trunk/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/soap/MAPCodecTest.java
(original)
+++ cxf/trunk/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/soap/MAPCodecTest.java
Fri Apr 10 13:36:22 2009
@@ -79,6 +79,7 @@
     private Map<String, List<String>> mimeHeaders;
     private Exchange correlatedExchange;
     private boolean expectRelatesTo;
+    private String nonReplyRelationship;
     private boolean expectFaultTo;
     
     @Before
@@ -97,6 +98,7 @@
         mimeHeaders = null;
         correlatedExchange = null;
         ContextUtils.setJAXBContext(null);
+        nonReplyRelationship = null;
     }
 
     @Test
@@ -244,6 +246,25 @@
         verifyMessage(message, true, false, false);
     }
 
+    @Test
+    public void testRequestorInboundNonReply() throws Exception {
+        nonReplyRelationship = "wsat:correlatedOneway";
+        SoapMessage message = setUpMessage(true, false);
+        codec.handleMessage(message);
+        control.verify();
+        verifyMessage(message, true, false, true);
+    }
+
+    @Test
+    public void testRequestorInboundNonNativeNonReply() throws Exception {
+        nonReplyRelationship = "wsat:correlatedOneway";
+        String uri = VersionTransformer.Names200408.WSA_NAMESPACE_NAME;
+        SoapMessage message = setUpMessage(true, false, false, false, uri);
+        codec.handleMessage(message);
+        control.verify();
+        verifyMessage(message, true, false, false);
+    }
+
     private SoapMessage setUpMessage(boolean requestor, boolean outbound) throws Exception
{
         return setUpMessage(requestor, outbound, false);
     }
@@ -435,8 +456,12 @@
             relatesTo = new RelatesToType();
             relatesTo.setValue(correlationID);
             maps.setRelatesTo(relatesTo);
-            correlatedExchange = new ExchangeImpl();
-            codec.uncorrelatedExchanges.put(correlationID, correlatedExchange);
+            if (nonReplyRelationship == null) {
+                correlatedExchange = new ExchangeImpl();
+                codec.uncorrelatedExchanges.put(correlationID, correlatedExchange);
+            } else {
+                relatesTo.setRelationshipType(nonReplyRelationship);
+            }
         }
         AttributedURIType action = ContextUtils.getAttributedURI("http://foo/bar/SEI/opRequest");
         maps.setAction(action);
@@ -646,16 +671,25 @@
             if (outbound) {
                 String id = expectedValues[1] instanceof AttributedURIType
                     ? ((AttributedURIType)expectedValues[1]).getValue()
-                    : expectedValues[0] instanceof AttributedURI ? ((AttributedURI)expectedValues[1])
-                        .getValue() : ((org.apache.cxf.ws.addressing.v200403.AttributedURI)expectedValues[1])
-                        .getValue();
-                // assertTrue("expected correlationID : " + id + " in map: " +
-                // codec.uncorrelatedExchanges,
-                // codec.uncorrelatedExchanges.containsKey(id));
-                assertSame("unexpected correlated exchange", codec.uncorrelatedExchanges.get(id),
message
-                    .getExchange());
+                    : expectedValues[0] instanceof AttributedURI 
+                      ? ((AttributedURI)expectedValues[1]).getValue() 
+                      : ((org.apache.cxf.ws.addressing.v200403.AttributedURI)expectedValues[1]).getValue();
+                assertSame("unexpected correlated exchange", 
+                           codec.uncorrelatedExchanges.get(id), 
+                           message.getExchange());
             } else {
-                assertSame("unexpected correlated exchange", correlatedExchange, message.getExchange());
+                if (isReply(exposedAsNative)) {
+                    assertSame("unexpected correlated exchange", 
+                               correlatedExchange, 
+                               message.getExchange());
+                } else {
+                    assertNotSame("unexpected correlated exchange",
+                                  correlatedExchange,
+                                  message.getExchange());
+                }
+                assertEquals("expected empty uncorrelated exchange cache",
+                             0, 
+                             codec.uncorrelatedExchanges.size());
             }
         }
         if (outbound) {
@@ -674,6 +708,24 @@
             }
         }
         assertTrue("unexpected MAPs", verifyMAPs(message.get(getMAPProperty(requestor, outbound))));
+    }
+
+    private boolean isReply(boolean exposedAsNative) {
+        boolean isReply = false;
+        if (exposedAsNative) {
+            isReply = 
+                Names.WSA_RELATIONSHIP_REPLY.equals(
+                    ((RelatesToType)expectedValues[4]).getRelationshipType());
+        } else {
+            QName relationship = 
+                expectedValues[4] instanceof Relationship
+                ? ((Relationship)expectedValues[4]).getRelationshipType()
+                : ((org.apache.cxf.ws.addressing.v200403.Relationship)expectedValues[4])
+                      .getRelationshipType();
+            isReply = relationship == null 
+                      || Names.WSA_REPLY_NAME.equalsIgnoreCase(relationship.getLocalPart());
+        } 
 
+        return isReply;
     }
 }



Mime
View raw message