Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-15742

xpath uses previous return type definition

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 3.6.0
    • 3.7.0
    • camel-core
    • None
    • Unknown

    Description

      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Ā 

       .setProperty("BOOK_COUNT", xpath( "//Books/@count", Long.class))
      

      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>

      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();
      
          }
      }
      

      *TEST: *

      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"));
          }}
      

      Attachments

        Activity

          People

            davsclaus Claus Ibsen
            Holu Dennis
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: