Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/camel-grok/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<artifactId>camel-support</artifactId>
</dependency>
<dependency>
<groupId>io.krakens</groupId>
<groupId>io.github.whatap</groupId>
<artifactId>java-grok</artifactId>
<version>${java-grok-version}</version>
</dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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);
Expand All @@ -69,16 +61,15 @@ public void configure() {
@Test
@SuppressWarnings("unchecked")
public void testFlattened() {
Map<String, Object> 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<String, Object> 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
Expand Down Expand Up @@ -110,18 +101,18 @@ 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<Map<String, Object>> allowMultipleMatchesPerLineFalse = template.requestBody(
"direct:allowMultipleMatchesPerLineFalse",
"1 2 \n 3",
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"));

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ public static List<Arguments> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
2 changes: 1 addition & 1 deletion parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@
<jandex-version>3.5.3</jandex-version>
<jansi-version>2.4.3</jansi-version>
<jasypt-version>1.9.3</jasypt-version>
<java-grok-version>0.1.9</java-grok-version>
<java-grok-version>0.1.2</java-grok-version>
<java-util-version>4.102.0</java-util-version>
<jnats-version>2.25.2</jnats-version>
<javacc-maven-plugin-version>3.2.0</javacc-maven-plugin-version>
Expand Down
Loading