This is an automated email from the ASF dual-hosted git repository. jamesnetherton pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
The following commit(s) were added to refs/heads/main by this push: new 5178ac1a26 Add Python JVM Only extension 5178ac1a26 is described below commit 5178ac1a265d7846beeb5005824e2e55e0afcc57 Author: James Netherton <jamesnether...@users.noreply.github.com> AuthorDate: Fri Jun 13 08:12:42 2025 +0100 Add Python JVM Only extension Fixes #4408 Co-authored-by: ikulaga <kulagaivanandreev...@gmail.com> --- catalog/pom.xml | 13 +++ docs/modules/ROOT/examples/languages/python.yml | 13 +++ docs/modules/ROOT/nav.adoc | 1 + .../ROOT/pages/reference/extensions/python.adoc | 41 +++++++++ extensions-jvm/pom.xml | 1 + extensions-jvm/python/deployment/pom.xml | 63 +++++++++++++ .../python/deployment/PythonProcessor.java | 46 ++++++++++ extensions-jvm/python/pom.xml | 39 ++++++++ extensions-jvm/python/runtime/pom.xml | 100 ++++++++++++++++++++ .../main/resources/META-INF/quarkus-extension.yaml | 34 +++++++ integration-tests-jvm/pom.xml | 1 + integration-tests-jvm/python/pom.xml | 101 +++++++++++++++++++++ .../component/python/it/PythonResource.java | 70 ++++++++++++++ .../quarkus/component/python/it/PythonRoutes.java | 40 ++++++++ .../src/main/resources/application.properties | 17 ++++ .../python/src/main/resources/script.py | 18 ++++ .../quarkus/component/python/it/PythonIT.java | 24 +++++ .../quarkus/component/python/it/PythonTest.java | 69 ++++++++++++++ poms/bom/pom.xml | 15 +++ poms/bom/src/main/generated/flattened-full-pom.xml | 15 +++ .../src/main/generated/flattened-reduced-pom.xml | 15 +++ .../generated/flattened-reduced-verbose-pom.xml | 15 +++ 22 files changed, 751 insertions(+) diff --git a/catalog/pom.xml b/catalog/pom.xml index afc0789243..f84c250177 100644 --- a/catalog/pom.xml +++ b/catalog/pom.xml @@ -3191,6 +3191,19 @@ </exclusion> </exclusions> </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-python</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-qdrant</artifactId> diff --git a/docs/modules/ROOT/examples/languages/python.yml b/docs/modules/ROOT/examples/languages/python.yml new file mode 100644 index 0000000000..098399afdf --- /dev/null +++ b/docs/modules/ROOT/examples/languages/python.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-python +cqArtifactIdBase: python +cqNativeSupported: false +cqStatus: Preview +cqDeprecated: false +cqJvmSince: 3.24.0 +cqNativeSince: n/a +cqCamelPartName: python +cqCamelPartTitle: Python +cqCamelPartDescription: Evaluates a Python expression. +cqExtensionPageTitle: Python diff --git a/docs/modules/ROOT/nav.adoc b/docs/modules/ROOT/nav.adoc index b93326e370..00b1ba2a27 100644 --- a/docs/modules/ROOT/nav.adoc +++ b/docs/modules/ROOT/nav.adoc @@ -254,6 +254,7 @@ *** xref:reference/extensions/jackson-protobuf.adoc[Protobuf Jackson] *** xref:reference/extensions/pubnub.adoc[PubNub] *** xref:reference/extensions/pulsar.adoc[Pulsar] +*** xref:reference/extensions/python.adoc[Python] *** xref:reference/extensions/qdrant.adoc[Qdrant] *** xref:reference/extensions/quartz.adoc[Quartz] *** xref:reference/extensions/quickfix.adoc[QuickFix] diff --git a/docs/modules/ROOT/pages/reference/extensions/python.adoc b/docs/modules/ROOT/pages/reference/extensions/python.adoc new file mode 100644 index 0000000000..4f51992096 --- /dev/null +++ b/docs/modules/ROOT/pages/reference/extensions/python.adoc @@ -0,0 +1,41 @@ +// Do not edit directly! +// This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page +[id="extensions-python"] += Python +:linkattrs: +:cq-artifact-id: camel-quarkus-python +:cq-native-supported: false +:cq-status: Preview +:cq-status-deprecation: Preview +:cq-description: Evaluates a Python expression. +:cq-deprecated: false +:cq-jvm-since: 3.24.0 +:cq-native-since: n/a + +ifeval::[{doc-show-badges} == true] +[.badges] +[.badge-key]##JVM since##[.badge-supported]##3.24.0## [.badge-key]##Native##[.badge-unsupported]##unsupported## +endif::[] + +Evaluates a Python expression. + +[id="extensions-python-whats-inside"] +== What's inside + +* xref:{cq-camel-components}:languages:python-language.adoc[Python language] + +Please refer to the above link for usage and configuration details. + +[id="extensions-python-maven-coordinates"] +== Maven coordinates + +[source,xml] +---- +<dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-python</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::[] diff --git a/extensions-jvm/pom.xml b/extensions-jvm/pom.xml index df7d0a9b0a..2c78edef2a 100644 --- a/extensions-jvm/pom.xml +++ b/extensions-jvm/pom.xml @@ -86,6 +86,7 @@ <module>pqc</module> <module>printer</module> <module>pulsar</module> + <module>python</module> <module>quickfix</module> <module>redis</module> <module>robotframework</module> diff --git a/extensions-jvm/python/deployment/pom.xml b/extensions-jvm/python/deployment/pom.xml new file mode 100644 index 0000000000..622f87dc2a --- /dev/null +++ b/extensions-jvm/python/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-python-parent</artifactId> + <version>3.24.0-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <artifactId>camel-quarkus-python-deployment</artifactId> + <name>Camel Quarkus :: Python :: 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-python</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-jvm/python/deployment/src/main/java/org/apache/camel/quarkus/component/python/deployment/PythonProcessor.java b/extensions-jvm/python/deployment/src/main/java/org/apache/camel/quarkus/component/python/deployment/PythonProcessor.java new file mode 100644 index 0000000000..a5995abb4f --- /dev/null +++ b/extensions-jvm/python/deployment/src/main/java/org/apache/camel/quarkus/component/python/deployment/PythonProcessor.java @@ -0,0 +1,46 @@ +/* + * 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.python.deployment; + +import io.quarkus.deployment.annotations.BuildStep; +import io.quarkus.deployment.annotations.ExecutionTime; +import io.quarkus.deployment.annotations.Record; +import io.quarkus.deployment.builditem.FeatureBuildItem; +import io.quarkus.deployment.pkg.steps.NativeOrNativeSourcesBuild; +import org.apache.camel.quarkus.core.JvmOnlyRecorder; +import org.jboss.logging.Logger; + +class PythonProcessor { + + private static final Logger LOG = Logger.getLogger(PythonProcessor.class); + private static final String FEATURE = "camel-python"; + + @BuildStep + FeatureBuildItem feature() { + return new FeatureBuildItem(FEATURE); + } + + /** + * Remove this once this extension starts supporting the native mode. + */ + @BuildStep(onlyIf = NativeOrNativeSourcesBuild.class) + @Record(value = ExecutionTime.RUNTIME_INIT) + void warnJvmInNative(JvmOnlyRecorder recorder) { + JvmOnlyRecorder.warnJvmInNative(LOG, FEATURE); // warn at build time + recorder.warnJvmInNative(FEATURE); // warn at runtime + } +} diff --git a/extensions-jvm/python/pom.xml b/extensions-jvm/python/pom.xml new file mode 100644 index 0000000000..09ad32d744 --- /dev/null +++ b/extensions-jvm/python/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-jvm</artifactId> + <version>3.24.0-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <artifactId>camel-quarkus-python-parent</artifactId> + <name>Camel Quarkus :: Python</name> + <packaging>pom</packaging> + + <modules> + <module>deployment</module> + <module>runtime</module> + </modules> +</project> diff --git a/extensions-jvm/python/runtime/pom.xml b/extensions-jvm/python/runtime/pom.xml new file mode 100644 index 0000000000..e7ce85cb10 --- /dev/null +++ b/extensions-jvm/python/runtime/pom.xml @@ -0,0 +1,100 @@ +<?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-python-parent</artifactId> + <version>3.24.0-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <artifactId>camel-quarkus-python</artifactId> + <name>Camel Quarkus :: Python :: Runtime</name> + <description>Evaluates a Python expression.</description> + + <properties> + <camel.quarkus.jvmSince>3.24.0</camel.quarkus.jvmSince> + </properties> + + <dependencies> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-core</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-python</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-jvm/python/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions-jvm/python/runtime/src/main/resources/META-INF/quarkus-extension.yaml new file mode 100644 index 0000000000..fe775fc605 --- /dev/null +++ b/extensions-jvm/python/runtime/src/main/resources/META-INF/quarkus-extension.yaml @@ -0,0 +1,34 @@ +# +# 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 Python" +description: "Evaluates a Python expression" +metadata: + icon-url: "https://raw.githubusercontent.com/apache/camel-website/main/antora-ui-camel/src/img/logo-d.svg" + sponsor: "Apache Software Foundation" + unlisted: true + guide: "https://camel.apache.org/camel-quarkus/latest/reference/extensions/python.html" + categories: + - "integration" + status: + - "preview" diff --git a/integration-tests-jvm/pom.xml b/integration-tests-jvm/pom.xml index 57fa448f88..572d389362 100644 --- a/integration-tests-jvm/pom.xml +++ b/integration-tests-jvm/pom.xml @@ -85,6 +85,7 @@ <module>pqc</module> <module>printer</module> <module>pulsar</module> + <module>python</module> <module>quickfix</module> <module>redis</module> <module>robotframework</module> diff --git a/integration-tests-jvm/python/pom.xml b/integration-tests-jvm/python/pom.xml new file mode 100644 index 0000000000..7288b74c7d --- /dev/null +++ b/integration-tests-jvm/python/pom.xml @@ -0,0 +1,101 @@ +<?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.24.0-SNAPSHOT</version> + <relativePath>../../poms/build-parent-it/pom.xml</relativePath> + </parent> + + <artifactId>camel-quarkus-integration-test-python</artifactId> + <name>Camel Quarkus :: Integration Tests :: Python</name> + <description>Integration tests for Camel Quarkus Python extension</description> + + <dependencies> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-direct</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-python</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> + + <profiles> + <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-python-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-jvm/python/src/main/java/org/apache/camel/quarkus/component/python/it/PythonResource.java b/integration-tests-jvm/python/src/main/java/org/apache/camel/quarkus/component/python/it/PythonResource.java new file mode 100644 index 0000000000..94f600d837 --- /dev/null +++ b/integration-tests-jvm/python/src/main/java/org/apache/camel/quarkus/component/python/it/PythonResource.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.python.it; + +import java.util.AbstractMap; +import java.util.Map; +import java.util.Map.Entry; +import java.util.stream.Collectors; + +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.PathParam; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.core.Context; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.UriInfo; +import org.apache.camel.ProducerTemplate; + +@Path("/python") +@ApplicationScoped +public class PythonResource { + + @Inject + ProducerTemplate producerTemplate; + + @POST + @Path("/hello") + @Consumes(MediaType.TEXT_PLAIN) + @Produces(MediaType.TEXT_PLAIN) + public String hello(String message) { + return producerTemplate.requestBody("direct:pythonHello", message, String.class); + } + + @POST + @Path("/predicate") + @Consumes(MediaType.TEXT_PLAIN) + @Produces(MediaType.TEXT_PLAIN) + public String predicate(String message) { + return producerTemplate.requestBody("direct:predicate", Integer.valueOf(message), String.class); + } + + @Path("/route/{route}") + @POST + @Consumes(MediaType.TEXT_PLAIN) + @Produces(MediaType.TEXT_PLAIN) + public String route(String statement, @PathParam("route") String route, @Context UriInfo uriInfo) { + final Map<String, Object> headers = uriInfo.getQueryParameters().entrySet().stream() + .map(e -> new AbstractMap.SimpleImmutableEntry<String, Object>(e.getKey(), e.getValue().get(0))) + .collect(Collectors.toMap(Entry::getKey, Entry::getValue)); + return producerTemplate.requestBodyAndHeaders("direct:" + route, statement, headers, String.class); + } + +} diff --git a/integration-tests-jvm/python/src/main/java/org/apache/camel/quarkus/component/python/it/PythonRoutes.java b/integration-tests-jvm/python/src/main/java/org/apache/camel/quarkus/component/python/it/PythonRoutes.java new file mode 100644 index 0000000000..dfede96d1a --- /dev/null +++ b/integration-tests-jvm/python/src/main/java/org/apache/camel/quarkus/component/python/it/PythonRoutes.java @@ -0,0 +1,40 @@ +/* + * 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.python.it; + +import org.apache.camel.builder.RouteBuilder; + +public class PythonRoutes extends RouteBuilder { + + @Override + public void configure() { + from("direct:pythonHello") + .transform().python("\"Hello \" + str(body) + \" from Python!\""); + + from("direct:predicate") + .choice() + .when().python("body / 2 > 10") + .setBody().constant("High").endChoice() + .otherwise() + .setBody().constant("Low").endChoice(); + + from("direct:scriptPython") + .script() + .python("exchange.getMessage().setBody('Hello ' + str(exchange.getMessage().getBody()) + ' from Python!')"); + + } +} diff --git a/integration-tests-jvm/python/src/main/resources/application.properties b/integration-tests-jvm/python/src/main/resources/application.properties new file mode 100644 index 0000000000..0a454a07d2 --- /dev/null +++ b/integration-tests-jvm/python/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.native.resources.includes=script.py \ No newline at end of file diff --git a/integration-tests-jvm/python/src/main/resources/script.py b/integration-tests-jvm/python/src/main/resources/script.py new file mode 100644 index 0000000000..193f253d91 --- /dev/null +++ b/integration-tests-jvm/python/src/main/resources/script.py @@ -0,0 +1,18 @@ +# +# 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. +# + +"The result is " + str(body * 2) \ No newline at end of file diff --git a/integration-tests-jvm/python/src/test/java/org/apache/camel/quarkus/component/python/it/PythonIT.java b/integration-tests-jvm/python/src/test/java/org/apache/camel/quarkus/component/python/it/PythonIT.java new file mode 100644 index 0000000000..40c941de62 --- /dev/null +++ b/integration-tests-jvm/python/src/test/java/org/apache/camel/quarkus/component/python/it/PythonIT.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.python.it; + +import io.quarkus.test.junit.QuarkusIntegrationTest; + +@QuarkusIntegrationTest +class PythonIT extends PythonTest { + +} diff --git a/integration-tests-jvm/python/src/test/java/org/apache/camel/quarkus/component/python/it/PythonTest.java b/integration-tests-jvm/python/src/test/java/org/apache/camel/quarkus/component/python/it/PythonTest.java new file mode 100644 index 0000000000..41434181bb --- /dev/null +++ b/integration-tests-jvm/python/src/test/java/org/apache/camel/quarkus/component/python/it/PythonTest.java @@ -0,0 +1,69 @@ +/* + * 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.python.it; + +import io.quarkus.test.junit.QuarkusTest; +import io.restassured.RestAssured; +import io.restassured.http.ContentType; +import org.hamcrest.CoreMatchers; +import org.hamcrest.Matchers; +import org.junit.jupiter.api.Test; + +@QuarkusTest +class PythonTest { + + @Test + void pythonHello() { + RestAssured.given() + .body("Will Smith") + .post("/python/hello") + .then() + .statusCode(200) + .body(CoreMatchers.is("Hello Will Smith from Python!")); + } + + @Test + void pythonHigh() { + RestAssured.given() + .body("45") + .post("/python/predicate") + .then() + .statusCode(200) + .body(CoreMatchers.is("High")); + } + + @Test + void pythonLow() { + RestAssured.given() + .body("13") + .post("/python/predicate") + .then() + .statusCode(200) + .body(CoreMatchers.is("Low")); + } + + @Test + void script() { + RestAssured.given() + .contentType(ContentType.TEXT) + .body(32767) + .post("/python/route/scriptPython") + .then() + .statusCode(200) + .body(Matchers.is("Hello 32767 from Python!")); + } +} diff --git a/poms/bom/pom.xml b/poms/bom/pom.xml index 76b0b16cd2..896f24e380 100644 --- a/poms/bom/pom.xml +++ b/poms/bom/pom.xml @@ -2415,6 +2415,11 @@ </exclusion> </exclusions> </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-python</artifactId> + <version>${camel.version}</version> + </dependency> <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-qdrant</artifactId> @@ -5492,6 +5497,16 @@ <artifactId>camel-quarkus-pulsar-deployment</artifactId> <version>${camel-quarkus.version}</version> </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-python</artifactId> + <version>${camel-quarkus.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-python-deployment</artifactId> + <version>${camel-quarkus.version}</version> + </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-qdrant</artifactId> diff --git a/poms/bom/src/main/generated/flattened-full-pom.xml b/poms/bom/src/main/generated/flattened-full-pom.xml index ce4519fb53..47698e582e 100644 --- a/poms/bom/src/main/generated/flattened-full-pom.xml +++ b/poms/bom/src/main/generated/flattened-full-pom.xml @@ -2336,6 +2336,11 @@ </exclusion> </exclusions> </dependency> + <dependency> + <groupId>org.apache.camel</groupId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> + <artifactId>camel-python</artifactId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> + <version>4.12.0</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-qdrant</artifactId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> @@ -5401,6 +5406,16 @@ <artifactId>camel-quarkus-pulsar-deployment</artifactId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> <version>3.24.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-python</artifactId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> + <version>3.24.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-python-deployment</artifactId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> + <version>3.24.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-qdrant</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 1fe92b4c79..5cdf592f29 100644 --- a/poms/bom/src/main/generated/flattened-reduced-pom.xml +++ b/poms/bom/src/main/generated/flattened-reduced-pom.xml @@ -2326,6 +2326,11 @@ </exclusion> </exclusions> </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-python</artifactId> + <version>4.12.0</version> + </dependency> <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-qdrant</artifactId> @@ -5391,6 +5396,16 @@ <artifactId>camel-quarkus-pulsar-deployment</artifactId> <version>3.24.0-SNAPSHOT</version> </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-python</artifactId> + <version>3.24.0-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-python-deployment</artifactId> + <version>3.24.0-SNAPSHOT</version> + </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-qdrant</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 031d883b72..8c0366d819 100644 --- a/poms/bom/src/main/generated/flattened-reduced-verbose-pom.xml +++ b/poms/bom/src/main/generated/flattened-reduced-verbose-pom.xml @@ -2326,6 +2326,11 @@ </exclusion> </exclusions> </dependency> + <dependency> + <groupId>org.apache.camel</groupId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> + <artifactId>camel-python</artifactId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> + <version>4.12.0</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-qdrant</artifactId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> @@ -5391,6 +5396,16 @@ <artifactId>camel-quarkus-pulsar-deployment</artifactId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> <version>3.24.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-python</artifactId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> + <version>3.24.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-python-deployment</artifactId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> + <version>3.24.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-qdrant</artifactId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->