camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1459380 - in /camel/trunk/camel-core/src/test/java/org/apache/camel/language/simple: SimpleParserExpressionTest.java SimpleParserPredicateTest.java
Date Thu, 21 Mar 2013 16:11:55 GMT
Author: davsclaus
Date: Thu Mar 21 16:11:54 2013
New Revision: 1459380

URL: http://svn.apache.org/r1459380
Log:
CAMEL-6191: Added unit tests

Modified:
    camel/trunk/camel-core/src/test/java/org/apache/camel/language/simple/SimpleParserExpressionTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/language/simple/SimpleParserPredicateTest.java

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/language/simple/SimpleParserExpressionTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/language/simple/SimpleParserExpressionTest.java?rev=1459380&r1=1459379&r2=1459380&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/language/simple/SimpleParserExpressionTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/language/simple/SimpleParserExpressionTest.java
Thu Mar 21 16:11:54 2013
@@ -16,8 +16,12 @@
  */
 package org.apache.camel.language.simple;
 
+import java.util.HashMap;
+import java.util.Map;
+
 import org.apache.camel.ExchangeTestSupport;
 import org.apache.camel.Expression;
+import org.apache.camel.Predicate;
 
 /**
  *
@@ -165,4 +169,20 @@ public class SimpleParserExpressionTest 
         assertEquals(123, num.intValue());
     }
 
+    public void testSimpleMap() throws Exception {
+        Map<String, String> map = new HashMap<String, String>();
+        map.put("foo", "123");
+        map.put("foo bar", "456");
+
+        exchange.getIn().setBody(map);
+
+        SimpleExpressionParser parser = new SimpleExpressionParser("${body[foo]}", true);
+        Expression exp = parser.parseExpression();
+        assertEquals("123", exp.evaluate(exchange, Object.class));
+
+        parser = new SimpleExpressionParser("${body['foo bar']}", true);
+        exp = parser.parseExpression();
+        assertEquals("456", exp.evaluate(exchange, Object.class));
+    }
+
 }

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/language/simple/SimpleParserPredicateTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/language/simple/SimpleParserPredicateTest.java?rev=1459380&r1=1459379&r2=1459380&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/language/simple/SimpleParserPredicateTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/language/simple/SimpleParserPredicateTest.java
Thu Mar 21 16:11:54 2013
@@ -16,6 +16,9 @@
  */
 package org.apache.camel.language.simple;
 
+import java.util.HashMap;
+import java.util.Map;
+
 import org.apache.camel.ExchangeTestSupport;
 import org.apache.camel.Predicate;
 
@@ -186,4 +189,20 @@ public class SimpleParserPredicateTest e
         assertTrue("Should match", pre.matches(exchange));
     }
 
+    public void testSimpleMap() throws Exception {
+        Map<String, String> map = new HashMap<String, String>();
+        map.put("foo", "123");
+        map.put("foo bar", "456");
+
+        exchange.getIn().setBody(map);
+
+        SimplePredicateParser parser = new SimplePredicateParser("${body[foo]} == 123", true);
+        Predicate pre = parser.parsePredicate();
+        assertTrue("Should match", pre.matches(exchange));
+
+        parser = new SimplePredicateParser("${body['foo bar']} == 456", true);
+        pre = parser.parsePredicate();
+        assertTrue("Should match", pre.matches(exchange));
+    }
+
 }



Mime
View raw message