camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r696114 - in /activemq/camel/trunk/components/camel-cxf/src: main/java/org/apache/camel/component/cxf/CxfBinding.java test/java/org/apache/camel/component/cxf/CxfProducerContextTest.java
Date Wed, 17 Sep 2008 00:38:34 GMT
Author: ningjiang
Date: Tue Sep 16 17:38:34 2008
New Revision: 696114

URL: http://svn.apache.org/viewvc?rev=696114&view=rev
Log:
CAMEL-912 applied patch with thanks to Mike

Modified:
    activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfBinding.java
    activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfProducerContextTest.java

Modified: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfBinding.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfBinding.java?rev=696114&r1=696113&r2=696114&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfBinding.java
(original)
+++ activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfBinding.java
Tue Sep 16 17:38:34 2008
@@ -86,6 +86,21 @@
             // TODO do we propagate header the same way in non-POJO mode?
             // CxfHeaderHelper.propagateCamelToCxf(strategy, in.getHeaders(), answer);
         }
+
+        //Ensure there is a request context, which is needed by propogateContext() below
+        Map<String, Object> requestContext = CastUtils.cast((Map)answer.get(Client.REQUEST_CONTEXT));
+        if (requestContext == null) {
+        	requestContext = new HashMap<String, Object>();
+        }
+        if (exchange.getExchange() != null) { 
+        	requestContext.putAll(exchange.getExchange());
+        }
+        if (exchange.getProperties() != null) {
+            //Allows other components to pass properties into cxf request context
+            requestContext.putAll(exchange.getProperties());
+        }
+        answer.put(Client.REQUEST_CONTEXT, requestContext);
+        
         return answer;
     }
 

Modified: activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfProducerContextTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfProducerContextTest.java?rev=696114&r1=696113&r2=696114&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfProducerContextTest.java
(original)
+++ activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfProducerContextTest.java
Tue Sep 16 17:38:34 2008
@@ -26,11 +26,27 @@
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.cxf.endpoint.Client;
+import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.message.Message;
 
 // We use context to change the producer's endpoint address here
 public class CxfProducerContextTest extends CxfProducerTest {
 
+	// *** This class extends CxfProducerTest, so see that class for other tests run by this
code
+	
+	private static final String TEST_KEY   = "sendSimpleMessage-test";
+	private static final String TEST_VALUE = "exchange property value should get passed through
request context";
+	
+	public void testExchangePropertyPropagation() throws Exception {
+        CxfExchange exchange = sendSimpleMessage();
+
+        assertNotNull(exchange);
+        assertNotNull(exchange.getInMessage());
+        assertNotNull(exchange.getInMessage().get(Client.REQUEST_CONTEXT));
+        Map<String, Object> requestContext = CastUtils.cast((Map)exchange.getInMessage().get(Client.REQUEST_CONTEXT));
+        String actualValue = (String)requestContext.get(TEST_KEY);
+        assertEquals("exchange property should get propagated to the request context", TEST_VALUE,
actualValue);
+    }
 
     protected String getSimpleEndpointUri() {
         return "cxf://http://localhost:9000/simple?serviceClass=org.apache.camel.component.cxf.HelloService";
@@ -50,6 +66,7 @@
                 exchange.getIn().setBody(params);
                 exchange.getIn().setHeader(Client.REQUEST_CONTEXT , requestContext);
                 exchange.getIn().setHeader(CxfConstants.OPERATION_NAME, ECHO_OPERATION);
+                exchange.getProperties().put(TEST_KEY, TEST_VALUE);
             }
         });
         return exchange;



Mime
View raw message