This is an automated email from the ASF dual-hosted git repository.
aldettinger pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
The following commit(s) were added to refs/heads/master by this push:
new 7a5a5b7 Added grok support #1466
7a5a5b7 is described below
commit 7a5a5b7312f39578d066031793b497c7a680340c
Author: aldettinger <[email protected]>
AuthorDate: Wed Jul 29 09:46:09 2020 +0200
Added grok support #1466
---
docs/modules/ROOT/pages/extensions/grok.adoc | 28 +++++
.../pages/list-of-camel-quarkus-extensions.adoc | 4 +-
extensions/grok/deployment/pom.xml | 63 ++++++++++
.../component/grok/deployment/GrokProcessor.java | 36 ++++++
extensions/grok/pom.xml | 39 ++++++
extensions/grok/runtime/pom.xml | 94 ++++++++++++++
.../main/resources/META-INF/quarkus-extension.yaml | 29 +++++
extensions/pom.xml | 1 +
integration-tests/grok/pom.xml | 134 ++++++++++++++++++++
.../quarkus/component/grok/it/GrokResource.java | 136 +++++++++++++++++++++
.../camel/quarkus/component/grok/it/GrokRoute.java | 58 +++++++++
.../camel/quarkus/component/grok/it/GrokIT.java | 24 ++++
.../camel/quarkus/component/grok/it/GrokTest.java | 118 ++++++++++++++++++
integration-tests/pom.xml | 1 +
poms/bom/pom.xml | 15 +++
tooling/scripts/test-categories.yaml | 1 +
16 files changed, 780 insertions(+), 1 deletion(-)
diff --git a/docs/modules/ROOT/pages/extensions/grok.adoc
b/docs/modules/ROOT/pages/extensions/grok.adoc
new file mode 100644
index 0000000..769af7f
--- /dev/null
+++ b/docs/modules/ROOT/pages/extensions/grok.adoc
@@ -0,0 +1,28 @@
+// Do not edit directly!
+// This file was generated by
camel-quarkus-maven-plugin:update-extension-doc-page
+
+[[grok]]
+= Grok
+
+[.badges]
+[.badge-key]##Since Camel Quarkus##[.badge-version]##1.0.0-CR4##
[.badge-key]##JVM##[.badge-supported]##supported##
[.badge-key]##Native##[.badge-supported]##supported##
+
+Unmarshal unstructured data to objects using Logstash based Grok patterns.
+
+== What's inside
+
+*
https://camel.apache.org/components/latest/dataformats/grok-dataformat.html[Grok
data format]
+
+Please refer to the above link for usage and configuration details.
+
+== Maven coordinates
+
+[source,xml]
+----
+<dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-grok</artifactId>
+</dependency>
+----
+
+Check the xref:user-guide/index.adoc[User guide] for more information about
writing Camel Quarkus applications.
diff --git a/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc
b/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc
index b5b03d3..a2e0a2c 100644
--- a/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc
+++ b/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc
@@ -339,7 +339,7 @@ Number of Camel components: 155 in 120 JAR artifacts (0
deprecated)
== Camel Data Formats
// dataformats: START
-Number of Camel data formats: 26 in 21 JAR artifacts (0 deprecated)
+Number of Camel data formats: 27 in 22 JAR artifacts (0 deprecated)
[width="100%",cols="4,1,1,1,5",options="header"]
|===
@@ -361,6 +361,8 @@ Number of Camel data formats: 26 in 21 JAR artifacts (0
deprecated)
| xref:extensions/fhir.adoc[FHIR XML] | camel-quarkus-fhir | Native + Stable |
0.3.0 | Marshall and unmarshall FHIR objects to/from XML.
+| xref:extensions/grok.adoc[Grok] | camel-quarkus-grok | Native + Stable |
1.0.0-CR4 | Unmarshal unstructured data to objects using Logstash based Grok
patterns.
+
| xref:extensions/zip-deflater.adoc[GZip Deflater] |
camel-quarkus-zip-deflater | Native + Stable | 1.0.0-M4 | Compress and
decompress messages using java.util.zip.GZIPStream.
| xref:extensions/ical.adoc[iCal] | camel-quarkus-ical | Native + Stable |
1.0.0-M5 | Marshal and unmarshal iCal (.ics) documents to/from model objects
provided by the iCal4j library.
diff --git a/extensions/grok/deployment/pom.xml
b/extensions/grok/deployment/pom.xml
new file mode 100644
index 0000000..283e368
--- /dev/null
+++ b/extensions/grok/deployment/pom.xml
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-grok-parent</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>camel-quarkus-grok-deployment</artifactId>
+ <name>Camel Quarkus :: Grok :: Deployment</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-core-deployment</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-grok</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <annotationProcessorPaths>
+ <path>
+ <groupId>io.quarkus</groupId>
+
<artifactId>quarkus-extension-processor</artifactId>
+ <version>${quarkus.version}</version>
+ </path>
+ </annotationProcessorPaths>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git
a/extensions/grok/deployment/src/main/java/org/apache/camel/quarkus/component/grok/deployment/GrokProcessor.java
b/extensions/grok/deployment/src/main/java/org/apache/camel/quarkus/component/grok/deployment/GrokProcessor.java
new file mode 100644
index 0000000..94259d8
--- /dev/null
+++
b/extensions/grok/deployment/src/main/java/org/apache/camel/quarkus/component/grok/deployment/GrokProcessor.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.grok.deployment;
+
+import io.quarkus.deployment.annotations.BuildStep;
+import io.quarkus.deployment.builditem.FeatureBuildItem;
+import
io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem;
+
+class GrokProcessor {
+
+ private static final String FEATURE = "camel-grok";
+
+ @BuildStep
+ FeatureBuildItem feature() {
+ return new FeatureBuildItem(FEATURE);
+ }
+
+ @BuildStep
+ NativeImageResourceBuildItem registerDefaultPatternsNativeResources() {
+ return new NativeImageResourceBuildItem("patterns/patterns");
+ }
+}
diff --git a/extensions/grok/pom.xml b/extensions/grok/pom.xml
new file mode 100644
index 0000000..0447dba
--- /dev/null
+++ b/extensions/grok/pom.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-build-parent</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ <relativePath>../../poms/build-parent/pom.xml</relativePath>
+ </parent>
+
+ <artifactId>camel-quarkus-grok-parent</artifactId>
+ <name>Camel Quarkus :: Grok</name>
+ <packaging>pom</packaging>
+
+ <modules>
+ <module>deployment</module>
+ <module>runtime</module>
+ </modules>
+</project>
diff --git a/extensions/grok/runtime/pom.xml b/extensions/grok/runtime/pom.xml
new file mode 100644
index 0000000..855c807
--- /dev/null
+++ b/extensions/grok/runtime/pom.xml
@@ -0,0 +1,94 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-grok-parent</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>camel-quarkus-grok</artifactId>
+ <name>Camel Quarkus :: Grok :: Runtime</name>
+ <description>Unmarshal unstructured data to objects using Logstash based
Grok patterns.</description>
+
+ <properties>
+ <firstVersion>1.0.0-CR4</firstVersion>
+ </properties>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-bom</artifactId>
+ <version>${project.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-grok</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>update-extension-doc-page</id>
+ <goals><goal>update-extension-doc-page</goal></goals>
+ <phase>process-classes</phase>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-bootstrap-maven-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <annotationProcessorPaths>
+ <path>
+ <groupId>io.quarkus</groupId>
+
<artifactId>quarkus-extension-processor</artifactId>
+ <version>${quarkus.version}</version>
+ </path>
+ </annotationProcessorPaths>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git
a/extensions/grok/runtime/src/main/resources/META-INF/quarkus-extension.yaml
b/extensions/grok/runtime/src/main/resources/META-INF/quarkus-extension.yaml
new file mode 100644
index 0000000..dd7b4bb
--- /dev/null
+++ b/extensions/grok/runtime/src/main/resources/META-INF/quarkus-extension.yaml
@@ -0,0 +1,29 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# This is a generated file. Do not edit directly!
+# To re-generate, run the following command from the top level directory:
+#
+# mvn -N cq:update-quarkus-metadata
+#
+---
+name: "Camel Grok"
+description: "Unmarshal unstructured data to objects using Logstash based Grok
patterns"
+metadata:
+ guide: "https://camel.apache.org/camel-quarkus/latest/extensions/grok.html"
+ categories:
+ - "integration"
diff --git a/extensions/pom.xml b/extensions/pom.xml
index 58ecf64..62cf6b7 100644
--- a/extensions/pom.xml
+++ b/extensions/pom.xml
@@ -99,6 +99,7 @@
<module>google-mail</module>
<module>google-sheets</module>
<module>graphql</module>
+ <module>grok</module>
<module>gson</module>
<module>http</module>
<module>hystrix</module>
diff --git a/integration-tests/grok/pom.xml b/integration-tests/grok/pom.xml
new file mode 100644
index 0000000..b0358ff
--- /dev/null
+++ b/integration-tests/grok/pom.xml
@@ -0,0 +1,134 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-integration-tests</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>camel-quarkus-integration-test-grok</artifactId>
+ <name>Camel Quarkus :: Integration Tests :: Grok</name>
+ <description>Integration tests for Camel Quarkus Grok
extension</description>
+
+ <properties>
+ <!-- mvnd, a.k.a. Maven Daemon: https://github.com/gnodet/mvnd -->
+ <!-- The following rule tells mvnd to build the listed deployment
modules before this module. -->
+ <!-- This is important because mvnd builds modules in parallel by
default. The deployment modules are not -->
+ <!-- explicit dependencies of this module in the Maven sense, although
they are required by the Quarkus Maven plugin. -->
+ <!-- Please update rule whenever you change the dependencies of this
module by running -->
+ <!-- mvn process-resources -Pformat from the root directory -->
+
<mvnd.builder.rule>camel-quarkus-grok-deployment,camel-quarkus-support-policy-deployment</mvnd.builder.rule>
+ </properties>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-bom-test</artifactId>
+ <version>${project.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-grok</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-direct</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-bean</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-resteasy</artifactId>
+ </dependency>
+
+ <!-- test dependencies -->
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-junit5</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>io.rest-assured</groupId>
+ <artifactId>rest-assured</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>build</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <profiles>
+ <profile>
+ <id>native</id>
+ <activation>
+ <property>
+ <name>native</name>
+ </property>
+ </activation>
+ <properties>
+ <quarkus.package.type>native</quarkus.package.type>
+ </properties>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-failsafe-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>integration-test</goal>
+ <goal>verify</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
+</project>
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
new file mode 100644
index 0000000..30062dc
--- /dev/null
+++
b/integration-tests/grok/src/main/java/org/apache/camel/quarkus/component/grok/it/GrokResource.java
@@ -0,0 +1,136 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.grok.it;
+
+import java.util.Map;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+
+import org.apache.camel.CamelExecutionException;
+import org.apache.camel.ProducerTemplate;
+import org.jboss.logging.Logger;
+
+@Path("/grok")
+@ApplicationScoped
+public class GrokResource {
+
+ private static final Logger LOG = Logger.getLogger(GrokResource.class);
+
+ @Inject
+ ProducerTemplate template;
+
+ @Path("/log")
+ @GET
+ public String log(String input) {
+ LOG.infof("Calling log with %s", input);
+ return template.requestBody("direct:log", input, String.class);
+ }
+
+ @Path("/fooBar")
+ @GET
+ public String fooBar(String input) {
+ LOG.infof("Calling fooBar with %s", input);
+ return template.requestBody("direct:fooBar", input, String.class);
+ }
+
+ @Path("/ip")
+ @GET
+ public String ip(String input) {
+ LOG.infof("Calling ip with %s", input);
+ return template.requestBody("direct:ip", input, String.class);
+ }
+
+ @Path("/qs")
+ @GET
+ public String qs(String input) {
+ LOG.infof("Calling qs with %s", input);
+ return template.requestBody("direct:qs", input, String.class);
+ }
+
+ @Path("/uuid")
+ @GET
+ public String uuid(String input) {
+ LOG.infof("Calling uuid with %s", input);
+ return template.requestBody("direct:uuid", input, String.class);
+ }
+
+ @Path("/mac")
+ @GET
+ public String mac(String input) {
+ LOG.infof("Calling mac with %s", input);
+ return template.requestBody("direct:mac", input, String.class);
+ }
+
+ @Path("/path")
+ @GET
+ public String path(String input) {
+ LOG.infof("Calling path with %s", input);
+ return template.requestBody("direct:path", input, String.class);
+ }
+
+ @Path("/uri")
+ @GET
+ public String uri(String input) {
+ LOG.infof("Calling uri with %s", input);
+ return template.requestBody("direct:uri", input, String.class);
+ }
+
+ @Path("/num")
+ @GET
+ public String num(String input) {
+ LOG.infof("Calling num with %s", input);
+ return template.requestBody("direct:num", input, String.class);
+ }
+
+ @Path("/timestamp")
+ @GET
+ public String timestamp(String input) {
+ LOG.infof("Calling timestamp with %s", input);
+ return template.requestBody("direct:timestamp", input, String.class);
+ }
+
+ @Path("/flatten")
+ @GET
+ 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;
+ }
+
+ @Path("/namedOnly")
+ @GET
+ public String namedOnly(String input) {
+ LOG.infof("Calling namedOnly with %s", input);
+ Map<?, ?> r = template.requestBody("direct:namedOnly", input,
Map.class);
+ return String.format("%s-%s+%s", r.containsKey("URIPROTO"),
r.containsKey("URIHOST"), r.containsKey("URIPATHPARAM"));
+ }
+
+ @Path("/singleMatchPerLine")
+ @GET
+ public String singleMatchPerLine(String input) {
+ LOG.infof("Calling singleMatchPerLine with %s", input);
+ return template.requestBody("direct:singleMatchPerLine", input,
String.class);
+ }
+
+}
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
new file mode 100644
index 0000000..68f822c
--- /dev/null
+++
b/integration-tests/grok/src/main/java/org/apache/camel/quarkus/component/grok/it/GrokRoute.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.grok.it;
+
+import javax.enterprise.context.ApplicationScoped;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.grok.GrokDataFormat;
+import org.apache.camel.component.grok.GrokPattern;
+import org.apache.camel.spi.DataFormat;
+
+@ApplicationScoped
+public class GrokRoute extends RouteBuilder {
+
+ @Override
+ public void configure() {
+
+ bindToRegistry("myCustomPatternBean", new GrokPattern("FOOBAR",
"foo|bar"));
+ GrokPattern myAnotherCustomPatternBean = new
GrokPattern("FOOBAR_WITH_PREFIX_AND_SUFFIX", "-- %{FOOBAR}+ --");
+ bindToRegistry("myAnotherCustomPatternBean",
myAnotherCustomPatternBean);
+
+
from("direct:log").unmarshal().grok("%{COMMONAPACHELOG}").setBody(simple("ip:
${body[4][clientip]}"));
+
from("direct:fooBar").unmarshal().grok("%{FOOBAR_WITH_PREFIX_AND_SUFFIX:fooBar}").setBody(simple("${body[fooBar]}"));
+
from("direct:ip").unmarshal().grok("%{IP:ip}").setBody(simple("${body[0][ip]}
-> ${body[3][ip]}"));
+
+
from("direct:qs").unmarshal().grok("%{QS:qs}").setBody(simple("${body[qs]}"));
+
from("direct:uuid").unmarshal().grok("%{UUID:uuid}").setBody(simple("${body[uuid]}"));
+
from("direct:mac").unmarshal().grok("%{MAC:mac}").setBody(simple("${body[mac]}"));
+
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]}"));
+
+ DataFormat flattenDf = new GrokDataFormat("%{INT:i}
%{INT:i}").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);
+
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/GrokIT.java
b/integration-tests/grok/src/test/java/org/apache/camel/quarkus/component/grok/it/GrokIT.java
new file mode 100644
index 0000000..c9a2738
--- /dev/null
+++
b/integration-tests/grok/src/test/java/org/apache/camel/quarkus/component/grok/it/GrokIT.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.grok.it;
+
+import io.quarkus.test.junit.NativeImageTest;
+
+@NativeImageTest
+class GrokIT extends GrokTest {
+
+}
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
new file mode 100644
index 0000000..8701dae
--- /dev/null
+++
b/integration-tests/grok/src/test/java/org/apache/camel/quarkus/component/grok/it/GrokTest.java
@@ -0,0 +1,118 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+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;
+
+import static io.restassured.RestAssured.given;
+import static org.hamcrest.Matchers.is;
+
+@QuarkusTest
+class GrokTest {
+
+ private static final String LOGS = ""
+ + "64.242.88.10 - - [07/Mar/2004:16:05:49 -0800] \"GET
/twiki/bin/edit/Main/Double_bounce_sender?topicparent=Main.ConfigurationVariables
HTTP/1.1\" 401 12846\n"
+ + "64.242.88.11 - - [07/Mar/2004:16:06:51 -0800] \"GET
/twiki/bin/rdiff/TWiki/NewUserTemplate?rev1=1.3&rev2=1.2 HTTP/1.1\" 200 4523\n"
+ + "64.242.88.12 - - [07/Mar/2004:16:10:02 -0800] \"GET
/mailman/listinfo/hsdivision HTTP/1.1\" 200 6291\n"
+ + "64.242.88.13 - - [07/Mar/2004:16:11:58 -0800] \"GET
/twiki/bin/view/TWiki/WikiSyntax HTTP/1.1\" 200 7352\n"
+ + "64.242.88.14 - - [07/Mar/2004:16:20:55 -0800] \"GET
/twiki/bin/view/Main/DCCAndPostFix HTTP/1.1\" 200 5253\n";
+
+ @Test
+ public void grokLogShouldCaptureFifthIp() {
+
given().body(LOGS).get("/grok/log").then().statusCode(200).body(is("ip:
64.242.88.14"));
+ }
+
+ @Test
+ public void grokFooBarShouldCaptureCenterFoosAndBars() {
+ final String fooBar = "bar foobar bar -- barbarfoobarfoobar -- barbar";
+
given().body(fooBar).get("/grok/fooBar").then().statusCode(200).body(is("--
barbarfoobarfoobar --"));
+ }
+
+ @Test
+ public void grokSpaceDelimitedIpsShouldCaptureFirstAndFourthIps() {
+ final String ips = "178.21.82.201 178.21.82.202 178.21.82.203
178.21.82.204";
+
given().body(ips).get("/grok/ip").then().statusCode(200).body(is("178.21.82.201
-> 178.21.82.204"));
+ }
+
+ @Test
+ public void grokMixDelimitedIpsShouldCaptureFirstAndFourthIps() {
+ final String ips = "178.21.82.101
178.21.82.102\n178.21.82.103\r\n178.21.82.104";
+
given().body(ips).get("/grok/ip").then().statusCode(200).body(is("178.21.82.101
-> 178.21.82.104"));
+ }
+
+ @Test
+ public void grokQsShouldCaptureQuotedString() {
+ final String qs = "this is some \"quoted string\".";
+
given().body(qs).get("/grok/qs").then().statusCode(200).body(is("quoted
string"));
+ }
+
+ @Test
+ public void grokUuidShouldCaptureUuidAtEnd() {
+ final String uuid = "some 123e4567-e89b-12d3-a456-426614174000";
+
given().body(uuid).get("/grok/uuid").then().statusCode(200).body(is("123e4567-e89b-12d3-a456-426614174000"));
+ }
+
+ @Test
+ public void grokMacShouldCaptureMacAddressAtEnd() {
+ final String mac = "some:invalid:prefix:of:eth0:02:00:4c:4f:4f:50";
+
given().body(mac).get("/grok/mac").then().statusCode(200).body(is("02:00:4c:4f:4f:50"));
+ }
+
+ @Test
+ public void grokPathShouldCaptureMntRelativePath() {
+ final String path = "The file with path /home/user/../../mnt has been
deleted";
+
given().body(path).get("/grok/path").then().statusCode(200).body(is("/home/user/../../mnt"));
+ }
+
+ @Test
+ public void grokUriShouldCaptureCamelSiteUri() {
+ final String uri = "the site is at https://camel.apache.org/";
+
given().body(uri).get("/grok/uri").then().statusCode(200).body(is("https://camel.apache.org/"));
+ }
+
+ @Test
+ public void grokNumberShouldCapture123() {
+ final String number = "number is 123.";
+
given().body(number).get("/grok/num").then().statusCode(200).body(is("123"));
+ }
+
+ @Test
+ public void grokTimestampShouldCaptureMay26th() {
+ final String timestamp = "This test was created at
2019-05-26T10:54:15Z test convert";
+
given().body(timestamp).get("/grok/timestamp").then().statusCode(200).body(is("2019-05-26T10:54:15Z"));
+ }
+
+ @Test
+ public void grokFlattenShouldReturnGrokExceptionClassName() {
+ final String expected = GrokException.class.getName();
+ given().body("1
2").get("/grok/flatten").then().statusCode(200).body(is(expected));
+ }
+
+ @Test
+ public void grokNamedOnlyShouldNotCaptureUnamedExpressions() {
+ final String body = "https://github.com/apache/camel";
+
given().body(body).get("/grok/namedOnly").then().statusCode(200).body(is("false-false+false"));
+ }
+
+ @Test
+ public void grokSingleMathPerLineShouldCapture1AndThen3() {
+ given().body("1 2 \n
3").get("/grok/singleMatchPerLine").then().statusCode(200).body(is("1-3"));
+ }
+
+}
diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml
index a3fc1c8..3796189 100644
--- a/integration-tests/pom.xml
+++ b/integration-tests/pom.xml
@@ -93,6 +93,7 @@
<module>github</module>
<module>google</module>
<module>graphql</module>
+ <module>grok</module>
<module>http</module>
<module>hystrix</module>
<module>infinispan</module>
diff --git a/poms/bom/pom.xml b/poms/bom/pom.xml
index 4135874..b03c9b3 100644
--- a/poms/bom/pom.xml
+++ b/poms/bom/pom.xml
@@ -628,6 +628,11 @@
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
+ <artifactId>camel-grok</artifactId>
+ <version>${camel.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
<artifactId>camel-groovy</artifactId>
<version>${camel.version}</version>
</dependency>
@@ -1976,6 +1981,16 @@
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-grok</artifactId>
+ <version>${camel-quarkus.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-grok-deployment</artifactId>
+ <version>${camel-quarkus.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-groovy</artifactId>
<version>${camel-quarkus.version}</version>
</dependency>
diff --git a/tooling/scripts/test-categories.yaml
b/tooling/scripts/test-categories.yaml
index c8a6d9a..bcc4153 100644
--- a/tooling/scripts/test-categories.yaml
+++ b/tooling/scripts/test-categories.yaml
@@ -83,6 +83,7 @@ misc:
- braintree
- compression
- graphql
+ - grok
- jolt
- mustache
- mock