You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2013/10/06 12:42:39 UTC
[2/3] git commit: CAMEL-6238: camel-jsonpath component.
CAMEL-6238: camel-jsonpath component.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/794ee2c8
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/794ee2c8
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/794ee2c8
Branch: refs/heads/master
Commit: 794ee2c8fe529a7c694c3079e1e9945c986e5c5c
Parents: 293b85c
Author: Claus Ibsen <da...@apache.org>
Authored: Sun Oct 6 11:53:16 2013 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Sun Oct 6 12:42:30 2013 +0200
----------------------------------------------------------------------
.../apache/camel/builder/ExpressionClause.java | 12 ++++
.../camel/builder/ExpressionClauseSupport.java | 12 ++++
.../model/language/JsonPathExpression.java | 42 +++++++++++++
.../org/apache/camel/model/language/jaxb.index | 1 +
components/camel-jsonpath/pom.xml | 4 +-
.../apache/camel/jsonpath/JSonPathEngine.java | 37 +++++++++++
.../camel/jsonpath/JsonPathExpression.java | 38 ------------
.../apache/camel/jsonpath/JsonPathLanguage.java | 35 ++++++++---
.../apache/camel/jsonpath/JsonPathCBRTest.java | 4 +-
.../camel/jsonpath/JsonPathTransformTest.java | 2 +-
.../camel/jsonpath/SpringJsonPathCBRTest.java | 65 ++++++++++++++++++++
.../jsonpath/SpringJsonPathTransformTest.java | 46 ++++++++++++++
.../camel/jsonpath/SpringJsonPathCBTTest.xml | 43 +++++++++++++
.../jsonpath/SpringJsonPathTransformTest.xml | 34 ++++++++++
14 files changed, 324 insertions(+), 51 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/794ee2c8/camel-core/src/main/java/org/apache/camel/builder/ExpressionClause.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/builder/ExpressionClause.java b/camel-core/src/main/java/org/apache/camel/builder/ExpressionClause.java
index 2e42ded..07ab027 100644
--- a/camel-core/src/main/java/org/apache/camel/builder/ExpressionClause.java
+++ b/camel-core/src/main/java/org/apache/camel/builder/ExpressionClause.java
@@ -277,6 +277,18 @@ public class ExpressionClause<T> extends ExpressionDefinition {
}
/**
+ * Evaluates a <a
+ * href="http://camel.apache.org/jsonpath.html">JSon Path
+ * expression</a>
+ *
+ * @param text the expression to be evaluated
+ * @return the builder to continue processing the DSL
+ */
+ public T jsonPath(String text) {
+ return delegate.jsonPath(text);
+ }
+
+ /**
* Evaluates a <a href="http://commons.apache.org/jxpath/">JXPath expression</a>
*
* @param text the expression to be evaluated
http://git-wip-us.apache.org/repos/asf/camel/blob/794ee2c8/camel-core/src/main/java/org/apache/camel/builder/ExpressionClauseSupport.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/builder/ExpressionClauseSupport.java b/camel-core/src/main/java/org/apache/camel/builder/ExpressionClauseSupport.java
index b970806..64955c2 100644
--- a/camel-core/src/main/java/org/apache/camel/builder/ExpressionClauseSupport.java
+++ b/camel-core/src/main/java/org/apache/camel/builder/ExpressionClauseSupport.java
@@ -28,6 +28,7 @@ import org.apache.camel.model.language.GroovyExpression;
import org.apache.camel.model.language.HeaderExpression;
import org.apache.camel.model.language.JXPathExpression;
import org.apache.camel.model.language.JavaScriptExpression;
+import org.apache.camel.model.language.JsonPathExpression;
import org.apache.camel.model.language.LanguageExpression;
import org.apache.camel.model.language.MethodCallExpression;
import org.apache.camel.model.language.MvelExpression;
@@ -312,6 +313,17 @@ public class ExpressionClauseSupport<T> {
}
/**
+ * Evaluates a <a href="http://camel.apache.org/jsonpath.html">JSon Path
+ * expression</a>
+ *
+ * @param text the expression to be evaluated
+ * @return the builder to continue processing the DSL
+ */
+ public T jsonPath(String text) {
+ return expression(new JsonPathExpression(text));
+ }
+
+ /**
* Evaluates a <a href="http://commons.apache.org/jxpath/">JXPath expression</a>
*
* @param text the expression to be evaluated
http://git-wip-us.apache.org/repos/asf/camel/blob/794ee2c8/camel-core/src/main/java/org/apache/camel/model/language/JsonPathExpression.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/language/JsonPathExpression.java b/camel-core/src/main/java/org/apache/camel/model/language/JsonPathExpression.java
new file mode 100644
index 0000000..31c32e2
--- /dev/null
+++ b/camel-core/src/main/java/org/apache/camel/model/language/JsonPathExpression.java
@@ -0,0 +1,42 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.model.language;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ * For JSonPath expressions and predicates
+ *
+ * @version
+ */
+@XmlRootElement(name = "jsonpath")
+@XmlAccessorType(XmlAccessType.FIELD)
+public class JsonPathExpression extends ExpressionDefinition {
+
+ public JsonPathExpression() {
+ }
+
+ public JsonPathExpression(String expression) {
+ super(expression);
+ }
+
+ public String getLanguage() {
+ return "jsonpath";
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/794ee2c8/camel-core/src/main/resources/org/apache/camel/model/language/jaxb.index
----------------------------------------------------------------------
diff --git a/camel-core/src/main/resources/org/apache/camel/model/language/jaxb.index b/camel-core/src/main/resources/org/apache/camel/model/language/jaxb.index
index d558d31..7dce959 100644
--- a/camel-core/src/main/resources/org/apache/camel/model/language/jaxb.index
+++ b/camel-core/src/main/resources/org/apache/camel/model/language/jaxb.index
@@ -20,6 +20,7 @@ ExpressionDefinition
GroovyExpression
HeaderExpression
JavaScriptExpression
+JsonPathExpression
JXPathExpression
LanguageExpression
MethodCallExpression
http://git-wip-us.apache.org/repos/asf/camel/blob/794ee2c8/components/camel-jsonpath/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-jsonpath/pom.xml b/components/camel-jsonpath/pom.xml
index 670f266..22033a8 100644
--- a/components/camel-jsonpath/pom.xml
+++ b/components/camel-jsonpath/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.apache.camel</groupId>
<artifactId>components</artifactId>
- <version>2.12.2-SNAPSHOT</version>
+ <version>2.13-SNAPSHOT</version>
</parent>
<artifactId>camel-jsonpath</artifactId>
@@ -49,7 +49,7 @@
<!-- testing -->
<dependency>
<groupId>org.apache.camel</groupId>
- <artifactId>camel-test</artifactId>
+ <artifactId>camel-test-spring</artifactId>
<scope>test</scope>
</dependency>
<dependency>
http://git-wip-us.apache.org/repos/asf/camel/blob/794ee2c8/components/camel-jsonpath/src/main/java/org/apache/camel/jsonpath/JSonPathEngine.java
----------------------------------------------------------------------
diff --git a/components/camel-jsonpath/src/main/java/org/apache/camel/jsonpath/JSonPathEngine.java b/components/camel-jsonpath/src/main/java/org/apache/camel/jsonpath/JSonPathEngine.java
new file mode 100644
index 0000000..48bde5c
--- /dev/null
+++ b/components/camel-jsonpath/src/main/java/org/apache/camel/jsonpath/JSonPathEngine.java
@@ -0,0 +1,37 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.jsonpath;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import com.jayway.jsonpath.JsonPath;
+
+public class JSonPathEngine {
+
+ private final String expression;
+ private final JsonPath path;
+
+ public JSonPathEngine(String expression) {
+ this.expression = expression;
+ this.path = JsonPath.compile(expression);
+ }
+
+ public Object read(InputStream json) throws IOException {
+ return path.read(json);
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/794ee2c8/components/camel-jsonpath/src/main/java/org/apache/camel/jsonpath/JsonPathExpression.java
----------------------------------------------------------------------
diff --git a/components/camel-jsonpath/src/main/java/org/apache/camel/jsonpath/JsonPathExpression.java b/components/camel-jsonpath/src/main/java/org/apache/camel/jsonpath/JsonPathExpression.java
deleted file mode 100644
index 8d39e7c..0000000
--- a/components/camel-jsonpath/src/main/java/org/apache/camel/jsonpath/JsonPathExpression.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.jsonpath;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import com.jayway.jsonpath.JsonPath;
-
-public class JsonPathExpression {
-
- private final String expression;
- private final JsonPath path;
-
- public JsonPathExpression(String expression) {
- this.expression = expression;
- this.path = JsonPath.compile(expression);
- }
-
- public Object evaluate(InputStream json) throws IOException {
- Object result = path.read(json);
- return result;
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/794ee2c8/components/camel-jsonpath/src/main/java/org/apache/camel/jsonpath/JsonPathLanguage.java
----------------------------------------------------------------------
diff --git a/components/camel-jsonpath/src/main/java/org/apache/camel/jsonpath/JsonPathLanguage.java b/components/camel-jsonpath/src/main/java/org/apache/camel/jsonpath/JsonPathLanguage.java
index 23d0c3e..9776f77 100644
--- a/components/camel-jsonpath/src/main/java/org/apache/camel/jsonpath/JsonPathLanguage.java
+++ b/components/camel-jsonpath/src/main/java/org/apache/camel/jsonpath/JsonPathLanguage.java
@@ -20,21 +20,31 @@ import java.io.InputStream;
import org.apache.camel.Exchange;
import org.apache.camel.Expression;
+import org.apache.camel.ExpressionEvaluationException;
+import org.apache.camel.ExpressionIllegalSyntaxException;
import org.apache.camel.Predicate;
import org.apache.camel.support.ExpressionAdapter;
import org.apache.camel.support.LanguageSupport;
+import org.apache.camel.util.IOHelper;
public class JsonPathLanguage extends LanguageSupport {
@Override
public Predicate createPredicate(final String predicate) {
+ final JSonPathEngine engine;
+ try {
+ engine = new JSonPathEngine(predicate);
+ } catch (Exception e) {
+ throw new ExpressionIllegalSyntaxException(predicate, e);
+ }
+
return new ExpressionAdapter() {
@Override
public Object evaluate(Exchange exchange) {
try {
- return evaluateJsonPath(exchange, predicate);
+ return evaluateJsonPath(exchange, engine);
} catch (Exception e) {
- throw new RuntimeException("TODO", e);
+ throw new ExpressionEvaluationException(this, exchange, e);
}
}
};
@@ -42,23 +52,32 @@ public class JsonPathLanguage extends LanguageSupport {
@Override
public Expression createExpression(final String expression) {
+ final JSonPathEngine engine;
+ try {
+ engine = new JSonPathEngine(expression);
+ } catch (Exception e) {
+ throw new ExpressionIllegalSyntaxException(expression, e);
+ }
+
return new ExpressionAdapter() {
@Override
public Object evaluate(Exchange exchange) {
try {
- return evaluateJsonPath(exchange, expression);
+ return evaluateJsonPath(exchange, engine);
} catch (Exception e) {
- throw new RuntimeException("TODO", e);
+ throw new ExpressionEvaluationException(this, exchange, e);
}
}
};
}
- private Object evaluateJsonPath(Exchange exchange, String expression) throws Exception {
+ private Object evaluateJsonPath(Exchange exchange, JSonPathEngine engine) throws Exception {
InputStream is = exchange.getIn().getMandatoryBody(InputStream.class);
- JsonPathExpression exp = new JsonPathExpression(expression);
- Object result = exp.evaluate(is);
- return result;
+ try {
+ return engine.read(is);
+ } finally {
+ IOHelper.close(is);
+ }
}
}
http://git-wip-us.apache.org/repos/asf/camel/blob/794ee2c8/components/camel-jsonpath/src/test/java/org/apache/camel/jsonpath/JsonPathCBRTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jsonpath/src/test/java/org/apache/camel/jsonpath/JsonPathCBRTest.java b/components/camel-jsonpath/src/test/java/org/apache/camel/jsonpath/JsonPathCBRTest.java
index 2c39998..cb9f51c 100644
--- a/components/camel-jsonpath/src/test/java/org/apache/camel/jsonpath/JsonPathCBRTest.java
+++ b/components/camel-jsonpath/src/test/java/org/apache/camel/jsonpath/JsonPathCBRTest.java
@@ -31,9 +31,9 @@ public class JsonPathCBRTest extends CamelTestSupport {
public void configure() throws Exception {
from("direct:start")
.choice()
- .when().language("jsonpath", "$.store.book[?(@.price < 10)]")
+ .when().jsonPath("$.store.book[?(@.price < 10)]")
.to("mock:cheap")
- .when().language("jsonpath", "$.store.book[?(@.price < 30)]")
+ .when().jsonPath("$.store.book[?(@.price < 30)]")
.to("mock:average")
.otherwise()
.to("mock:expensive");
http://git-wip-us.apache.org/repos/asf/camel/blob/794ee2c8/components/camel-jsonpath/src/test/java/org/apache/camel/jsonpath/JsonPathTransformTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jsonpath/src/test/java/org/apache/camel/jsonpath/JsonPathTransformTest.java b/components/camel-jsonpath/src/test/java/org/apache/camel/jsonpath/JsonPathTransformTest.java
index b8a56fc..1486ff4 100644
--- a/components/camel-jsonpath/src/test/java/org/apache/camel/jsonpath/JsonPathTransformTest.java
+++ b/components/camel-jsonpath/src/test/java/org/apache/camel/jsonpath/JsonPathTransformTest.java
@@ -31,7 +31,7 @@ public class JsonPathTransformTest extends CamelTestSupport {
@Override
public void configure() throws Exception {
from("direct:start")
- .transform().language("jsonpath", "$.store.book[*].author")
+ .transform().jsonPath("$.store.book[*].author")
.to("mock:authors");
}
};
http://git-wip-us.apache.org/repos/asf/camel/blob/794ee2c8/components/camel-jsonpath/src/test/java/org/apache/camel/jsonpath/SpringJsonPathCBRTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jsonpath/src/test/java/org/apache/camel/jsonpath/SpringJsonPathCBRTest.java b/components/camel-jsonpath/src/test/java/org/apache/camel/jsonpath/SpringJsonPathCBRTest.java
new file mode 100644
index 0000000..32aeb57
--- /dev/null
+++ b/components/camel-jsonpath/src/test/java/org/apache/camel/jsonpath/SpringJsonPathCBRTest.java
@@ -0,0 +1,65 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.jsonpath;
+
+import java.io.File;
+
+import org.apache.camel.test.spring.CamelSpringTestSupport;
+import org.junit.Test;
+import org.springframework.context.support.AbstractApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class SpringJsonPathCBRTest extends CamelSpringTestSupport {
+
+ @Override
+ protected AbstractApplicationContext createApplicationContext() {
+ return new ClassPathXmlApplicationContext("org/apache/camel/jsonpath/SpringJsonPathCBTTest.xml");
+ }
+
+ @Test
+ public void testCheap() throws Exception {
+ getMockEndpoint("mock:cheap").expectedMessageCount(1);
+ getMockEndpoint("mock:average").expectedMessageCount(0);
+ getMockEndpoint("mock:expensive").expectedMessageCount(0);
+
+ template.sendBody("direct:start", new File("src/test/resources/cheap.json"));
+
+ assertMockEndpointsSatisfied();
+ }
+
+ @Test
+ public void testAverage() throws Exception {
+ getMockEndpoint("mock:cheap").expectedMessageCount(0);
+ getMockEndpoint("mock:average").expectedMessageCount(1);
+ getMockEndpoint("mock:expensive").expectedMessageCount(0);
+
+ template.sendBody("direct:start", new File("src/test/resources/average.json"));
+
+ assertMockEndpointsSatisfied();
+ }
+
+ @Test
+ public void testExpensive() throws Exception {
+ getMockEndpoint("mock:cheap").expectedMessageCount(0);
+ getMockEndpoint("mock:average").expectedMessageCount(0);
+ getMockEndpoint("mock:expensive").expectedMessageCount(1);
+
+ template.sendBody("direct:start", new File("src/test/resources/expensive.json"));
+
+ assertMockEndpointsSatisfied();
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/794ee2c8/components/camel-jsonpath/src/test/java/org/apache/camel/jsonpath/SpringJsonPathTransformTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jsonpath/src/test/java/org/apache/camel/jsonpath/SpringJsonPathTransformTest.java b/components/camel-jsonpath/src/test/java/org/apache/camel/jsonpath/SpringJsonPathTransformTest.java
new file mode 100644
index 0000000..49c6ec8
--- /dev/null
+++ b/components/camel-jsonpath/src/test/java/org/apache/camel/jsonpath/SpringJsonPathTransformTest.java
@@ -0,0 +1,46 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.jsonpath;
+
+import java.io.File;
+import java.util.List;
+
+import org.apache.camel.test.spring.CamelSpringTestSupport;
+import org.junit.Test;
+import org.springframework.context.support.AbstractApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class SpringJsonPathTransformTest extends CamelSpringTestSupport {
+
+ @Override
+ protected AbstractApplicationContext createApplicationContext() {
+ return new ClassPathXmlApplicationContext("org/apache/camel/jsonpath/SpringJsonPathTransformTest.xml");
+ }
+
+ @Test
+ public void testAuthors() throws Exception {
+ getMockEndpoint("mock:authors").expectedMessageCount(1);
+
+ template.sendBody("direct:start", new File("src/test/resources/books.json"));
+
+ assertMockEndpointsSatisfied();
+
+ List authors = getMockEndpoint("mock:authors").getReceivedExchanges().get(0).getIn().getBody(List.class);
+ assertEquals("Nigel Rees", authors.get(0));
+ assertEquals("Evelyn Waugh", authors.get(1));
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/794ee2c8/components/camel-jsonpath/src/test/resources/org/apache/camel/jsonpath/SpringJsonPathCBTTest.xml
----------------------------------------------------------------------
diff --git a/components/camel-jsonpath/src/test/resources/org/apache/camel/jsonpath/SpringJsonPathCBTTest.xml b/components/camel-jsonpath/src/test/resources/org/apache/camel/jsonpath/SpringJsonPathCBTTest.xml
new file mode 100644
index 0000000..514e542
--- /dev/null
+++ b/components/camel-jsonpath/src/test/resources/org/apache/camel/jsonpath/SpringJsonPathCBTTest.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
+
+ <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
+ <route>
+ <from uri="direct:start"/>
+ <choice>
+ <when>
+ <jsonpath>$.store.book[?(@.price < 10)]</jsonpath>
+ <to uri="mock:cheap"/>
+ </when>
+ <when>
+ <jsonpath>$.store.book[?(@.price < 30)]</jsonpath>
+ <to uri="mock:average"/>
+ </when>
+ <otherwise>
+ <to uri="mock:expensive"/>
+ </otherwise>
+ </choice>
+ </route>
+ </camelContext>
+
+</beans>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/794ee2c8/components/camel-jsonpath/src/test/resources/org/apache/camel/jsonpath/SpringJsonPathTransformTest.xml
----------------------------------------------------------------------
diff --git a/components/camel-jsonpath/src/test/resources/org/apache/camel/jsonpath/SpringJsonPathTransformTest.xml b/components/camel-jsonpath/src/test/resources/org/apache/camel/jsonpath/SpringJsonPathTransformTest.xml
new file mode 100644
index 0000000..e684735
--- /dev/null
+++ b/components/camel-jsonpath/src/test/resources/org/apache/camel/jsonpath/SpringJsonPathTransformTest.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
+
+ <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
+ <route>
+ <from uri="direct:start"/>
+ <transform>
+ <jsonpath>$.store.book[*].author</jsonpath>
+ </transform>
+ <to uri="mock:authors"/>
+ </route>
+ </camelContext>
+
+</beans>
\ No newline at end of file