camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1150997 - in /camel/trunk/camel-core/src: main/java/org/apache/camel/language/simple/SimpleLanguage.java test/java/org/apache/camel/component/bean/BeanParameterValueTest.java test/java/org/apache/camel/language/SimpleTest.java
Date Tue, 26 Jul 2011 07:06:00 GMT
Author: davsclaus
Date: Tue Jul 26 07:05:59 2011
New Revision: 1150997

URL: http://svn.apache.org/viewvc?rev=1150997&view=rev
Log:
CAMEL-3961: Added headers to simple language to you can refer to the headers as a Map, and
use that for bean parameter binding in the method name option.

Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/language/simple/SimpleLanguage.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/bean/BeanParameterValueTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/language/SimpleTest.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/language/simple/SimpleLanguage.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/language/simple/SimpleLanguage.java?rev=1150997&r1=1150996&r2=1150997&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/language/simple/SimpleLanguage.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/language/simple/SimpleLanguage.java
Tue Jul 26 07:05:59 2011
@@ -222,6 +222,11 @@ public class SimpleLanguage extends Simp
             return ExpressionBuilder.headerExpression(key, type);
         }
 
+        // headers expression
+        if ("in.headers".equals(expression) || "headers".equals(expression)) {
+            return ExpressionBuilder.headersExpression();
+        }
+
         // in header expression
         remainder = ifStartsWithReturnRemainder("in.headers", expression);
         if (remainder == null) {

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/component/bean/BeanParameterValueTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/bean/BeanParameterValueTest.java?rev=1150997&r1=1150996&r2=1150997&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/bean/BeanParameterValueTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/bean/BeanParameterValueTest.java
Tue Jul 26 07:05:59 2011
@@ -16,6 +16,8 @@
  */
 package org.apache.camel.component.bean;
 
+import java.util.Map;
+
 import org.apache.camel.ContextTestSupport;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.impl.JndiRegistry;
@@ -73,6 +75,14 @@ public class BeanParameterValueTest exte
         assertMockEndpointsSatisfied();
     }
 
+    public void testBeanParameterValueMap() throws Exception {
+        getMockEndpoint("mock:result").expectedBodiesReceived("Hello World");
+
+        template.sendBodyAndHeader("direct:heads", "World", "hello", "Hello");
+
+        assertMockEndpointsSatisfied();
+    }
+
     @Override
     protected JndiRegistry createRegistry() throws Exception {
         JndiRegistry jndi = super.createRegistry();
@@ -108,6 +118,10 @@ public class BeanParameterValueTest exte
                 from("direct:echo2")
                     .to("bean:foo?method=echo(*, ${in.header.times})")
                     .to("mock:result");
+
+                from("direct:heads")
+                    .to("bean:foo?method=heads(${body}, ${headers})")
+                    .to("mock:result");
             }
         };
     }
@@ -133,5 +147,10 @@ public class BeanParameterValueTest exte
 
             return body;
         }
+
+        public String heads(String body, Map headers) {
+            return headers.get("hello") + " " + body;
+        }
+
     }
 }

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/language/SimpleTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/language/SimpleTest.java?rev=1150997&r1=1150996&r2=1150997&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/language/SimpleTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/language/SimpleTest.java Tue Jul
26 07:05:59 2011
@@ -411,6 +411,16 @@ public class SimpleTest extends Language
         }
     }
 
+    public void testHeaders() throws Exception {
+        Map headers = exchange.getIn().getHeaders();
+        assertEquals(2, headers.size());
+
+        assertExpression("headers", headers);
+        assertExpression("${headers}", headers);
+        assertExpression("in.headers", headers);
+        assertExpression("${in.headers}", headers);
+    }
+
     public void testHeaderAs() throws Exception {
         assertExpression("${headerAs(foo,String)}", "abc");
 



Mime
View raw message