cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject git commit: [CXF-5741]:The properties in the requestContext are not copied into RMClient
Date Wed, 14 May 2014 05:23:20 GMT
Repository: cxf
Updated Branches:
  refs/heads/2.7.x-fixes 78bb7e5f4 -> 849272170


[CXF-5741]:The properties in the requestContext are not copied into RMClient


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/84927217
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/84927217
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/84927217

Branch: refs/heads/2.7.x-fixes
Commit: 849272170debf5f4c1466e52a685dfc5d3add2ed
Parents: 78bb7e5
Author: Jim Ma <ema@apache.org>
Authored: Wed May 14 09:26:50 2014 +0800
Committer: Jim Ma <ema@apache.org>
Committed: Wed May 14 12:16:26 2014 +0800

----------------------------------------------------------------------
 .../src/main/java/org/apache/cxf/ws/rm/Proxy.java  | 17 ++++++++---------
 .../main/java/org/apache/cxf/ws/rm/RMManager.java  | 10 +++++++++-
 .../test/java/org/apache/cxf/ws/rm/ProxyTest.java  | 15 +++++++++------
 .../java/org/apache/cxf/ws/rm/RMManagerTest.java   |  8 +++++++-
 4 files changed, 33 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/84927217/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/Proxy.java
----------------------------------------------------------------------
diff --git a/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/Proxy.java b/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/Proxy.java
index a6b2742..e8d3889 100644
--- a/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/Proxy.java
+++ b/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/Proxy.java
@@ -112,11 +112,9 @@ public class Proxy {
        
     }
 
