servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r1406451 - in /servicemix/smx4/features/trunk/cxf/cxf-transport-nmr/src: main/java/org/apache/servicemix/cxf/transport/nmr/NMRDestination.java test/java/org/apache/servicemix/cxf/transport/nmr/NMRDestinationTest.java
Date Wed, 07 Nov 2012 04:20:24 GMT
Author: ningjiang
Date: Wed Nov  7 04:20:24 2012
New Revision: 1406451

URL: http://svn.apache.org/viewvc?rev=1406451&view=rev
Log:
SMX4-1273 cxf-nmr trasport should copy the message header which value is String as the Protocol
Header

Modified:
    servicemix/smx4/features/trunk/cxf/cxf-transport-nmr/src/main/java/org/apache/servicemix/cxf/transport/nmr/NMRDestination.java
    servicemix/smx4/features/trunk/cxf/cxf-transport-nmr/src/test/java/org/apache/servicemix/cxf/transport/nmr/NMRDestinationTest.java

Modified: servicemix/smx4/features/trunk/cxf/cxf-transport-nmr/src/main/java/org/apache/servicemix/cxf/transport/nmr/NMRDestination.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/cxf/cxf-transport-nmr/src/main/java/org/apache/servicemix/cxf/transport/nmr/NMRDestination.java?rev=1406451&r1=1406450&r2=1406451&view=diff
==============================================================================
--- servicemix/smx4/features/trunk/cxf/cxf-transport-nmr/src/main/java/org/apache/servicemix/cxf/transport/nmr/NMRDestination.java
(original)
+++ servicemix/smx4/features/trunk/cxf/cxf-transport-nmr/src/main/java/org/apache/servicemix/cxf/transport/nmr/NMRDestination.java
Wed Nov  7 04:20:24 2012
@@ -25,7 +25,9 @@ import java.io.OutputStream;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
+import java.util.TreeMap;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
@@ -144,11 +146,19 @@ public class NMRDestination extends Abst
             }
             inMessage.setAttachments(cxfAttachmentList);
             
-            //copy properties
+            //copy properties and setup the cxf protocol header
+            Map<String, List<String>> protocolHeaders = new TreeMap<String,
List<String>>(String.CASE_INSENSITIVE_ORDER);
+            inMessage.put(Message.PROTOCOL_HEADERS, protocolHeaders);
+
             for (Map.Entry<String, Object> ent : nm.getHeaders().entrySet()) {
                 if (!ent.getKey().equals(Message.REQUESTOR_ROLE)) {
                     inMessage.put(ent.getKey(), ent.getValue());
                 }
+                if (ent.getValue() instanceof String) {
+            	    List<String> value = new ArrayList<String>();
+            	    value.add((String)ent.getValue());
+            	    protocolHeaders.put(ent.getKey(), value);
+                }
             }
             
             //copy securitySubject

Modified: servicemix/smx4/features/trunk/cxf/cxf-transport-nmr/src/test/java/org/apache/servicemix/cxf/transport/nmr/NMRDestinationTest.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/cxf/cxf-transport-nmr/src/test/java/org/apache/servicemix/cxf/transport/nmr/NMRDestinationTest.java?rev=1406451&r1=1406450&r2=1406451&view=diff
==============================================================================
--- servicemix/smx4/features/trunk/cxf/cxf-transport-nmr/src/test/java/org/apache/servicemix/cxf/transport/nmr/NMRDestinationTest.java
(original)
+++ servicemix/smx4/features/trunk/cxf/cxf-transport-nmr/src/test/java/org/apache/servicemix/cxf/transport/nmr/NMRDestinationTest.java
Wed Nov  7 04:20:24 2012
@@ -22,6 +22,8 @@ package org.apache.servicemix.cxf.transp
 import java.io.ByteArrayInputStream;
 import java.security.AccessController;
 import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 import java.util.logging.Logger;
 
 import javax.security.auth.Subject;
@@ -129,7 +131,9 @@ public class NMRDestinationTest extends 
         EasyMock.expect(xchg.getStatus()).andReturn(Status.Active);
         EasyMock.expect(xchg.getIn()).andReturn(inMsg);
         EasyMock.expect(inMsg.getAttachments()).andReturn(new HashMap<String, Object>());
-        EasyMock.expect(inMsg.getHeaders()).andReturn(new HashMap<String, Object>());
+        Map<String, Object> nmrHeaders = new HashMap<String, Object>();
+        nmrHeaders.put("hello", "world");
+        EasyMock.expect(inMsg.getHeaders()).andReturn(nmrHeaders);
         Source source = new StreamSource(new ByteArrayInputStream(
                             "<message>TestHelloWorld</message>".getBytes()));
         EasyMock.expect(inMsg.getBody(Source.class)).andReturn(source);
@@ -145,6 +149,9 @@ public class NMRDestinationTest extends 
         destination.setMessageObserver(observer);
         destination.process(xchg);
         assertNotNull(inMessage);
+        @SuppressWarnings("unchecked")
+		Map<String, List<String>> protocolHeaders = (Map<String, List<String>>)inMessage.get(Message.PROTOCOL_HEADERS);
+        assertEquals("We should get a right protocol headers", "world", protocolHeaders.get("hello").get(0));
     }
     
     @Test



Mime
View raw message