You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Claus Ibsen (Jira)" <ji...@apache.org> on 2020/10/23 07:13:00 UTC
[jira] [Resolved] (CAMEL-15742) xpath uses previous return type
definition
[ https://issues.apache.org/jira/browse/CAMEL-15742?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Claus Ibsen resolved CAMEL-15742.
---------------------------------
Resolution: Fixed
Yes its a little bug which is now fixed. Thanks for reporting and with the sample code
> xpath uses previous return type definition
> ------------------------------------------
>
> Key: CAMEL-15742
> URL: https://issues.apache.org/jira/browse/CAMEL-15742
> Project: Camel
> Issue Type: Bug
> Components: camel-core
> Affects Versions: 3.6.0
> Reporter: Dennis
> Assignee: Claus Ibsen
> Priority: Major
> Fix For: 3.7.0
>
>
> The 3.6.0 version brakes our route tests.
> In the code below we have two xpath expressions. Debugging shows, that the second one in split uses Long.class as return type for evaluation which is wrong and split silently fails (No split done).
> if you removeĀ
> {code:java}
> .setProperty("BOOK_COUNT", xpath( "//Books/@count", Long.class))
> {code}
> test will pass.
> Verified by test based on Camel Quarkus :: Examples :: Rest Json
> <camel-quarkus.version>1.3.0</camel-quarkus.version>
> <quarkus.version>1.9.0.Final</quarkus.version>
> {code:java}
> package org.acme.rest.json;
> import org.apache.camel.builder.RouteBuilder;
> import java.util.concurrent.atomic.AtomicInteger;
> public class Routes extends RouteBuilder {
> private AtomicInteger splitCount = new AtomicInteger();
> @Override
> public void configure() throws Exception {
> from("platform-http:/xpathtest?httpMethodRestrict=POST")
> .process(exchange -> splitCount.set(0))
> .setProperty("BOOK_COUNT", xpath( "//Books/@count", Long.class))
> .split(xpath("//Books/Book"))
> .process(exchange -> splitCount.getAndIncrement())
> .end()
> .setBody(exchange -> splitCount.get())
> .marshal().json();
> }
> }
> {code}
> *TEST: *
> {code:java}
> package org.acme.rest.json;import io.quarkus.test.junit.QuarkusTest;
> import org.junit.jupiter.api.Test;import static io.restassured.RestAssured.given;
> import static org.hamcrest.CoreMatchers.is;@QuarkusTest
> public class RestJsonTest { @Test
> public void xpath() {
> given()
> .body("<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n" +
> "<Books count=\"2\"><Book Id=\"1\" ISBN=\"1\"><Titel>First</Titel> </Book>" +
> "<Book Id=\"2\" ISBN=\"2\"><Titel>SECOND</Titel> </Book>" +
> "</Books>")
> .header("Content-Type", "application/xml")
> .when()
> .post("/xpathtest")
> .then()
> .statusCode(200)
> .body(is("2"));
> }}
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)