-    public CreateSequenceResponseType createSequence(
-                        EndpointReferenceType defaultAcksTo,
-                        RelatesToType relatesTo,
-                        boolean isServer, final ProtocolVariation protocol) throws RMException
{
-        
+    public CreateSequenceResponseType createSequence(EndpointReferenceType defaultAcksTo,
RelatesToType relatesTo, 
+             boolean isServer, final ProtocolVariation protocol, final Map<String, Object>
context) 
+        throws RMException {
         SourcePolicyType sp = reliableEndpoint.getManager().getSourcePolicy();
         CreateSequenceType create = new CreateSequenceType();        
 
@@ -179,9 +177,7 @@ public class Proxy {
             ex.execute(r);
             return null;
         }
-        
-        
-        Object resp = invoke(oi, protocol, new Object[] {send}, null);
+        Object resp = invoke(oi, protocol, new Object[] {send}, context);
         return codec.convertReceivedCreateSequenceResponse(resp);
     }
     
@@ -285,6 +281,9 @@ public class Proxy {
         
         BindingOperationInfo boi = bi.getOperation(oi);
         try {
+            if (context != null) {
+                client.getRequestContext().putAll(context);
+            }
             Object[] result = client.invoke(boi, params, context);
             if (result != null && result.length > 0) {
                 return result[0];
@@ -345,4 +344,4 @@ public class Proxy {
     void setReliableEndpoint(RMEndpoint rme) {
         reliableEndpoint = rme;
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/84927217/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMManager.java
----------------------------------------------------------------------
diff --git a/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMManager.java b/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMManager.java
index bd3961c..6368fee 100644
--- a/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMManager.java
+++ b/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMManager.java
@@ -445,8 +445,16 @@ public class RMManager {
                 throw new RMException(msg);
             }
             Proxy proxy = source.getReliableEndpoint().getProxy();
+            Map<String, Object> context = new HashMap<String, Object>(16);
+            for (String key : message.keySet()) {
+                //copy other properties?
+                if (key.startsWith("ws-security")) {
+                    context.put(key, message.getContextualProperty(key));               
  
+                }
+            }
+            
             CreateSequenceResponseType createResponse = 
-                proxy.createSequence(acksTo, relatesTo, isServer, protocol);
+                proxy.createSequence(acksTo, relatesTo, isServer, protocol, context);
             if (!isServer) {
                 Servant servant = source.getReliableEndpoint().getServant();
                 servant.createSequenceResponse(createResponse, protocol);

http://git-wip-us.apache.org/repos/asf/cxf/blob/84927217/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/ProxyTest.java
----------------------------------------------------------------------
diff --git a/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/ProxyTest.java b/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/ProxyTest.java
index f43d5b9..a7eb60b 100644
--- a/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/ProxyTest.java
+++ b/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/ProxyTest.java
@@ -48,6 +48,7 @@ import org.apache.cxf.ws.rm.v200702.Identifier;
 import org.apache.cxf.ws.rm.v200702.OfferType;
 import org.easymock.EasyMock;
 import org.easymock.IMocksControl;
+
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
@@ -268,13 +269,14 @@ public class ProxyTest extends Assert {
         BindingOperationInfo boi = control.createMock(BindingOperationInfo.class);
         EasyMock.expect(bi.getOperation(oi)).andReturn(boi).anyTimes();
         Client client = control.createMock(Client.class);
+        EasyMock.expect(client.getRequestContext()).andReturn(new HashMap<String, Object>()).anyTimes();
+        
         EasyMock.expect(proxy.createClient(bus, endpoint, ProtocolVariation.RM10WSA200408,
conduit, replyTo))
             .andReturn(client).anyTimes();  
         Object[] args = new Object[] {};
         Map<String, Object> context = new HashMap<String, Object>();
         Object[] results = new Object[] {"a", "b", "c"};
-        EasyMock.expect(client.invoke(boi, args, context)).andReturn(results).anyTimes();
       
-        
+        EasyMock.expect(client.invoke(boi, args, context)).andReturn(results).anyTimes();

         control.replay();
         assertEquals("a", proxy.invoke(oi, ProtocolVariation.RM10WSA200408, args, context));
     }
@@ -350,19 +352,20 @@ public class ProxyTest extends Assert {
                 new org.apache.cxf.ws.rm.v200502.CreateSequenceResponseType();
             expectInvoke(proxy, oi, csr);
         }
-        
+
         EndpointReferenceType defaultAcksTo = control.createMock(EndpointReferenceType.class);
         AttributedURIType aut = control.createMock(AttributedURIType.class);
         EasyMock.expect(aut.getValue()).andReturn("here").anyTimes();
         EasyMock.expect(defaultAcksTo.getAddress()).andReturn(aut).anyTimes();
         RelatesToType relatesTo = control.createMock(RelatesToType.class);
         control.replay();
+        Map<String, Object> context = new HashMap<String, Object>();
         if (isServer) {
             assertNull(proxy.createSequence(defaultAcksTo, relatesTo, isServer, 
-                                            ProtocolVariation.RM10WSA200408));
+                                            ProtocolVariation.RM10WSA200408, context));
         } else {
             assertNotNull(proxy.createSequence(defaultAcksTo, relatesTo, isServer, 
-                                               ProtocolVariation.RM10WSA200408));
+                                               ProtocolVariation.RM10WSA200408, context));
         }
     }
     
@@ -370,7 +373,7 @@ public class ProxyTest extends Assert {
     private void expectInvoke(Proxy proxy, OperationInfo oi, Object expectedReturn) throws
RMException {
         EasyMock.expect(proxy.invoke(EasyMock.same(oi), EasyMock.isA(ProtocolVariation.class),

                                      EasyMock.isA(Object[].class), 
-            (Map<String, Object>)EasyMock.isNull())).andReturn(expectedReturn).anyTimes();
+                                     EasyMock.isA(Map.class))).andReturn(expectedReturn).anyTimes();
     }
     
     @SuppressWarnings("unchecked")

http://git-wip-us.apache.org/repos/asf/cxf/blob/84927217/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMManagerTest.java
----------------------------------------------------------------------
diff --git a/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMManagerTest.java b/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMManagerTest.java
index 36c947c..b641979 100644
--- a/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMManagerTest.java
+++ b/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMManagerTest.java
@@ -25,6 +25,7 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Date;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
 import java.util.TimerTask;
 
@@ -63,6 +64,7 @@ import org.apache.cxf.ws.rmp.v200502.RMAssertion;
 import org.easymock.Capture;
 import org.easymock.EasyMock;
 import org.easymock.IMocksControl;
+
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
@@ -397,7 +399,9 @@ public class RMManagerTest extends Assert {
         control.verify();
     }
     
+    
     @Test
+    @SuppressWarnings("unchecked")
     public void testGetNewSequence() throws NoSuchMethodException, SequenceFault, RMException
{
         Method m = RMManager.class.getDeclaredMethod("getSource", new Class[] {Message.class});
         manager = control.createMock(RMManager.class, new Method[] {m});
@@ -405,6 +409,7 @@ public class RMManagerTest extends Assert {
         EasyMock.expect(RMContextUtils.getProtocolVariation(message))
             .andReturn(ProtocolVariation.RM10WSA200408);
         Exchange exchange = control.createMock(Exchange.class);
+        EasyMock.expect(message.keySet()).andReturn(new HashSet<String>()).anyTimes();
         EasyMock.expect(message.getExchange()).andReturn(exchange).anyTimes();
         EasyMock.expect(exchange.getOutMessage()).andReturn(message).anyTimes();
         EasyMock.expect(exchange.getInMessage()).andReturn(null).anyTimes();
@@ -429,7 +434,8 @@ public class RMManagerTest extends Assert {
         proxy.createSequence(EasyMock.isA(EndpointReferenceType.class),
                              (RelatesToType)EasyMock.isNull(),
                              EasyMock.eq(false),
-                             EasyMock.isA(ProtocolVariation.class));
+                             EasyMock.isA(ProtocolVariation.class),
+                             EasyMock.isA(HashMap.class));
         EasyMock.expectLastCall().andReturn(createResponse);
         Servant servant = control.createMock(Servant.class);
         EasyMock.expect(rme.getServant()).andReturn(servant);


Mime
View raw message