You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Dennis (Jira)" <ji...@apache.org> on 2020/10/22 18:24:00 UTC

[jira] [Created] (CAMEL-15742) xpath uses previous return type definition

Dennis created CAMEL-15742:
------------------------------

             Summary: 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-language
    Affects Versions: 3.6.0
            Reporter: Dennis


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)