diff --git a/components/camel-grok/pom.xml b/components/camel-grok/pom.xml index e9aea6eb15720..7c746cb031d6e 100644 --- a/components/camel-grok/pom.xml +++ b/components/camel-grok/pom.xml @@ -39,7 +39,7 @@ camel-support - io.krakens + io.github.whatap java-grok ${java-grok-version} diff --git a/components/camel-grok/src/main/java/org/apache/camel/component/grok/GrokDataFormat.java b/components/camel-grok/src/main/java/org/apache/camel/component/grok/GrokDataFormat.java index 5c9ec85b9f471..9a75abe69f365 100644 --- a/components/camel-grok/src/main/java/org/apache/camel/component/grok/GrokDataFormat.java +++ b/components/camel-grok/src/main/java/org/apache/camel/component/grok/GrokDataFormat.java @@ -26,9 +26,9 @@ import java.util.*; import java.util.stream.Stream; -import io.krakens.grok.api.Grok; -import io.krakens.grok.api.GrokCompiler; -import io.krakens.grok.api.Match; +import io.whatap.grok.api.Grok; +import io.whatap.grok.api.GrokCompiler; +import io.whatap.grok.api.Match; import org.apache.camel.CamelContext; import org.apache.camel.CamelContextAware; import org.apache.camel.Exchange; diff --git a/components/camel-grok/src/test/java/org/apache/camel/component/grok/GrokOptionalOptionsTest.java b/components/camel-grok/src/test/java/org/apache/camel/component/grok/GrokOptionalOptionsTest.java index 46c82e00e87c6..779e803322d6c 100644 --- a/components/camel-grok/src/test/java/org/apache/camel/component/grok/GrokOptionalOptionsTest.java +++ b/components/camel-grok/src/test/java/org/apache/camel/component/grok/GrokOptionalOptionsTest.java @@ -19,19 +19,15 @@ import java.util.List; import java.util.Map; -import io.krakens.grok.api.exception.GrokException; -import org.apache.camel.CamelExecutionException; import org.apache.camel.RoutesBuilder; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.spi.DataFormat; import org.apache.camel.test.junit6.CamelTestSupport; import org.junit.jupiter.api.Test; -import static org.apache.camel.test.junit6.TestSupport.assertIsInstanceOf; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; public class GrokOptionalOptionsTest extends CamelTestSupport { @@ -40,23 +36,19 @@ protected RoutesBuilder createRouteBuilder() { return new RouteBuilder() { @Override public void configure() { - DataFormat grokFlattenedTrue = new GrokDataFormat("%{INT:i} %{INT:i}") - .setFlattened(true); - DataFormat grokFlattenedFalse = new GrokDataFormat("%{INT:i} %{INT:i}") - .setFlattened(false); + DataFormat grokMultipleInt = new GrokDataFormat("%{INT:i:integer} %{INT:j:integer}"); DataFormat grokNamedOnlyTrue = new GrokDataFormat("%{URI:website}") .setNamedOnly(true); DataFormat grokNamedOnlyFalse = new GrokDataFormat("%{URI:website}") .setNamedOnly(false); - DataFormat grokAllowMultipleMatchesPerLineTrue = new GrokDataFormat("%{INT:i}") + DataFormat grokAllowMultipleMatchesPerLineTrue = new GrokDataFormat("%{INT:i:integer}") .setAllowMultipleMatchesPerLine(true); - DataFormat grokAllowMultipleMatchesPerLineFalse = new GrokDataFormat("%{INT:i}") + DataFormat grokAllowMultipleMatchesPerLineFalse = new GrokDataFormat("%{INT:i:integer}") .setAllowMultipleMatchesPerLine(false); - from("direct:flattenedTrue").unmarshal(grokFlattenedTrue); - from("direct:flattenedFalse").unmarshal(grokFlattenedFalse); + from("direct:multipleInt").unmarshal(grokMultipleInt); from("direct:namedOnlyTrue").unmarshal(grokNamedOnlyTrue); from("direct:namedOnlyFalse").unmarshal(grokNamedOnlyFalse); from("direct:allowMultipleMatchesPerLineTrue").unmarshal(grokAllowMultipleMatchesPerLineTrue); @@ -69,16 +61,15 @@ public void configure() { @Test @SuppressWarnings("unchecked") public void testFlattened() { - Map flattenedFalse = template.requestBody("direct:flattenedFalse", "123 456", Map.class); - assertNotNull(flattenedFalse); - assertTrue(flattenedFalse.containsKey("i")); - assertTrue(flattenedFalse.get("i") instanceof List); - assertEquals("123", ((List) flattenedFalse.get("i")).get(0)); - assertEquals("456", ((List) flattenedFalse.get("i")).get(1)); + Map multipleInt = template.requestBody("direct:multipleInt", "123 456", Map.class); + assertNotNull(multipleInt); + assertTrue(multipleInt.containsKey("i")); + assertTrue(multipleInt.get("i") instanceof Integer); + assertEquals(123, multipleInt.get("i")); - CamelExecutionException e = assertThrows(CamelExecutionException.class, - () -> template.requestBody("direct:flattenedTrue", "1 2")); - assertIsInstanceOf(GrokException.class, e.getCause()); + assertTrue(multipleInt.containsKey("j")); + assertTrue(multipleInt.get("j") instanceof Integer); + assertEquals(456, multipleInt.get("j")); } @Test @@ -110,9 +101,9 @@ public void testAllowMultipleMatchesPerLine() { List.class); assertNotNull(allowMultipleMatchesPerLineTrue); assertEquals(3, allowMultipleMatchesPerLineTrue.size()); - assertEquals("1", allowMultipleMatchesPerLineTrue.get(0).get("i")); - assertEquals("2", allowMultipleMatchesPerLineTrue.get(1).get("i")); - assertEquals("3", allowMultipleMatchesPerLineTrue.get(2).get("i")); + assertEquals(1, allowMultipleMatchesPerLineTrue.get(0).get("i")); + assertEquals(2, allowMultipleMatchesPerLineTrue.get(1).get("i")); + assertEquals(3, allowMultipleMatchesPerLineTrue.get(2).get("i")); List> allowMultipleMatchesPerLineFalse = template.requestBody( "direct:allowMultipleMatchesPerLineFalse", @@ -120,8 +111,8 @@ public void testAllowMultipleMatchesPerLine() { List.class); assertNotNull(allowMultipleMatchesPerLineFalse); assertEquals(2, allowMultipleMatchesPerLineFalse.size()); - assertEquals("1", allowMultipleMatchesPerLineFalse.get(0).get("i")); - assertEquals("3", allowMultipleMatchesPerLineFalse.get(1).get("i")); + assertEquals(1, allowMultipleMatchesPerLineFalse.get(0).get("i")); + assertEquals(3, allowMultipleMatchesPerLineFalse.get(1).get("i")); } } diff --git a/components/camel-grok/src/test/java/org/apache/camel/component/grok/GrokPatternsTest.java b/components/camel-grok/src/test/java/org/apache/camel/component/grok/GrokPatternsTest.java index b8e0393616bbc..405c2fa69dd39 100644 --- a/components/camel-grok/src/test/java/org/apache/camel/component/grok/GrokPatternsTest.java +++ b/components/camel-grok/src/test/java/org/apache/camel/component/grok/GrokPatternsTest.java @@ -57,11 +57,11 @@ public static List data() { Arguments.of("%{NUMBER:num}", "number is 123.", test("num", "123")), Arguments.of("%{NUMBER:num:integer}", "number is 123.", test("num", 123)), Arguments.of("%{IP:ip}", "my ip is 192.168.0.1", test("ip", "192.168.0.1")), - Arguments.of("%{TIMESTAMP_ISO8601:timestamp}", "This test was created at 2019-05-26T10:54:15Z test plain", - test("timestamp", "2019-05-26T10:54:15Z")), - Arguments.of("%{TIMESTAMP_ISO8601:timestamp:date}", + Arguments.of("%{TIMESTAMP_ISO8601:log_timestamp}", "This test was created at 2019-05-26T10:54:15Z test plain", + test("log_timestamp", "2019-05-26T10:54:15Z")), + Arguments.of("%{TIMESTAMP_ISO8601:log_timestamp:date}", "This test was created at 2019-05-26T10:54:15Z test convert", - test("timestamp", Instant.ofEpochSecond(1558868055)))); + test("log_timestamp", Instant.ofEpochSecond(1558868055)))); } @Override diff --git a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_21.adoc b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_21.adoc index 7e42bfa2cdd49..e4c1f7748a93a 100644 --- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_21.adoc +++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_21.adoc @@ -13,6 +13,11 @@ See the xref:camel-upgrade-recipes-tool.adoc[documentation] page for details. == Upgrading Camel 4.20 to 4.21 +=== camel-grok - potential breaking change + +The library used for Camel Grok component has been migrated from no more maintained `io.krakens:java-grok` to its fork `io.github.whatap:java-grok`. +It implies small differences listed https://github.com/whatap/java-grok#what-is-different-from-iokrakensjava-grok[here]. + === camel-core The `org.apache.camel.support.DefaultHeaderFilterStrategy` changed default setting for lowercase from `false` to `true`. diff --git a/parent/pom.xml b/parent/pom.xml index f6821883ad603..ce8100d34489d 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -260,7 +260,7 @@ 3.5.3 2.4.3 1.9.3 - 0.1.9 + 0.1.2 4.102.0 2.25.2 3.2.0