You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by cm...@apache.org on 2014/08/28 12:22:05 UTC
git commit: Extend unit test to include field search based on
type/customer
Repository: camel
Updated Branches:
refs/heads/master 75bcfbc58 -> 394c08712
Extend unit test to include field search based on type/customer
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/394c0871
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/394c0871
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/394c0871
Branch: refs/heads/master
Commit: 394c087126c1e744d06f8ac8536ff41f31803855
Parents: 75bcfbc
Author: Charles Moulliard <ch...@gmail.com>
Authored: Thu Aug 28 12:21:57 2014 +0200
Committer: Charles Moulliard <ch...@gmail.com>
Committed: Thu Aug 28 12:21:57 2014 +0200
----------------------------------------------------------------------
.../camel/jsonpath/JsonPathLanguageTest.java | 24 ++++++++++++++++----
1 file changed, 20 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/394c0871/components/camel-jsonpath/src/test/java/org/apache/camel/jsonpath/JsonPathLanguageTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jsonpath/src/test/java/org/apache/camel/jsonpath/JsonPathLanguageTest.java b/components/camel-jsonpath/src/test/java/org/apache/camel/jsonpath/JsonPathLanguageTest.java
index 0773760..a0d8a28 100644
--- a/components/camel-jsonpath/src/test/java/org/apache/camel/jsonpath/JsonPathLanguageTest.java
+++ b/components/camel-jsonpath/src/test/java/org/apache/camel/jsonpath/JsonPathLanguageTest.java
@@ -35,14 +35,14 @@ public class JsonPathLanguageTest extends CamelTestSupport {
}
@Test
- public void testExpression() throws Exception {
+ public void testExpressionArray() throws Exception {
Exchange exchange = new DefaultExchange(context);
exchange.getIn().setBody(new File("src/test/resources/books.json"));
Language lan = context.resolveLanguage("jsonpath");
Expression exp = lan.createExpression("$.store.book[*].author");
List<?> authors = exp.evaluate(exchange, List.class);
- log.info("Authors {}", authors);
+ log.debug("Authors {}", authors);
assertNotNull(authors);
assertEquals(2, authors.size());
@@ -52,8 +52,24 @@ public class JsonPathLanguageTest extends CamelTestSupport {
exp = lan.createExpression("$.store.bicycle.price");
String price = exp.evaluate(exchange, String.class);
assertEquals("Got a wrong result", "19.95", price);
-
-
+ }
+
+ @Test
+ public void testExpressionField() throws Exception {
+ Exchange exchange = new DefaultExchange(context);
+ exchange.getIn().setBody(new File("src/test/resources/type.json"));
+
+ Language lan = context.resolveLanguage("jsonpath");
+ Expression exp = lan.createExpression("$.kind");
+ String kind = exp.evaluate(exchange, String.class);
+
+ assertNotNull(kind);
+ assertEquals("full", kind);
+
+ exp = lan.createExpression("$.type");
+ String type = exp.evaluate(exchange, String.class);
+ assertNotNull(type);
+ assertEquals("customer", type);
}
@Test