Skip to content

Commit

Permalink
Upgraded to Camel 2.18. Fixed XQuery/XPath issues; see #61 and #62.
Browse files Browse the repository at this point in the history
  • Loading branch information
jkorab committed Oct 20, 2016
1 parent 22db625 commit 33d1e60
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public boolean isUseAdviceWith() {
@Test
public void testXmlEncryptionDecryption() throws Exception {
final Namespaces namespaces = new Namespaces("c", "http://camelcookbook.org/schema/booksignings");
final String cityExistsXPath = "exists(/c:booksignings/c:store/c:address/c:city)";
final String cityExistsXPath = "/c:booksignings/c:store/c:address/c:city";

context.getRouteDefinition("encrypt")
.adviceWith(context, new AdviceWithRouteBuilder() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public boolean isUseAdviceWith() {
@Test
public void testXmlEncryptionDecryption() throws Exception {
final Namespaces namespaces = new Namespaces("c", "http://camelcookbook.org/schema/booksignings");
final String cityExistsXPath = "exists(/c:booksignings/c:store/c:address/c:city)";
final String cityExistsXPath = "/c:booksignings/c:store/c:address/c:city";

context.getRouteDefinition("encrypt")
.adviceWith(context, new AdviceWithRouteBuilder() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public boolean isUseAdviceWith() {

@Test
public void testXmlEncryptionDecryption() throws Exception {
final String cityExistsXPath = "exists(/booksignings/store/address/city)";
final String cityExistsXPath = "/booksignings/store/address/city";

context.getRouteDefinition("encrypt")
.adviceWith(context, new AdviceWithRouteBuilder() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public boolean isUseAdviceWith() {

@Test
public void testXmlEncryptionDecryption() throws Exception {
final String cityExistsXPath = "exists(/booksignings/store/address/city)";
final String cityExistsXPath = "/booksignings/store/address/city";

context.getRouteDefinition("encrypt")
.adviceWith(context, new AdviceWithRouteBuilder() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public boolean isUseAdviceWith() {

@Test
public void testXmlEncryptionDecryption() throws Exception {
final String cityExistsXPath = "exists(/booksignings/store/address/city)";
final String cityExistsXPath = "/booksignings/store/address/city";

context.getRouteDefinition("encrypt")
.adviceWith(context, new AdviceWithRouteBuilder() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public boolean isUseAdviceWith() {

@Test
public void testXmlEncryptionDecryption() throws Exception {
final String cityExistsXPath = "exists(/booksignings/store/address/city)";
final String cityExistsXPath = "/booksignings/store/address/city";

context.getRouteDefinition("encrypt")
.adviceWith(context, new AdviceWithRouteBuilder() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ public class XqueryParamRouteBuilder extends RouteBuilder {
@Override
public void configure() throws Exception {
from("direct:start")
.transform(xquery("declare variable $in.headers.myParamValue as xs:integer external; <books value='{$in.headers.myParamValue}'>{for $x in /bookstore/book where $x/price>$in.headers.myParamValue order by $x/title return $x/title}</books>"));
.transform(xquery("declare variable $in.headers.myParamValue as xs:string external; <books value='{$in.headers.myParamValue}'>{for $x in /bookstore/book where $x/price>($in.headers.myParamValue cast as xs:integer) order by $x/title return $x/title}</books>"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
<from uri="direct:start"/>
<transform>
<xquery>
declare variable $in.headers.myParamValue as xs:integer external;
declare variable $in.headers.myParamValue as xs:string external;
&lt;books value='{$in.headers.myParamValue}'&gt;{
for $x in /bookstore/book
where $x/price>$in.headers.myParamValue
where $x/price>($in.headers.myParamValue cast as xs:integer)
order by $x/title
return $x/title
}&lt;/books&gt;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ public void testXqueryParam() throws Exception {
final InputStream resource = getClass().getClassLoader().getResourceAsStream("bookstore.xml");
final String request = context().getTypeConverter().convertTo(String.class, resource);

String response = template.requestBodyAndHeader("direct:start", request, "myParamValue", 30, String.class);
String response = template.requestBodyAndHeader("direct:start", request, "myParamValue", new Integer(30), String.class);

log.info("Response > 30 = {}", response);
assertEquals("<books value=\"30\"><title lang=\"en\">Apache Camel Developer's Cookbook</title><title lang=\"en\">Learning XML</title></books>", response);

response = template.requestBodyAndHeader("direct:start", request, "myParamValue", 40, String.class);
response = template.requestBodyAndHeader("direct:start", request, "myParamValue", new Integer(40), String.class);

log.info("Response > 40 = {}", response);
assertEquals("<books value=\"40\"><title lang=\"en\">Apache Camel Developer's Cookbook</title></books>", response);
Expand Down
14 changes: 7 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@
<properties>
<application-name>Camel Cookbook Examples</application-name>

<camel-version>2.17.0</camel-version>
<camel-version>2.18.0</camel-version>

<activemq-version>5.13.2</activemq-version>
<activemq-version>5.14.0</activemq-version>
<aries-blueprint-api-version>1.0.1</aries-blueprint-api-version>
<aries-blueprint-cm-version>1.0.6</aries-blueprint-cm-version>
<aries-blueprint-core-version>1.4.4</aries-blueprint-core-version>
Expand All @@ -67,15 +67,15 @@
<commons-codec-version>1.10</commons-codec-version>
<commons-lang-version>2.6</commons-lang-version>
<commons-logging-version>1.2</commons-logging-version>
<cxf-version>3.1.5</cxf-version>
<cxf-version>3.1.7</cxf-version>
<h2-version>1.3.167</h2-version>
<jaxb-version>2.2.11</jaxb-version>
<junit-version>4.11</junit-version>
<junit-version>4.12</junit-version>
<log4j-version>1.2.17</log4j-version>
<saxon-version>9.5.1-5</saxon-version>
<slf4j-version>1.7.13</slf4j-version>
<saxon-version>9.7.0-8</saxon-version>
<slf4j-version>1.7.21</slf4j-version>
<spring-security-version>4.0.4.RELEASE</spring-security-version>
<spring-version>4.2.5.RELEASE</spring-version>
<spring-version>4.3.3.RELEASE</spring-version>
<xalan-version>2.7.2</xalan-version>
<xbean.version>3.18</xbean.version>
<xml-apis-version>1.4.01</xml-apis-version>
Expand Down

0 comments on commit 33d1e60

Please sign in to comment.