camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r1302786 - in /camel/branches/camel-2.8.x: ./ components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducer.java components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducerTest.java
Date Tue, 20 Mar 2012 06:42:34 GMT
Author: ningjiang
Date: Tue Mar 20 06:42:33 2012
New Revision: 1302786

URL: http://svn.apache.org/viewvc?rev=1302786&view=rev
Log:
Merged revisions 1302761 via svnmerge from 
https://svn.apache.org/repos/asf/camel/branches/camel-2.9.x

................
  r1302761 | ningjiang | 2012-03-20 10:41:47 +0800 (Tue, 20 Mar 2012) | 9 lines
  
  Merged revisions 1302484 via svnmerge from 
  https://svn.apache.org/repos/asf/camel/trunk
  
  ........
    r1302484 | ningjiang | 2012-03-19 22:52:17 +0800 (Mon, 19 Mar 2012) | 1 line
    
    CAMEL-5107 cxfrs producer should retain the message headers when it gets the reponse
  ........
................

Modified:
    camel/branches/camel-2.8.x/   (props changed)
    camel/branches/camel-2.8.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducer.java
    camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducerTest.java

Propchange: camel/branches/camel-2.8.x/
------------------------------------------------------------------------------
  Merged /camel/trunk:r1302484
  Merged /camel/branches/camel-2.9.x:r1302761

Propchange: camel/branches/camel-2.8.x/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: camel/branches/camel-2.8.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducer.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducer.java?rev=1302786&r1=1302785&r2=1302786&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducer.java
(original)
+++ camel/branches/camel-2.8.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducer.java
Tue Mar 20 06:42:33 2012
@@ -181,8 +181,9 @@ public class CxfRsProducer extends Defau
         // set response
         if (exchange.getPattern().isOutCapable()) {
             LOG.trace("Response body = {}", response);
+            exchange.getOut().getHeaders().putAll(exchange.getIn().getHeaders());
             exchange.getOut().setBody(binding.bindResponseToCamelBody(response, exchange));
-            exchange.getOut().setHeaders(binding.bindResponseHeadersToCamelHeaders(response,
exchange));
+            exchange.getOut().getHeaders().putAll(binding.bindResponseHeadersToCamelHeaders(response,
exchange));
             exchange.getOut().setHeader(Exchange.HTTP_RESPONSE_CODE, statesCode);
         }
     }
@@ -230,8 +231,9 @@ public class CxfRsProducer extends Defau
         
         if (exchange.getPattern().isOutCapable()) {
             LOG.trace("Response body = {}", response);
+            exchange.getOut().getHeaders().putAll(exchange.getIn().getHeaders());
             exchange.getOut().setBody(binding.bindResponseToCamelBody(response, exchange));
-            exchange.getOut().setHeaders(binding.bindResponseHeadersToCamelHeaders(response,
exchange));
+            exchange.getOut().getHeaders().putAll(binding.bindResponseHeadersToCamelHeaders(response,
exchange));
             exchange.getOut().setHeader(Exchange.HTTP_RESPONSE_CODE, statesCode);
         }
     }

Modified: camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducerTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducerTest.java?rev=1302786&r1=1302785&r2=1302786&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducerTest.java
(original)
+++ camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducerTest.java
Tue Mar 20 06:42:33 2012
@@ -83,6 +83,8 @@ public class CxfRsProducerTest extends C
                 inMessage.setHeader(CxfConstants.OPERATION_NAME, "getCustomer");
                 // using the proxy client API
                 inMessage.setHeader(CxfConstants.CAMEL_CXF_RS_USING_HTTP_API, Boolean.FALSE);
+                // set a customer header
+                inMessage.setHeader("key", "value");
                 // set the parameters , if you just have one parameter 
                 // camel will put this object into an Object[] itself
                 inMessage.setBody("123");
@@ -96,6 +98,8 @@ public class CxfRsProducerTest extends C
         assertEquals("Get a wrong customer id ", String.valueOf(response.getId()), "123");
         assertEquals("Get a wrong customer name", response.getName(), "John");
         assertEquals("Get a wrong response code", 200, exchange.getOut().getHeader(Exchange.HTTP_RESPONSE_CODE));
+        System.out.println(exchange.getOut().getHeaders());
+        assertEquals("Get a wrong header value", "value", exchange.getOut().getHeader("key"));
         // END SNIPPET: ProxyExample     
     }
     
@@ -141,6 +145,8 @@ public class CxfRsProducerTest extends C
                 inMessage.setHeader(Exchange.HTTP_PATH, "/customerservice/customers/123");
               
                 // Specify the response class , cxfrs will use InputStream as the response
object type 
                 inMessage.setHeader(CxfConstants.CAMEL_CXF_RS_RESPONSE_CLASS, Customer.class);
+                // set a customer header
+                inMessage.setHeader("key", "value");
                 // since we use the Get method, so we don't need to set the message body
                 inMessage.setBody(null);                
             }
@@ -153,6 +159,7 @@ public class CxfRsProducerTest extends C
         assertEquals("Get a wrong customer id ", String.valueOf(response.getId()), "123");
         assertEquals("Get a wrong customer name", response.getName(), "John");
         assertEquals("Get a wrong response code", 200, exchange.getOut().getHeader(Exchange.HTTP_RESPONSE_CODE));
+        assertEquals("Get a wrong header value", "value", exchange.getOut().getHeader("key"));
         // END SNIPPET: HttpExample 
     }
     



Mime
View raw message