camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r675878 - in /activemq/camel/trunk/camel-core/src: main/java/org/apache/camel/processor/TransformProcessor.java test/java/org/apache/camel/processor/TransformProcessorWithHeaderTest.java
Date Fri, 11 Jul 2008 09:23:44 GMT
Author: davsclaus
Date: Fri Jul 11 02:23:43 2008
New Revision: 675878

URL: http://svn.apache.org/viewvc?rev=675878&view=rev
Log:
CAMEL-697: transform() should propogate headers

Added:
    activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/TransformProcessorWithHeaderTest.java
      - copied, changed from r675840, activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/TransformProcessorTest.java
Modified:
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/TransformProcessor.java

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/TransformProcessor.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/TransformProcessor.java?rev=675878&r1=675877&r2=675878&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/TransformProcessor.java
(original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/TransformProcessor.java
Fri Jul 11 02:23:43 2008
@@ -42,6 +42,9 @@
         Object newBody = expression.evaluate(exchange);
         exchange.getOut().setBody(newBody);
 
+        // propogate headers
+        exchange.getOut().getHeaders().putAll(exchange.getIn().getHeaders());
+        
         super.process(exchange);
     }
 

Copied: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/TransformProcessorWithHeaderTest.java
(from r675840, activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/TransformProcessorTest.java)
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/TransformProcessorWithHeaderTest.java?p2=activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/TransformProcessorWithHeaderTest.java&p1=activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/TransformProcessorTest.java&r1=675840&r2=675878&rev=675878&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/TransformProcessorTest.java
(original)
+++ activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/TransformProcessorWithHeaderTest.java
Fri Jul 11 02:23:43 2008
@@ -16,17 +16,35 @@
  */
 package org.apache.camel.processor;
 
+import org.apache.camel.ContextTestSupport;
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
 
-public class TransformProcessorTest extends TransformViaDSLTest {
+/**
+ * Unit test to verify that headers can be propogated with the transform DSL.
+ */
+public class TransformProcessorWithHeaderTest extends ContextTestSupport {
+
+    public void testTransformPropogateHeaders() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMessageCount(1);
+        mock.expectedBodiesReceived("London");
+        mock.expectedHeaderReceived("foo", "bar");
+
+        template.sendBodyAndHeader("direct:in",
+            "<person name='James' city='London'/>", "foo", "bar");
+
+        assertMockEndpointsSatisifed();
+    }
 
     protected RouteBuilder createRouteBuilder() {
         return new RouteBuilder() {
             public void configure() {
-                // START SNIPPET: example
-                from("direct:start").transform(body().append(" World!")).to("mock:result");
-                // END SNIPPET: example
+                from("direct:in")
+                    .transform().constant("London")
+                    .to("mock:result");
             }
         };
     }
-}
+
+}
\ No newline at end of file



Mime
View raw message