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 7c082ae Added support for flatpack dataformat fixes #796 7c082ae is described below commit 7c082ae3f362cfa10cd8e2c1d7000f6c2ebda47f Author: aldettinger <aldettin...@gmail.com> AuthorDate: Tue Aug 18 21:24:17 2020 +0200 Added support for flatpack dataformat fixes #796 --- docs/modules/ROOT/nav.adoc | 1 + docs/modules/ROOT/pages/reference/components.adoc | 5 +- docs/modules/ROOT/pages/reference/dataformats.adoc | 5 +- .../ROOT/pages/reference/extensions/flatpack.adoc | 30 +++++ docs/modules/ROOT/pages/reference/index.adoc | 5 +- extensions/flatpack/deployment/pom.xml | 63 ++++++++++ .../flatpack/deployment/FlatpackProcessor.java | 36 ++++++ extensions/flatpack/pom.xml | 39 ++++++ extensions/flatpack/runtime/pom.xml | 94 +++++++++++++++ .../main/resources/META-INF/quarkus-extension.yaml | 31 +++++ extensions/pom.xml | 1 + integration-tests/flatpack/pom.xml | 134 +++++++++++++++++++++ .../component/flatpack/it/FlatPackRoutes.java | 41 +++++++ .../component/flatpack/it/FlatpackResource.java | 81 +++++++++++++ .../src/main/resources/application.properties | 17 +++ .../mappings/INVENTORY-Delimited.pzmap.xml | 27 +++++ .../mappings/PEOPLE-FixedLength.pzmap.xml | 30 +++++ .../INVENTORY-CommaDelimitedWithQualifier.txt | 5 + .../src/test/data/fixed/PEOPLE-FixedLength.txt | 4 + .../quarkus/component/flatpack/it/FlatpackIT.java | 24 ++++ .../component/flatpack/it/FlatpackTest.java | 90 ++++++++++++++ integration-tests/pom.xml | 1 + poms/bom/pom.xml | 15 +++ tooling/scripts/test-categories.yaml | 1 + 24 files changed, 777 insertions(+), 3 deletions(-) diff --git a/docs/modules/ROOT/nav.adoc b/docs/modules/ROOT/nav.adoc index 764362e..a9a50bb 100644 --- a/docs/modules/ROOT/nav.adoc +++ b/docs/modules/ROOT/nav.adoc @@ -80,6 +80,7 @@ *** xref:reference/extensions/fhir.adoc[FHIR] *** xref:reference/extensions/file.adoc[File] *** xref:reference/extensions/file-watch.adoc[File Watch] +*** xref:reference/extensions/flatpack.adoc[Flatpack] *** xref:reference/extensions/ftp.adoc[FTP] *** xref:reference/extensions/github.adoc[GitHub] *** xref:reference/extensions/google-bigquery.adoc[Google BigQuery] diff --git a/docs/modules/ROOT/pages/reference/components.adoc b/docs/modules/ROOT/pages/reference/components.adoc index 5d7fc68..c686f6a 100644 --- a/docs/modules/ROOT/pages/reference/components.adoc +++ b/docs/modules/ROOT/pages/reference/components.adoc @@ -4,7 +4,7 @@ [camel-quarkus-components] = Camel components supported on Quarkus -156 components in 121 JAR artifacts (0 deprecated, 17 JVM only) +157 components in 122 JAR artifacts (0 deprecated, 17 JVM only) [width="100%",cols="4,1,1,1,5",options="header"] |=== @@ -190,6 +190,9 @@ Stable | 0.4.0 | Read and write files. | xref:reference/extensions/file-watch.adoc[File Watch] | camel-quarkus-file-watch | Native + Stable | 1.0.0 | Get notified about file events in a directory using java.nio.file.WatchService. +| xref:reference/extensions/flatpack.adoc[Flatpack] | camel-quarkus-flatpack | Native + +Stable | 1.1.0 | Parse fixed width and delimited files using the FlatPack library. + | xref:reference/extensions/ftp.adoc[FTP] | camel-quarkus-ftp | Native + Stable | 1.0.0 | Upload and download files to/from FTP servers. diff --git a/docs/modules/ROOT/pages/reference/dataformats.adoc b/docs/modules/ROOT/pages/reference/dataformats.adoc index e86b249..739e777 100644 --- a/docs/modules/ROOT/pages/reference/dataformats.adoc +++ b/docs/modules/ROOT/pages/reference/dataformats.adoc @@ -4,7 +4,7 @@ [camel-quarkus-dataformats] = Camel data formats supported on Quarkus -27 data formats in 22 JAR artifacts (0 deprecated, 1 JVM only) +28 data formats in 23 JAR artifacts (0 deprecated, 1 JVM only) [width="100%",cols="4,1,1,1,5",options="header"] |=== @@ -34,6 +34,9 @@ Stable | 0.3.0 | Marshall and unmarshall FHIR objects to/from JSON. | xref:reference/extensions/fhir.adoc[FHIR XML] | camel-quarkus-fhir | Native + Stable | 0.3.0 | Marshall and unmarshall FHIR objects to/from XML. +| xref:reference/extensions/flatpack.adoc[Flatpack] | camel-quarkus-flatpack | Native + +Stable | 1.1.0 | Marshal and unmarshal Java lists and maps to/from flat files (such as CSV, delimited, or fixed length formats) using Flatpack library. + | xref:reference/extensions/grok.adoc[Grok] | camel-quarkus-grok | Native + Stable | 1.0.0 | Unmarshal unstructured data to objects using Logstash based Grok patterns. diff --git a/docs/modules/ROOT/pages/reference/extensions/flatpack.adoc b/docs/modules/ROOT/pages/reference/extensions/flatpack.adoc new file mode 100644 index 0000000..7cd3da6 --- /dev/null +++ b/docs/modules/ROOT/pages/reference/extensions/flatpack.adoc @@ -0,0 +1,30 @@ +// Do not edit directly! +// This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page + +[[flatpack]] += Flatpack +:page-aliases: extensions/flatpack.adoc + +[.badges] +[.badge-key]##Since Camel Quarkus##[.badge-version]##1.1.0## [.badge-key]##JVM##[.badge-supported]##supported## [.badge-key]##Native##[.badge-supported]##supported## + +Parse fixed width and delimited files using the FlatPack library. + +== What's inside + +* https://camel.apache.org/components/latest/flatpack-component.html[Flatpack component], URI syntax: `flatpack:type:resourceUri` +* https://camel.apache.org/components/latest/dataformats/flatpack-dataformat.html[Flatpack data format] + +Please refer to the above links for usage and configuration details. + +== Maven coordinates + +[source,xml] +---- +<dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-flatpack</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/reference/index.adoc b/docs/modules/ROOT/pages/reference/index.adoc index aef8bfd..e477ede 100644 --- a/docs/modules/ROOT/pages/reference/index.adoc +++ b/docs/modules/ROOT/pages/reference/index.adoc @@ -17,7 +17,7 @@ In case you are missing some extension in the list: https://github.com/apache/camel-quarkus/issues[report] any issues you encounter. ==== -165 extensions (1 deprecated, 14 JVM only) +166 extensions (1 deprecated, 14 JVM only) [width="100%",cols="4,1,1,1,5",options="header"] |=== @@ -221,6 +221,9 @@ Stable | 0.4.0 | Read and write files. | xref:reference/extensions/file-watch.adoc[File Watch] | camel-quarkus-file-watch | Native + Stable | 1.0.0 | Get notified about file events in a directory using java.nio.file.WatchService. +| xref:reference/extensions/flatpack.adoc[Flatpack] | camel-quarkus-flatpack | Native + +Stable | 1.1.0 | Parse fixed width and delimited files using the FlatPack library. + | xref:reference/extensions/ftp.adoc[FTP] | camel-quarkus-ftp | Native + Stable | 1.0.0 | Upload and download files to/from FTP or SFTP servers. diff --git a/extensions/flatpack/deployment/pom.xml b/extensions/flatpack/deployment/pom.xml new file mode 100644 index 0000000..5034fed --- /dev/null +++ b/extensions/flatpack/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-flatpack-parent</artifactId> + <version>1.1.0-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <artifactId>camel-quarkus-flatpack-deployment</artifactId> + <name>Camel Quarkus :: Flatpack :: 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-flatpack</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/flatpack/deployment/src/main/java/org/apache/camel/quarkus/component/flatpack/deployment/FlatpackProcessor.java b/extensions/flatpack/deployment/src/main/java/org/apache/camel/quarkus/component/flatpack/deployment/FlatpackProcessor.java new file mode 100644 index 0000000..466ff1d --- /dev/null +++ b/extensions/flatpack/deployment/src/main/java/org/apache/camel/quarkus/component/flatpack/deployment/FlatpackProcessor.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.flatpack.deployment; + +import io.quarkus.deployment.annotations.BuildStep; +import io.quarkus.deployment.builditem.FeatureBuildItem; +import io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem; + +class FlatpackProcessor { + + private static final String FEATURE = "camel-flatpack"; + + @BuildStep + FeatureBuildItem feature() { + return new FeatureBuildItem(FEATURE); + } + + @BuildStep + NativeImageResourceBuildItem registerNativeImageResources() { + return new NativeImageResourceBuildItem("net/sf/flatpack/xml/flatpack.dtd", "fpconvert.properties"); + } +} diff --git a/extensions/flatpack/pom.xml b/extensions/flatpack/pom.xml new file mode 100644 index 0000000..4c69134 --- /dev/null +++ b/extensions/flatpack/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-flatpack-parent</artifactId> + <name>Camel Quarkus :: Flatpack</name> + <packaging>pom</packaging> + + <modules> + <module>deployment</module> + <module>runtime</module> + </modules> +</project> diff --git a/extensions/flatpack/runtime/pom.xml b/extensions/flatpack/runtime/pom.xml new file mode 100644 index 0000000..2ba8356 --- /dev/null +++ b/extensions/flatpack/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-flatpack-parent</artifactId> + <version>1.1.0-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <artifactId>camel-quarkus-flatpack</artifactId> + <name>Camel Quarkus :: Flatpack :: Runtime</name> + <description>Parse fixed width and delimited files using the FlatPack library.</description> + + <properties> + <firstVersion>1.1.0</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-flatpack</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/flatpack/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions/flatpack/runtime/src/main/resources/META-INF/quarkus-extension.yaml new file mode 100644 index 0000000..d974a66 --- /dev/null +++ b/extensions/flatpack/runtime/src/main/resources/META-INF/quarkus-extension.yaml @@ -0,0 +1,31 @@ +# +# 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 Flatpack" +description: "Parse fixed width and delimited files using the FlatPack library" +metadata: + guide: "https://camel.apache.org/components/latest/flatpack-component.html" + categories: + - "integration" + status: + - "stable" diff --git a/extensions/pom.xml b/extensions/pom.xml index 1879a80..3284d70 100644 --- a/extensions/pom.xml +++ b/extensions/pom.xml @@ -92,6 +92,7 @@ <module>fhir</module> <module>file</module> <module>file-watch</module> + <module>flatpack</module> <module>ftp</module> <module>github</module> <module>google-calendar</module> diff --git a/integration-tests/flatpack/pom.xml b/integration-tests/flatpack/pom.xml new file mode 100644 index 0000000..37ea04b --- /dev/null +++ b/integration-tests/flatpack/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-flatpack</artifactId> + <name>Camel Quarkus :: Integration Tests :: Flatpack</name> + <description>Integration tests for Camel Quarkus Flatpack 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-flatpack-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-direct</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-flatpack</artifactId> + </dependency> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-resteasy</artifactId> + </dependency> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-resteasy-jackson</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/flatpack/src/main/java/org/apache/camel/quarkus/component/flatpack/it/FlatPackRoutes.java b/integration-tests/flatpack/src/main/java/org/apache/camel/quarkus/component/flatpack/it/FlatPackRoutes.java new file mode 100644 index 0000000..2ee17ff --- /dev/null +++ b/integration-tests/flatpack/src/main/java/org/apache/camel/quarkus/component/flatpack/it/FlatPackRoutes.java @@ -0,0 +1,41 @@ +/* + * 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.flatpack.it; + +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.dataformat.flatpack.FlatpackDataFormat; + +public class FlatPackRoutes extends RouteBuilder { + + @Override + public void configure() { + // Testing delimited data format + FlatpackDataFormat delimitedDataFormat = new FlatpackDataFormat(); + delimitedDataFormat.setDefinition("mappings/INVENTORY-Delimited.pzmap.xml"); + from("direct:delimited-unmarshal").unmarshal(delimitedDataFormat); + from("direct:delimited-marshal").marshal(delimitedDataFormat); + + // Testing fixed length data format + FlatpackDataFormat fixedLengthDataFormat = new FlatpackDataFormat(); + fixedLengthDataFormat.setDefinition("mappings/PEOPLE-FixedLength.pzmap.xml"); + fixedLengthDataFormat.setFixed(true); + fixedLengthDataFormat.setIgnoreFirstRecord(false); + from("direct:fixed-length-unmarshal").unmarshal(fixedLengthDataFormat); + from("direct:fixed-length-marshal").marshal(fixedLengthDataFormat); + } + +} diff --git a/integration-tests/flatpack/src/main/java/org/apache/camel/quarkus/component/flatpack/it/FlatpackResource.java b/integration-tests/flatpack/src/main/java/org/apache/camel/quarkus/component/flatpack/it/FlatpackResource.java new file mode 100644 index 0000000..0686060 --- /dev/null +++ b/integration-tests/flatpack/src/main/java/org/apache/camel/quarkus/component/flatpack/it/FlatpackResource.java @@ -0,0 +1,81 @@ +/* + * 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.flatpack.it; + +import java.util.List; +import java.util.Map; + +import javax.enterprise.context.ApplicationScoped; +import javax.inject.Inject; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; + +import org.apache.camel.ProducerTemplate; +import org.apache.camel.component.flatpack.DataSetList; +import org.jboss.logging.Logger; + +@Path("/flatpack") +@ApplicationScoped +public class FlatpackResource { + + private static final Logger LOG = Logger.getLogger(FlatpackResource.class); + + @Inject + ProducerTemplate producerTemplate; + + @Path("/delimited-unmarshal") + @GET + @Consumes(MediaType.TEXT_PLAIN) + @Produces(MediaType.TEXT_PLAIN) + public String delimitedUnmarshal(String data) { + LOG.infof("Invoking delimitedUnmarshal with data: %s", data); + DataSetList unmarshalled = producerTemplate.requestBody("direct:delimited-unmarshal", data, DataSetList.class); + return unmarshalled.size() + "-" + unmarshalled.get(0).get("ITEM_DESC"); + } + + @Path("/delimited-marshal") + @GET + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.TEXT_PLAIN) + public String delimitedMarshal(List<Map<String, String>> object) { + LOG.infof("Invoking delimitedMarshal with object: %s", object); + return producerTemplate.requestBody("direct:delimited-marshal", object, String.class); + } + + @Path("/fixed-length-unmarshal") + @GET + @Consumes(MediaType.TEXT_PLAIN) + @Produces(MediaType.TEXT_PLAIN) + public String fixedLengthUnmarshal(String data) { + LOG.infof("Invoking fixedLengthUnmarshal with data: %s", data); + DataSetList unmarshalled = producerTemplate.requestBody("direct:fixed-length-unmarshal", data, DataSetList.class); + return unmarshalled.size() + "-" + unmarshalled.get(0).get("FIRSTNAME"); + } + + @Path("/fixed-length-marshal") + @GET + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.TEXT_PLAIN) + public String fixedLengthMarshal(List<Map<String, String>> object) { + LOG.infof("Invoking fixedLengthMarshal with object: %s", object); + return producerTemplate.requestBody("direct:fixed-length-marshal", object, String.class); + } + +} diff --git a/integration-tests/flatpack/src/main/resources/application.properties b/integration-tests/flatpack/src/main/resources/application.properties new file mode 100644 index 0000000..e96b84b --- /dev/null +++ b/integration-tests/flatpack/src/main/resources/application.properties @@ -0,0 +1,17 @@ +## --------------------------------------------------------------------------- +## 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. +## --------------------------------------------------------------------------- +quarkus.camel.native.resources.include-patterns = mappings/*.pzmap.xml diff --git a/integration-tests/flatpack/src/main/resources/mappings/INVENTORY-Delimited.pzmap.xml b/integration-tests/flatpack/src/main/resources/mappings/INVENTORY-Delimited.pzmap.xml new file mode 100644 index 0000000..1ae4fc0 --- /dev/null +++ b/integration-tests/flatpack/src/main/resources/mappings/INVENTORY-Delimited.pzmap.xml @@ -0,0 +1,27 @@ +<?xml version='1.0'?> +<!-- + + 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. + +--> +<!DOCTYPE PZMAP SYSTEM + "flatpack.dtd" > +<PZMAP> + <COLUMN name="ITEM_DESC" /> + <COLUMN name="IN_STOCK" /> + <COLUMN name="PRICE" /> + <COLUMN name="LAST_RECV_DT" /> +</PZMAP> diff --git a/integration-tests/flatpack/src/main/resources/mappings/PEOPLE-FixedLength.pzmap.xml b/integration-tests/flatpack/src/main/resources/mappings/PEOPLE-FixedLength.pzmap.xml new file mode 100644 index 0000000..187451c --- /dev/null +++ b/integration-tests/flatpack/src/main/resources/mappings/PEOPLE-FixedLength.pzmap.xml @@ -0,0 +1,30 @@ +<?xml version='1.0'?> +<!-- + + 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. + +--> +<!DOCTYPE PZMAP SYSTEM + "flatpack.dtd" > +<PZMAP> + <COLUMN name="FIRSTNAME" length="35" /> + <COLUMN name="LASTNAME" length="35" /> + <COLUMN name="ADDRESS" length="100" /> + <COLUMN name="CITY" length="100" /> + <COLUMN name="STATE" length="2" /> + <COLUMN name="ZIP" length="5" /> + +</PZMAP> diff --git a/integration-tests/flatpack/src/test/data/delim/INVENTORY-CommaDelimitedWithQualifier.txt b/integration-tests/flatpack/src/test/data/delim/INVENTORY-CommaDelimitedWithQualifier.txt new file mode 100644 index 0000000..c38818b --- /dev/null +++ b/integration-tests/flatpack/src/test/data/delim/INVENTORY-CommaDelimitedWithQualifier.txt @@ -0,0 +1,5 @@ +"ITEM_DESC","IN_STOCK","PRICE","LAST_RECV_DT" +"SOME VALVE","2","5.00","20050101" +"AN ENGINE","100","1000.00","20040601" +"A BELT","45",".50","20030101" +"A BOLT","1000","2.75","20050101" diff --git a/integration-tests/flatpack/src/test/data/fixed/PEOPLE-FixedLength.txt b/integration-tests/flatpack/src/test/data/fixed/PEOPLE-FixedLength.txt new file mode 100644 index 0000000..42fc0f4 --- /dev/null +++ b/integration-tests/flatpack/src/test/data/fixed/PEOPLE-FixedLength.txt @@ -0,0 +1,4 @@ +JOHN DOE 1234 CIRCLE CT ELYRIA OH44035 +JIMMY SMITH 180 SOME ST AVON OH44011 +JANE DOE 111 MILKY WY AMHERST OH44001 +FRED FLINTSTONE 123 ROCKY WY BEDROCK AZ12345 diff --git a/integration-tests/flatpack/src/test/java/org/apache/camel/quarkus/component/flatpack/it/FlatpackIT.java b/integration-tests/flatpack/src/test/java/org/apache/camel/quarkus/component/flatpack/it/FlatpackIT.java new file mode 100644 index 0000000..7aebda5 --- /dev/null +++ b/integration-tests/flatpack/src/test/java/org/apache/camel/quarkus/component/flatpack/it/FlatpackIT.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.flatpack.it; + +import io.quarkus.test.junit.NativeImageTest; + +@NativeImageTest +class FlatpackIT extends FlatpackTest { + +} diff --git a/integration-tests/flatpack/src/test/java/org/apache/camel/quarkus/component/flatpack/it/FlatpackTest.java b/integration-tests/flatpack/src/test/java/org/apache/camel/quarkus/component/flatpack/it/FlatpackTest.java new file mode 100644 index 0000000..da1b563 --- /dev/null +++ b/integration-tests/flatpack/src/test/java/org/apache/camel/quarkus/component/flatpack/it/FlatpackTest.java @@ -0,0 +1,90 @@ +/* + * 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.flatpack.it; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +import io.quarkus.test.junit.QuarkusTest; +import io.restassured.http.ContentType; +import org.apache.camel.converter.IOConverter; +import org.junit.jupiter.api.Test; + +import static io.restassured.RestAssured.given; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.startsWith; + +@QuarkusTest +class FlatpackTest { + + @Test + public void delimitedUnmarshalShouldSucceed() throws IOException { + String data = IOConverter.toString(new File("src/test/data/delim/INVENTORY-CommaDelimitedWithQualifier.txt"), null); + + given().body(data).when().get("/flatpack/delimited-unmarshal").then().statusCode(200).body(is("4-SOME VALVE")); + } + + @Test + public void delimitedMarshalShouldSucceed() { + List<Map<String, String>> data = new ArrayList<>(); + Map<String, String> firstRow = new LinkedHashMap<>(); + firstRow.put("ITEM_DESC", "SOME VALVE"); + firstRow.put("IN_STOCK", "2"); + firstRow.put("PRICE", "5.00"); + firstRow.put("LAST_RECV_DT", "20050101"); + data.add(firstRow); + + Map<String, String> secondRow = new LinkedHashMap<>(); + secondRow.put("ITEM_DESC", "AN ENGINE"); + secondRow.put("IN_STOCK", "100"); + secondRow.put("PRICE", "1000.00"); + secondRow.put("LAST_RECV_DT", "20040601"); + data.add(secondRow); + + String expected = "ITEM_DESC,IN_STOCK,PRICE,LAST_RECV_DT\nAN ENGINE,100,1000.00,20040601\n"; + given().contentType(ContentType.JSON).body(data).when().get("/flatpack/delimited-marshal").then().statusCode(200) + .body(is(expected)); + } + + @Test + public void fixedLengthUnmarshalShouldSucceed() throws IOException { + String data = IOConverter.toString(new File("src/test/data/fixed/PEOPLE-FixedLength.txt"), null); + + given().body(data).when().get("/flatpack/fixed-length-unmarshal").then().statusCode(200).body(is("4-JOHN")); + } + + @Test + public void fixedLengthMarshalShouldSucceed() { + List<Map<String, Object>> data = new ArrayList<>(); + Map<String, Object> row = new LinkedHashMap<>(); + row.put("FIRSTNAME", "JOHN"); + row.put("LASTNAME", "DOE"); + row.put("ADDRESS", "1234 CIRCLE CT"); + row.put("CITY", "ELYRIA"); + row.put("STATE", "OH"); + row.put("ZIP", "44035"); + data.add(row); + + given().contentType(ContentType.JSON).body(data).when().get("/flatpack/fixed-length-marshal").then().statusCode(200) + .body(startsWith("JOHN DOE")); + } + +} diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml index afcb1c3..05d91bb 100644 --- a/integration-tests/pom.xml +++ b/integration-tests/pom.xml @@ -89,6 +89,7 @@ <module>exec</module> <module>fhir</module> <module>file</module> + <module>flatpack</module> <module>ftp</module> <module>github</module> <module>google</module> diff --git a/poms/bom/pom.xml b/poms/bom/pom.xml index b3dcdb2..93adef3 100644 --- a/poms/bom/pom.xml +++ b/poms/bom/pom.xml @@ -583,6 +583,11 @@ </dependency> <dependency> <groupId>org.apache.camel</groupId> + <artifactId>camel-flatpack</artifactId> + <version>${camel.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> <artifactId>camel-ftp</artifactId> <version>${camel.version}</version> </dependency> @@ -1896,6 +1901,16 @@ </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-flatpack</artifactId> + <version>${camel-quarkus.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-flatpack-deployment</artifactId> + <version>${camel-quarkus.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-ftp</artifactId> <version>${camel-quarkus.version}</version> </dependency> diff --git a/tooling/scripts/test-categories.yaml b/tooling/scripts/test-categories.yaml index 2790afe..a563a20 100644 --- a/tooling/scripts/test-categories.yaml +++ b/tooling/scripts/test-categories.yaml @@ -82,6 +82,7 @@ messaging: misc: - braintree - compression + - flatpack - graphql - grok - jolt