This is an automated email from the ASF dual-hosted git repository. jamesnetherton pushed a commit to branch camel-main in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
commit 170d1558094c0d85f6677c00a354f5487382077b Author: James Netherton <[email protected]> AuthorDate: Thu May 7 16:11:42 2026 +0100 Adapt Grok tests to switch to io.github.whatap:java-grok --- .../apache/camel/quarkus/component/grok/it/GrokResource.java | 10 +++------- .../org/apache/camel/quarkus/component/grok/it/GrokRoute.java | 7 ++++--- .../org/apache/camel/quarkus/component/grok/it/GrokTest.java | 4 +--- 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/integration-tests/grok/src/main/java/org/apache/camel/quarkus/component/grok/it/GrokResource.java b/integration-tests/grok/src/main/java/org/apache/camel/quarkus/component/grok/it/GrokResource.java index 2263ba8f57..ea80d8f8f9 100644 --- a/integration-tests/grok/src/main/java/org/apache/camel/quarkus/component/grok/it/GrokResource.java +++ b/integration-tests/grok/src/main/java/org/apache/camel/quarkus/component/grok/it/GrokResource.java @@ -22,7 +22,6 @@ import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; import jakarta.ws.rs.GET; import jakarta.ws.rs.Path; -import org.apache.camel.CamelExecutionException; import org.apache.camel.ProducerTemplate; import org.jboss.logging.Logger; @@ -107,14 +106,11 @@ public class GrokResource { @Path("/flatten") @GET + @SuppressWarnings("unchecked") public String flatten(String input) { LOG.infof("Calling flatten with %s", input); - try { - template.requestBody("direct:flatten", input, String.class); - } catch (CamelExecutionException cex) { - return cex.getCause().getClass().getName(); - } - return null; + Map<String, Object> result = template.requestBody("direct:flatten", input, Map.class); + return result.toString(); } @Path("/namedOnly") diff --git a/integration-tests/grok/src/main/java/org/apache/camel/quarkus/component/grok/it/GrokRoute.java b/integration-tests/grok/src/main/java/org/apache/camel/quarkus/component/grok/it/GrokRoute.java index d64206bd14..9862cb6f7e 100644 --- a/integration-tests/grok/src/main/java/org/apache/camel/quarkus/component/grok/it/GrokRoute.java +++ b/integration-tests/grok/src/main/java/org/apache/camel/quarkus/component/grok/it/GrokRoute.java @@ -48,15 +48,16 @@ public class GrokRoute extends RouteBuilder { from("direct:path").unmarshal().grok("%{PATH:path}").setBody(simple("${body[path]}")); from("direct:uri").unmarshal().grok("%{URI:uri}").setBody(simple("${body[uri]}")); from("direct:num").unmarshal().grok("%{NUMBER:num}").setBody(simple("${body[num]}")); - from("direct:timestamp").unmarshal().grok("%{TIMESTAMP_ISO8601:timestamp}").setBody(simple("${body[timestamp]}")); + from("direct:timestamp").unmarshal().grok("%{TIMESTAMP_ISO8601:log_timestamp}") + .setBody(simple("${body[log_timestamp]}")); - DataFormat flattenDf = new GrokDataFormat("%{INT:i} %{INT:i}").setFlattened(true); + DataFormat flattenDf = new GrokDataFormat("%{INT:i:integer} %{INT:j:integer}").setFlattened(true); from("direct:flatten").unmarshal(flattenDf); DataFormat namedOnlyDf = new GrokDataFormat("%{URI:website}").setNamedOnly(true); from("direct:namedOnly").unmarshal(namedOnlyDf); - DataFormat singleMatchPerLineDf = new GrokDataFormat("%{INT:i}").setAllowMultipleMatchesPerLine(false); + DataFormat singleMatchPerLineDf = new GrokDataFormat("%{INT:i:integer}").setAllowMultipleMatchesPerLine(false); from("direct:singleMatchPerLine").unmarshal(singleMatchPerLineDf).setBody(simple("${body[0][i]}-${body[1][i]}")); } diff --git a/integration-tests/grok/src/test/java/org/apache/camel/quarkus/component/grok/it/GrokTest.java b/integration-tests/grok/src/test/java/org/apache/camel/quarkus/component/grok/it/GrokTest.java index 8701daeb7f..2a6776f077 100644 --- a/integration-tests/grok/src/test/java/org/apache/camel/quarkus/component/grok/it/GrokTest.java +++ b/integration-tests/grok/src/test/java/org/apache/camel/quarkus/component/grok/it/GrokTest.java @@ -16,7 +16,6 @@ */ package org.apache.camel.quarkus.component.grok.it; -import io.krakens.grok.api.exception.GrokException; import io.quarkus.test.junit.QuarkusTest; import org.junit.jupiter.api.Test; @@ -100,8 +99,7 @@ class GrokTest { @Test public void grokFlattenShouldReturnGrokExceptionClassName() { - final String expected = GrokException.class.getName(); - given().body("1 2").get("/grok/flatten").then().statusCode(200).body(is(expected)); + given().body("1 2").get("/grok/flatten").then().statusCode(200).body(is("{i=1, j=2}")); } @Test
