You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by al...@apache.org on 2022/03/01 12:03:11 UTC
[camel-quarkus] branch main updated: jsonpath: fix different number of ObjectMapper modules between JVM and native mode #3582
This is an automated email from the ASF dual-hosted git repository.
aldettinger pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
The following commit(s) were added to refs/heads/main by this push:
new ff25795 jsonpath: fix different number of ObjectMapper modules between JVM and native mode #3582
ff25795 is described below
commit ff25795df9f344a90b1e89a397358bc4f19af763
Author: aldettinger <al...@gmail.com>
AuthorDate: Tue Mar 1 09:06:15 2022 +0100
jsonpath: fix different number of ObjectMapper modules between JVM and native mode #3582
---
.../json/path/deployment/JsonPathProcessor.java | 3 ++
integration-tests/jsonpath/pom.xml | 2 +-
.../component/json/path/it/JsonPathResource.java | 11 +++++---
.../json/path/it/JsonPathCharsetsTest.java | 32 +++++++++++-----------
4 files changed, 27 insertions(+), 21 deletions(-)
diff --git a/extensions/jsonpath/deployment/src/main/java/org/apache/camel/quarkus/component/json/path/deployment/JsonPathProcessor.java b/extensions/jsonpath/deployment/src/main/java/org/apache/camel/quarkus/component/json/path/deployment/JsonPathProcessor.java
index 5e68144..1fa1321 100644
--- a/extensions/jsonpath/deployment/src/main/java/org/apache/camel/quarkus/component/json/path/deployment/JsonPathProcessor.java
+++ b/extensions/jsonpath/deployment/src/main/java/org/apache/camel/quarkus/component/json/path/deployment/JsonPathProcessor.java
@@ -41,6 +41,9 @@ class JsonPathProcessor {
reflectiveClassBuildItems.add(new ReflectiveClassBuildItem(false, false, JsonPathAnnotationExpressionFactory.class));
reflectiveClassBuildItems.add(new ReflectiveClassBuildItem(true, false, JsonPath.class));
reflectiveClassBuildItems.add(new ReflectiveClassBuildItem(false, false, JacksonJsonAdapter.class));
+ reflectiveClassBuildItems
+ .add(new ReflectiveClassBuildItem(false, false, "com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule"));
+
return reflectiveClassBuildItems;
}
diff --git a/integration-tests/jsonpath/pom.xml b/integration-tests/jsonpath/pom.xml
index 518f8fd..f07e8f6 100644
--- a/integration-tests/jsonpath/pom.xml
+++ b/integration-tests/jsonpath/pom.xml
@@ -45,7 +45,7 @@
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
- <artifactId>quarkus-resteasy-jackson</artifactId>
+ <artifactId>quarkus-resteasy</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
diff --git a/integration-tests/jsonpath/src/main/java/org/apache/camel/quarkus/component/json/path/it/JsonPathResource.java b/integration-tests/jsonpath/src/main/java/org/apache/camel/quarkus/component/json/path/it/JsonPathResource.java
index c235593..2e6f91b 100644
--- a/integration-tests/jsonpath/src/main/java/org/apache/camel/quarkus/component/json/path/it/JsonPathResource.java
+++ b/integration-tests/jsonpath/src/main/java/org/apache/camel/quarkus/component/json/path/it/JsonPathResource.java
@@ -36,6 +36,7 @@ import org.apache.camel.Exchange;
import org.apache.camel.Message;
import org.apache.camel.ProducerTemplate;
import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.commons.lang3.StringUtils;
import org.jboss.logging.Logger;
import static org.apache.camel.jsonpath.JsonPathConstants.HEADER_JSON_ENCODING;
@@ -133,19 +134,21 @@ public class JsonPathResource {
@Path("/getAuthorsFromJsonStream")
@GET
- @Produces(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.TEXT_PLAIN)
@Consumes(MediaType.APPLICATION_OCTET_STREAM)
- public List<?> getAuthorsFromJsonStream(byte[] jsonBytes, @QueryParam("encoding") String encoding) throws IOException {
+ public String getAuthorsFromJsonStream(byte[] jsonBytes, @QueryParam("encoding") String encoding) throws IOException {
LOG.debugf("Getting authors from JsonStream with encoding '%s' and %d bytes", encoding, jsonBytes.length);
+ List<?> bookTitles;
try (ByteArrayInputStream jsonStream = new ByteArrayInputStream(jsonBytes)) {
if (encoding == null) {
- return producerTemplate.requestBody("direct:getAuthorsFromJsonStream", jsonStream, List.class);
+ bookTitles = producerTemplate.requestBody("direct:getAuthorsFromJsonStream", jsonStream, List.class);
} else {
- return producerTemplate.requestBodyAndHeader("direct:getAuthorsFromJsonStream", jsonStream,
+ bookTitles = producerTemplate.requestBodyAndHeader("direct:getAuthorsFromJsonStream", jsonStream,
HEADER_JSON_ENCODING, encoding, List.class);
}
}
+ return StringUtils.join(bookTitles, "-");
}
@Path("/splitInputJsonThenWriteAsStringShouldSucceed")
diff --git a/integration-tests/jsonpath/src/test/java/org/apache/camel/quarkus/component/json/path/it/JsonPathCharsetsTest.java b/integration-tests/jsonpath/src/test/java/org/apache/camel/quarkus/component/json/path/it/JsonPathCharsetsTest.java
index 94a9b30..d12c097 100644
--- a/integration-tests/jsonpath/src/test/java/org/apache/camel/quarkus/component/json/path/it/JsonPathCharsetsTest.java
+++ b/integration-tests/jsonpath/src/test/java/org/apache/camel/quarkus/component/json/path/it/JsonPathCharsetsTest.java
@@ -23,7 +23,7 @@ import org.apache.commons.io.IOUtils;
import org.junit.jupiter.api.Test;
import static io.restassured.RestAssured.given;
-import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.hamcrest.Matchers.is;
@QuarkusTest
class JsonPathCharsetsTest {
@@ -31,31 +31,31 @@ class JsonPathCharsetsTest {
@Test
public void transformBooksUTF16BEShouldReturnTwoAuthors() throws IOException {
byte[] body = IOUtils.resourceToByteArray("/booksUTF16BE.json");
- String[] authors = given().body(body).get("/jsonpath/getAuthorsFromJsonStream").then().statusCode(200).extract()
- .as(String[].class);
- assertEquals(2, authors.length);
- assertEquals("Sayings of the Century", authors[0]);
- assertEquals("Sword of Honour", authors[1]);
+ given().body(body)
+ .get("/jsonpath/getAuthorsFromJsonStream")
+ .then()
+ .statusCode(200)
+ .body(is("Sayings of the Century-Sword of Honour"));
}
@Test
public void transformBooksUTF16LEShouldReturnTwoAuthors() throws IOException {
byte[] body = IOUtils.resourceToByteArray("/booksUTF16LE.json");
- String[] authors = given().body(body).get("/jsonpath/getAuthorsFromJsonStream").then().statusCode(200).extract()
- .as(String[].class);
- assertEquals(2, authors.length);
- assertEquals("Sayings of the Century", authors[0]);
- assertEquals("Sword of Honour", authors[1]);
+ given().body(body)
+ .get("/jsonpath/getAuthorsFromJsonStream")
+ .then().statusCode(200)
+ .body(is("Sayings of the Century-Sword of Honour"));
}
@Test
public void transformBooksIso_8859_1_ShouldReturnTwoAuthors() throws IOException {
byte[] body = IOUtils.resourceToByteArray("/germanbooks-iso-8859-1.json");
- String[] authors = given().queryParam("encoding", "ISO-8859-1").body(body).get("/jsonpath/getAuthorsFromJsonStream")
- .then().statusCode(200).extract().as(String[].class);
- assertEquals(2, authors.length);
- assertEquals("Joseph und seine Brüder", authors[0]);
- assertEquals("Götzendämmerung", authors[1]);
+ given().queryParam("encoding", "ISO-8859-1")
+ .body(body)
+ .get("/jsonpath/getAuthorsFromJsonStream")
+ .then()
+ .statusCode(200)
+ .body(is("Joseph und seine Brüder-Götzendämmerung"));
}
}