This is an automated email from the ASF dual-hosted git repository. github-bot pushed a commit to branch camel-main in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
commit 19ee699ac881ecd927eb7cfa050a393ac4eee775 Author: JiriOndrusek <[email protected]> AuthorDate: Thu Sep 4 17:24:49 2025 +0200 Fixes #7675 Add support of camel-groovy-xml extension --- catalog/pom.xml | 13 ++ .../ROOT/examples/dataformats/groovyXml.yml | 13 ++ docs/modules/ROOT/nav.adoc | 1 + .../pages/reference/extensions/groovy-xml.adoc | 56 +++++++++ extensions/groovy-xml/deployment/pom.xml | 67 +++++++++++ .../groovy/xml/deployment/GroovyXmlProcessor.java | 30 +++++ extensions/groovy-xml/pom.xml | 39 ++++++ extensions/groovy-xml/runtime/pom.xml | 105 ++++++++++++++++ .../runtime/src/main/doc/limitations.adoc | 5 + .../main/resources/META-INF/quarkus-extension.yaml | 33 +++++ extensions/pom.xml | 1 + integration-tests/groovy-xml/pom.xml | 133 +++++++++++++++++++++ .../component/groovy/xml/it/GroovyXmlResource.java | 64 ++++++++++ .../component/groovy/xml/it/GroovyXmlRoutes.java | 32 +++++ .../src/main/resources/application.properties | 19 +++ .../component/groovy/xml/it/GroovyXmlIT.java | 24 ++++ .../component/groovy/xml/it/GroovyXmlTest.java | 70 +++++++++++ integration-tests/pom.xml | 1 + poms/bom/pom.xml | 15 +++ poms/bom/src/main/generated/flattened-full-pom.xml | 15 +++ .../src/main/generated/flattened-reduced-pom.xml | 20 ++++ .../generated/flattened-reduced-verbose-pom.xml | 20 ++++ tooling/scripts/test-categories.yaml | 1 + 23 files changed, 777 insertions(+) diff --git a/catalog/pom.xml b/catalog/pom.xml index 93d7d907df..430179f4f6 100644 --- a/catalog/pom.xml +++ b/catalog/pom.xml @@ -1644,6 +1644,19 @@ </exclusion> </exclusions> </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-groovy-xml</artifactId> + <version>${project.version}</version> + <type>pom</type> + <scope>test</scope> + <exclusions> + <exclusion> + <groupId>*</groupId> + <artifactId>*</artifactId> + </exclusion> + </exclusions> + </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-grpc</artifactId> diff --git a/docs/modules/ROOT/examples/dataformats/groovyXml.yml b/docs/modules/ROOT/examples/dataformats/groovyXml.yml new file mode 100644 index 0000000000..57b62e94b0 --- /dev/null +++ b/docs/modules/ROOT/examples/dataformats/groovyXml.yml @@ -0,0 +1,13 @@ +# Do not edit directly! +# This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page +cqArtifactId: camel-quarkus-groovy-xml +cqArtifactIdBase: groovy-xml +cqNativeSupported: true +cqStatus: Stable +cqDeprecated: false +cqJvmSince: 3.27.0 +cqNativeSince: 3.27.0 +cqCamelPartName: groovyXml +cqCamelPartTitle: Groovy XML +cqCamelPartDescription: Transform between XML and Groovy Node (Map structure) objects. +cqExtensionPageTitle: Groovy XML diff --git a/docs/modules/ROOT/nav.adoc b/docs/modules/ROOT/nav.adoc index bd73535f5e..24b7ef8498 100644 --- a/docs/modules/ROOT/nav.adoc +++ b/docs/modules/ROOT/nav.adoc @@ -147,6 +147,7 @@ *** xref:reference/extensions/graphql.adoc[GraphQL] *** xref:reference/extensions/grok.adoc[Grok] *** xref:reference/extensions/groovy.adoc[Groovy] +*** xref:reference/extensions/groovy-xml.adoc[Groovy XML] *** xref:reference/extensions/gson.adoc[Gson] *** xref:reference/extensions/guava-eventbus.adoc[Guava EventBus] *** xref:reference/extensions/hl7.adoc[HL7] diff --git a/docs/modules/ROOT/pages/reference/extensions/groovy-xml.adoc b/docs/modules/ROOT/pages/reference/extensions/groovy-xml.adoc new file mode 100644 index 0000000000..b4c659a9ac --- /dev/null +++ b/docs/modules/ROOT/pages/reference/extensions/groovy-xml.adoc @@ -0,0 +1,56 @@ +// Do not edit directly! +// This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page +[id="extensions-groovy-xml"] += Groovy XML +:linkattrs: +:cq-artifact-id: camel-quarkus-groovy-xml +:cq-native-supported: true +:cq-status: Stable +:cq-status-deprecation: Stable +:cq-description: Transform between XML and Groovy Node (Map structure) objects. +:cq-deprecated: false +:cq-jvm-since: 3.27.0 +:cq-native-since: 3.27.0 + +ifeval::[{doc-show-badges} == true] +[.badges] +[.badge-key]##JVM since##[.badge-supported]##3.27.0## [.badge-key]##Native since##[.badge-supported]##3.27.0## +endif::[] + +Transform between XML and Groovy Node (Map structure) objects. + +[id="extensions-groovy-xml-whats-inside"] +== What's inside + +* xref:{cq-camel-components}:dataformats:groovyXml-dataformat.adoc[Groovy XML data format] + +Please refer to the above link for usage and configuration details. + +[id="extensions-groovy-xml-maven-coordinates"] +== Maven coordinates + +https://{link-quarkus-code-generator}/?extension-search=camel-quarkus-groovy-xml[Create a new project with this extension on {link-quarkus-code-generator}, window="_blank"] + +Or add the coordinates to your existing project: + +[source,xml] +---- +<dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-groovy-xml</artifactId> +</dependency> +---- +ifeval::[{doc-show-user-guide-link} == true] +Check the xref:user-guide/index.adoc[User guide] for more information about writing Camel Quarkus applications. +endif::[] + +[id="extensions-groovy-xml-camel-quarkus-limitations"] +== Camel Quarkus limitations + +[id="extensions-groovy-xml-limitations-native-mode-limitations"] +=== Native mode limitations + +[IMPORTANT] +==== +Due to an issue in GraalVM / Mandrel 23.1.x, you *must* build your native application with the https://quarkus.io/guides/all-config#quarkus-core_quarkus-native-report-errors-at-runtime[`--report-unsupported-elements-at-runtime`] option. You can do this by adding the following configuration to `application.properties`. + diff --git a/extensions/groovy-xml/deployment/pom.xml b/extensions/groovy-xml/deployment/pom.xml new file mode 100644 index 0000000000..6d8081ee5e --- /dev/null +++ b/extensions/groovy-xml/deployment/pom.xml @@ -0,0 +1,67 @@ +<?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-groovy-xml-parent</artifactId> + <version>3.27.0-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <artifactId>camel-quarkus-groovy-xml-deployment</artifactId> + <name>Camel Quarkus :: Groovy XML :: 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-groovy-xml</artifactId> + </dependency> + <dependency> + <groupId>io.quarkiverse.groovy</groupId> + <artifactId>quarkus-groovy-deployment</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/groovy-xml/deployment/src/main/java/org/apache/camel/quarkus/component/groovy/xml/deployment/GroovyXmlProcessor.java b/extensions/groovy-xml/deployment/src/main/java/org/apache/camel/quarkus/component/groovy/xml/deployment/GroovyXmlProcessor.java new file mode 100644 index 0000000000..8673a123e9 --- /dev/null +++ b/extensions/groovy-xml/deployment/src/main/java/org/apache/camel/quarkus/component/groovy/xml/deployment/GroovyXmlProcessor.java @@ -0,0 +1,30 @@ +/* + * 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.groovy.xml.deployment; + +import io.quarkus.deployment.annotations.BuildStep; +import io.quarkus.deployment.builditem.FeatureBuildItem; + +class GroovyXmlProcessor { + + private static final String FEATURE = "camel-groovy-xml"; + + @BuildStep + FeatureBuildItem feature() { + return new FeatureBuildItem(FEATURE); + } +} diff --git a/extensions/groovy-xml/pom.xml b/extensions/groovy-xml/pom.xml new file mode 100644 index 0000000000..a619d9823d --- /dev/null +++ b/extensions/groovy-xml/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-extensions</artifactId> + <version>3.27.0-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <artifactId>camel-quarkus-groovy-xml-parent</artifactId> + <name>Camel Quarkus :: Groovy XML</name> + <packaging>pom</packaging> + + <modules> + <module>deployment</module> + <module>runtime</module> + </modules> +</project> diff --git a/extensions/groovy-xml/runtime/pom.xml b/extensions/groovy-xml/runtime/pom.xml new file mode 100644 index 0000000000..11f11f59ca --- /dev/null +++ b/extensions/groovy-xml/runtime/pom.xml @@ -0,0 +1,105 @@ +<?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-groovy-xml-parent</artifactId> + <version>3.27.0-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <artifactId>camel-quarkus-groovy-xml</artifactId> + <name>Camel Quarkus :: Groovy XML :: Runtime</name> + <description>Transform between XML and Groovy Node (Map structure) objects.</description> + + <properties> + <camel.quarkus.jvmSince>3.27.0</camel.quarkus.jvmSince> + <camel.quarkus.nativeSince>3.27.0</camel.quarkus.nativeSince> + </properties> + + <dependencies> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-core</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-groovy-xml</artifactId> + </dependency> + <dependency> + <groupId>io.quarkiverse.groovy</groupId> + <artifactId>quarkus-groovy</artifactId> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-extension-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> + + + <profiles> + <profile> + <id>full</id> + <activation> + <property> + <name>!quickly</name> + </property> + </activation> + <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> + </plugins> + </build> + </profile> + </profiles> +</project> diff --git a/extensions/groovy-xml/runtime/src/main/doc/limitations.adoc b/extensions/groovy-xml/runtime/src/main/doc/limitations.adoc new file mode 100644 index 0000000000..0052c79f6c --- /dev/null +++ b/extensions/groovy-xml/runtime/src/main/doc/limitations.adoc @@ -0,0 +1,5 @@ +=== Native mode limitations + +[IMPORTANT] +==== +Due to an issue in GraalVM / Mandrel 23.1.x, you *must* build your native application with the https://quarkus.io/guides/all-config#quarkus-core_quarkus-native-report-errors-at-runtime[`--report-unsupported-elements-at-runtime`] option. You can do this by adding the following configuration to `application.properties`. diff --git a/extensions/groovy-xml/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions/groovy-xml/runtime/src/main/resources/META-INF/quarkus-extension.yaml new file mode 100644 index 0000000000..a4c6f9dba5 --- /dev/null +++ b/extensions/groovy-xml/runtime/src/main/resources/META-INF/quarkus-extension.yaml @@ -0,0 +1,33 @@ +# +# 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 Groovy XML" +description: "Transform between XML and Groovy Node (Map structure) objects" +metadata: + icon-url: "https://raw.githubusercontent.com/apache/camel-website/main/antora-ui-camel/src/img/logo-d.svg" + sponsor: "Apache Software Foundation" + guide: "https://camel.apache.org/camel-quarkus/latest/reference/extensions/groovy-xml.html" + categories: + - "integration" + status: + - "stable" diff --git a/extensions/pom.xml b/extensions/pom.xml index 32c7e01aa5..56b07a9874 100644 --- a/extensions/pom.xml +++ b/extensions/pom.xml @@ -128,6 +128,7 @@ <module>graphql</module> <module>grok</module> <module>groovy</module> + <module>groovy-xml</module> <module>grpc</module> <module>gson</module> <module>hashicorp-vault</module> diff --git a/integration-tests/groovy-xml/pom.xml b/integration-tests/groovy-xml/pom.xml new file mode 100644 index 0000000000..68ed26c275 --- /dev/null +++ b/integration-tests/groovy-xml/pom.xml @@ -0,0 +1,133 @@ +<?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-it</artifactId> + <version>3.27.0-SNAPSHOT</version> + <relativePath>../../poms/build-parent-it/pom.xml</relativePath> + </parent> + + <artifactId>camel-quarkus-integration-test-groovy-xml</artifactId> + <name>Camel Quarkus :: Integration Tests :: Groovy XML</name> + <description>Integration tests for Camel Quarkus Groovy XML extension</description> + + <dependencies> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-groovy-xml</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-direct</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> + + <profiles> + <profile> + <id>native</id> + <activation> + <property> + <name>native</name> + </property> + </activation> + <properties> + <quarkus.native.enabled>true</quarkus.native.enabled> + </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> + <profile> + <id>virtualDependencies</id> + <activation> + <property> + <name>!noVirtualDependencies</name> + </property> + </activation> + <dependencies> + <!-- The following dependencies guarantee that this module is built after them. You can update them by running `mvn process-resources -Pformat -N` from the source tree root directory --> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-direct-deployment</artifactId> + <version>${project.version}</version> + <type>pom</type> + <scope>test</scope> + <exclusions> + <exclusion> + <groupId>*</groupId> + <artifactId>*</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-groovy-xml-deployment</artifactId> + <version>${project.version}</version> + <type>pom</type> + <scope>test</scope> + <exclusions> + <exclusion> + <groupId>*</groupId> + <artifactId>*</artifactId> + </exclusion> + </exclusions> + </dependency> + </dependencies> + </profile> + </profiles> + +</project> diff --git a/integration-tests/groovy-xml/src/main/java/org/apache/camel/quarkus/component/groovy/xml/it/GroovyXmlResource.java b/integration-tests/groovy-xml/src/main/java/org/apache/camel/quarkus/component/groovy/xml/it/GroovyXmlResource.java new file mode 100644 index 0000000000..e7d12bbedc --- /dev/null +++ b/integration-tests/groovy-xml/src/main/java/org/apache/camel/quarkus/component/groovy/xml/it/GroovyXmlResource.java @@ -0,0 +1,64 @@ +/* + * 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.groovy.xml.it; + +import java.util.List; + +import groovy.util.Node; +import groovy.xml.XmlParser; +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.inject.Inject; +import jakarta.ws.rs.Consumes; +import jakarta.ws.rs.POST; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.core.MediaType; +import org.apache.camel.ProducerTemplate; + +@Path("/groovy-xml") +@ApplicationScoped +public class GroovyXmlResource { + + @Inject + ProducerTemplate producerTemplate; + + @Path("/unmarshal") + @POST + @Consumes(MediaType.TEXT_PLAIN) + @Produces(MediaType.APPLICATION_JSON) + @SuppressWarnings("unchecked") + public List<String> unmarshal(String message) throws Exception { + final Node node = producerTemplate.requestBody("direct:unmarshal", message, Node.class); + + //extract ids from the children + return node.children().stream().map(ch -> ((Node) ch).attribute("id")).toList(); + } + + @Path("/marshal") + @POST + @Consumes(MediaType.TEXT_PLAIN) + @Produces(MediaType.TEXT_PLAIN) + public String marshal(String message) throws Exception { + + final XmlParser parser = new XmlParser(); + parser.setTrimWhitespace(false); + final Node node = parser.parseText(message); + + return producerTemplate.requestBody("direct:marshal", node, String.class); + } + +} diff --git a/integration-tests/groovy-xml/src/main/java/org/apache/camel/quarkus/component/groovy/xml/it/GroovyXmlRoutes.java b/integration-tests/groovy-xml/src/main/java/org/apache/camel/quarkus/component/groovy/xml/it/GroovyXmlRoutes.java new file mode 100644 index 0000000000..6e5b075385 --- /dev/null +++ b/integration-tests/groovy-xml/src/main/java/org/apache/camel/quarkus/component/groovy/xml/it/GroovyXmlRoutes.java @@ -0,0 +1,32 @@ +/* + * 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.groovy.xml.it; + +import org.apache.camel.builder.RouteBuilder; + +public class GroovyXmlRoutes extends RouteBuilder { + + @Override + public void configure() throws Exception { + from("direct:marshal").streamCache(false) + .marshal().groovyXml(); + + from("direct:unmarshal") + .unmarshal().groovyXml(); + } + +} diff --git a/integration-tests/groovy-xml/src/main/resources/application.properties b/integration-tests/groovy-xml/src/main/resources/application.properties new file mode 100644 index 0000000000..63ea5b4ada --- /dev/null +++ b/integration-tests/groovy-xml/src/main/resources/application.properties @@ -0,0 +1,19 @@ +## --------------------------------------------------------------------------- +## 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. +## --------------------------------------------------------------------------- + +# TODO: Remove this: https://github.com/apache/camel-quarkus/issues/7361 +quarkus.native.report-errors-at-runtime=true diff --git a/integration-tests/groovy-xml/src/test/java/org/apache/camel/quarkus/component/groovy/xml/it/GroovyXmlIT.java b/integration-tests/groovy-xml/src/test/java/org/apache/camel/quarkus/component/groovy/xml/it/GroovyXmlIT.java new file mode 100644 index 0000000000..10413e8493 --- /dev/null +++ b/integration-tests/groovy-xml/src/test/java/org/apache/camel/quarkus/component/groovy/xml/it/GroovyXmlIT.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.groovy.xml.it; + +import io.quarkus.test.junit.QuarkusIntegrationTest; + +@QuarkusIntegrationTest +class GroovyXmlIT extends GroovyXmlTest { + +} diff --git a/integration-tests/groovy-xml/src/test/java/org/apache/camel/quarkus/component/groovy/xml/it/GroovyXmlTest.java b/integration-tests/groovy-xml/src/test/java/org/apache/camel/quarkus/component/groovy/xml/it/GroovyXmlTest.java new file mode 100644 index 0000000000..bddb0353ce --- /dev/null +++ b/integration-tests/groovy-xml/src/test/java/org/apache/camel/quarkus/component/groovy/xml/it/GroovyXmlTest.java @@ -0,0 +1,70 @@ +/* + * 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.groovy.xml.it; + +import io.quarkus.test.junit.QuarkusTest; +import io.restassured.RestAssured; +import io.restassured.http.ContentType; +import org.hamcrest.Matchers; +import org.junit.jupiter.api.Test; + +@QuarkusTest +class GroovyXmlTest { + + private static final String BOOKS = """ + <library> + <book id="bk101"> + <title>No Title</title> + <author>F. Scott Fitzgerald</author> + <year>1925</year> + <genre>Classic</genre> + </book> + <book id="bk102"> + <title>1984</title> + <author>George Orwell</author> + <year>1949</year> + <genre>Dystopian</genre> + </book> + </library> + """; + + @Test + public void testUnmarshal() throws Exception { + + RestAssured.given() + .contentType(ContentType.TEXT) + .body(BOOKS) + .post("/groovy-xml/unmarshal") // + .then() + .statusCode(200) + .body(org.hamcrest.Matchers.containsString("bk101")) + .body(org.hamcrest.Matchers.containsString("bk102")); + } + + @Test + public void testMarshal() throws Exception { + //it is not possible to send Node, therefore conversion from xml to Node is done on Resource instance + RestAssured.given() + .contentType(ContentType.TEXT) + .body(BOOKS) + .post("/groovy-xml/marshal") // + .then() + .statusCode(200) + .body(Matchers.is(BOOKS)); + } + +} diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml index 184bd89b52..41e2693f1d 100644 --- a/integration-tests/pom.xml +++ b/integration-tests/pom.xml @@ -102,6 +102,7 @@ <module>graphql</module> <module>grok</module> <module>groovy</module> + <module>groovy-xml</module> <module>grpc</module> <module>hashicorp-vault</module> <module>hazelcast</module> diff --git a/poms/bom/pom.xml b/poms/bom/pom.xml index 3cd0ec65c2..39dea66401 100644 --- a/poms/bom/pom.xml +++ b/poms/bom/pom.xml @@ -1456,6 +1456,11 @@ <artifactId>camel-groovy</artifactId> <version>${camel.version}</version> </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-groovy-xml</artifactId> + <version>${camel.version}</version> + </dependency> <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-grpc</artifactId> @@ -4401,6 +4406,16 @@ <artifactId>camel-quarkus-groovy-deployment</artifactId> <version>${camel-quarkus.version}</version> </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-groovy-xml</artifactId> + <version>${camel-quarkus.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-groovy-xml-deployment</artifactId> + <version>${camel-quarkus.version}</version> + </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-grpc</artifactId> diff --git a/poms/bom/src/main/generated/flattened-full-pom.xml b/poms/bom/src/main/generated/flattened-full-pom.xml index a91a6f4cfd..6a2bb17cd5 100644 --- a/poms/bom/src/main/generated/flattened-full-pom.xml +++ b/poms/bom/src/main/generated/flattened-full-pom.xml @@ -1372,6 +1372,11 @@ <artifactId>camel-groovy</artifactId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> <version>4.15.0-SNAPSHOT</version><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> </dependency> + <dependency> + <groupId>org.apache.camel</groupId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> + <artifactId>camel-groovy-xml</artifactId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> + <version>4.15.0-SNAPSHOT</version><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> + </dependency> <dependency> <groupId>org.apache.camel</groupId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> <artifactId>camel-grpc</artifactId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> @@ -4289,6 +4294,16 @@ <artifactId>camel-quarkus-groovy-deployment</artifactId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> <version>3.27.0-SNAPSHOT</version><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> + <artifactId>camel-quarkus-groovy-xml</artifactId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> + <version>3.27.0-SNAPSHOT</version><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> + <artifactId>camel-quarkus-groovy-xml-deployment</artifactId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> + <version>3.27.0-SNAPSHOT</version><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> + </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> <artifactId>camel-quarkus-grpc</artifactId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> diff --git a/poms/bom/src/main/generated/flattened-reduced-pom.xml b/poms/bom/src/main/generated/flattened-reduced-pom.xml index ef2557a5bc..0c68c0c7e0 100644 --- a/poms/bom/src/main/generated/flattened-reduced-pom.xml +++ b/poms/bom/src/main/generated/flattened-reduced-pom.xml @@ -1367,6 +1367,11 @@ <artifactId>camel-groovy</artifactId> <version>4.15.0-SNAPSHOT</version> </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-groovy-xml</artifactId> + <version>4.15.0-SNAPSHOT</version> + </dependency> <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-grpc</artifactId> @@ -4279,6 +4284,16 @@ <artifactId>camel-quarkus-groovy-deployment</artifactId> <version>3.27.0-SNAPSHOT</version> </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-groovy-xml</artifactId> + <version>3.27.0-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-groovy-xml-deployment</artifactId> + <version>3.27.0-SNAPSHOT</version> + </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-grpc</artifactId> @@ -8363,6 +8378,11 @@ <artifactId>groovy</artifactId> <version>4.0.28</version> </dependency> + <dependency> + <groupId>org.apache.groovy</groupId> + <artifactId>groovy-xml</artifactId> + <version>4.0.28</version> + </dependency> <dependency> <groupId>software.amazon.awssdk</groupId> <artifactId>annotations</artifactId> diff --git a/poms/bom/src/main/generated/flattened-reduced-verbose-pom.xml b/poms/bom/src/main/generated/flattened-reduced-verbose-pom.xml index 6491a3f0fc..81e9847d0e 100644 --- a/poms/bom/src/main/generated/flattened-reduced-verbose-pom.xml +++ b/poms/bom/src/main/generated/flattened-reduced-verbose-pom.xml @@ -1367,6 +1367,11 @@ <artifactId>camel-groovy</artifactId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> <version>4.15.0-SNAPSHOT</version><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> </dependency> + <dependency> + <groupId>org.apache.camel</groupId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> + <artifactId>camel-groovy-xml</artifactId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> + <version>4.15.0-SNAPSHOT</version><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> + </dependency> <dependency> <groupId>org.apache.camel</groupId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> <artifactId>camel-grpc</artifactId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> @@ -4279,6 +4284,16 @@ <artifactId>camel-quarkus-groovy-deployment</artifactId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> <version>3.27.0-SNAPSHOT</version><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> + <artifactId>camel-quarkus-groovy-xml</artifactId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> + <version>3.27.0-SNAPSHOT</version><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> + <artifactId>camel-quarkus-groovy-xml-deployment</artifactId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> + <version>3.27.0-SNAPSHOT</version><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> + </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> <artifactId>camel-quarkus-grpc</artifactId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> @@ -8363,6 +8378,11 @@ <artifactId>groovy</artifactId><!-- org.apache.groovy:groovy-bom:4.0.28 --> <version>4.0.28</version><!-- org.apache.groovy:groovy-bom:4.0.28 --> </dependency> + <dependency> + <groupId>org.apache.groovy</groupId><!-- org.apache.groovy:groovy-bom:4.0.28 --> + <artifactId>groovy-xml</artifactId><!-- org.apache.groovy:groovy-bom:4.0.28 --> + <version>4.0.28</version><!-- org.apache.groovy:groovy-bom:4.0.28 --> + </dependency> <dependency> <groupId>software.amazon.awssdk</groupId><!-- software.amazon.awssdk:bom:2.32.4 --> <artifactId>annotations</artifactId><!-- software.amazon.awssdk:bom:2.32.4 --> diff --git a/tooling/scripts/test-categories.yaml b/tooling/scripts/test-categories.yaml index a01f7451ce..40d9338bd6 100644 --- a/tooling/scripts/test-categories.yaml +++ b/tooling/scripts/test-categories.yaml @@ -38,6 +38,7 @@ group-02: - aws2 - beanio - google-pubsub + - groovy-xml - grpc - iso8583 - jackson-avro
