You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by ni...@apache.org on 2013/02/17 04:31:07 UTC
svn commit: r1446995 - in
/servicemix/smx4/features/trunk/cxf/cxf-transport-nmr/src:
main/java/org/apache/servicemix/cxf/transport/nmr/NMRConduitOutputStream.java
test/java/org/apache/servicemix/cxf/transport/nmr/NMRConduitTest.java
Author: ningjiang
Date: Sun Feb 17 03:31:07 2013
New Revision: 1446995
URL: http://svn.apache.org/r1446995
Log:
SMX4-1378 copy the cxf protocol header to nmr message
Modified:
servicemix/smx4/features/trunk/cxf/cxf-transport-nmr/src/main/java/org/apache/servicemix/cxf/transport/nmr/NMRConduitOutputStream.java
servicemix/smx4/features/trunk/cxf/cxf-transport-nmr/src/test/java/org/apache/servicemix/cxf/transport/nmr/NMRConduitTest.java
Modified: servicemix/smx4/features/trunk/cxf/cxf-transport-nmr/src/main/java/org/apache/servicemix/cxf/transport/nmr/NMRConduitOutputStream.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/cxf/cxf-transport-nmr/src/main/java/org/apache/servicemix/cxf/transport/nmr/NMRConduitOutputStream.java?rev=1446995&r1=1446994&r2=1446995&view=diff
==============================================================================
--- servicemix/smx4/features/trunk/cxf/cxf-transport-nmr/src/main/java/org/apache/servicemix/cxf/transport/nmr/NMRConduitOutputStream.java (original)
+++ servicemix/smx4/features/trunk/cxf/cxf-transport-nmr/src/main/java/org/apache/servicemix/cxf/transport/nmr/NMRConduitOutputStream.java Sun Feb 17 03:31:07 2013
@@ -27,16 +27,15 @@ import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import java.util.logging.Logger;
-
import javax.activation.DataHandler;
import javax.jws.WebService;
import javax.security.auth.Subject;
import javax.xml.namespace.QName;
import javax.xml.transform.Source;
import javax.xml.transform.stream.StreamSource;
-
import org.apache.cxf.attachment.AttachmentImpl;
import org.apache.cxf.common.logging.LogUtils;
import org.apache.cxf.io.CachedOutputStream;
@@ -143,6 +142,17 @@ public class NMRConduitOutputStream exte
inMsg.setHeader(ent.getKey(), ent.getValue());
}
}
+
+ // we need to copy the protocol headers
+ Map<String, List<String>> protocolHeaders = (Map<String, List<String>>)message.get(Message.PROTOCOL_HEADERS);
+ if (protocolHeaders != null) {
+ for (Map.Entry<String, List<String>> ent : protocolHeaders.entrySet()) {
+ if (ent.getValue().size() > 0) {
+ // here we just put the first header value
+ inMsg.setHeader(ent.getKey(), ent.getValue().get(0));
+ }
+ }
+ }
//copy securitySubject
inMsg.setSecuritySubject((Subject) message.get(NMRTransportFactory.NMR_SECURITY_SUBJECT));
Modified: servicemix/smx4/features/trunk/cxf/cxf-transport-nmr/src/test/java/org/apache/servicemix/cxf/transport/nmr/NMRConduitTest.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/cxf/cxf-transport-nmr/src/test/java/org/apache/servicemix/cxf/transport/nmr/NMRConduitTest.java?rev=1446995&r1=1446994&r2=1446995&view=diff
==============================================================================
--- servicemix/smx4/features/trunk/cxf/cxf-transport-nmr/src/test/java/org/apache/servicemix/cxf/transport/nmr/NMRConduitTest.java (original)
+++ servicemix/smx4/features/trunk/cxf/cxf-transport-nmr/src/test/java/org/apache/servicemix/cxf/transport/nmr/NMRConduitTest.java Sun Feb 17 03:31:07 2013
@@ -24,13 +24,15 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.lang.reflect.Method;
+import java.util.ArrayList;
import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
import java.util.logging.Logger;
-
import javax.xml.stream.XMLStreamReader;
import javax.xml.transform.Source;
import javax.xml.transform.stream.StreamSource;
-
import org.apache.cxf.common.logging.LogUtils;
import org.apache.cxf.message.ExchangeImpl;
import org.apache.cxf.message.Message;
@@ -71,6 +73,12 @@ public class NMRConduitTest extends Abst
Class<org.apache.servicemix.cxf.transport.nmr.Greeter> greeterCls
= org.apache.servicemix.cxf.transport.nmr.Greeter.class;
message.put(Method.class.getName(), greeterCls.getMethod("sayHi"));
+ Map<String, List<String>> protocolHeaders = new TreeMap<String, List<String>>(String.CASE_INSENSITIVE_ORDER);
+ List<String> value = new ArrayList<String>();
+ value.add("value");
+ protocolHeaders.put("myHeader", value);
+ message.put(Message.PROTOCOL_HEADERS, protocolHeaders);
+
org.apache.cxf.message.Exchange exchange = new ExchangeImpl();
exchange.setOneWay(false);
@@ -86,6 +94,9 @@ public class NMRConduitTest extends Abst
EasyMock.expect(channel.createExchange(Pattern.InOut)).andReturn(xchg);
org.apache.servicemix.nmr.api.Message inMsg = control.createMock(org.apache.servicemix.nmr.api.Message.class);
EasyMock.expect(xchg.getIn()).andReturn(inMsg);
+ // just need to make sure the customer header is set
+ inMsg.setHeader("myHeader", "value");
+ EasyMock.expectLastCall();
EndpointRegistry endpoints = control.createMock(EndpointRegistry.class);
EasyMock.expect(channel.getNMR()).andReturn(nmr);
EasyMock.expect(nmr.getEndpointRegistry()).andReturn(endpoints);
@@ -108,7 +119,10 @@ public class NMRConduitTest extends Abst
OutputStream os = message.getContent(OutputStream.class);
assertTrue("The OutputStream should not be null ", os != null);
os.write("HelloWorld".getBytes());
- os.close();
+ os.close();
+ control.verify();
+ // check the customer protocol header
+ //assertEquals("Should get the customer header here.", "value", headers.get("myHeader"));
InputStream is = inMessage.getContent(InputStream.class);
assertNotNull(is);
XMLStreamReader reader = StaxUtils.createXMLStreamReader(is, null);