You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ja...@apache.org on 2026/04/22 12:56:39 UTC
(camel-quarkus) branch main updated: Promote ibm-watson-language to native support with integration tests
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 058b347795 Promote ibm-watson-language to native support with integration tests
058b347795 is described below
commit 058b347795c08b8904cdcaa5e39ff67b1d4960ef
Author: JinyuChen97 <as...@gmail.com>
AuthorDate: Wed Apr 22 13:56:33 2026 +0100
Promote ibm-watson-language to native support with integration tests
fixes #7991
---
.../examples/components/ibm-watson-language.yml | 6 +-
.../reference/extensions/ibm-watson-language.adoc | 14 +-
.../deployment/IbmWatsonLanguageProcessor.java | 46 -------
extensions-jvm/pom.xml | 1 -
.../ibm-watson-language/deployment/pom.xml | 0
.../deployment/IbmWatsonLanguageProcessor.java | 72 +++++++++++
.../ibm-watson-language/pom.xml | 2 +-
.../ibm-watson-language/runtime/pom.xml | 10 ++
.../main/resources/META-INF/quarkus-extension.yaml | 1 -
extensions/pom.xml | 1 +
.../language/it/IbmWatsonLanguageResource.java | 50 --------
integration-tests-jvm/pom.xml | 1 -
.../ibm-watson-language/pom.xml | 48 +++++++
.../language/it/IbmWatsonLanguageResource.java | 65 ++++++++++
.../language/it/IbmWatsonLanguageRoutes.java | 84 ++++++++++++
.../src/main/resources/application.properties | 22 ++++
.../watson/language/it/IbmWatsonLanguageIT.java | 19 +--
.../watson/language/it/IbmWatsonLanguageTest.java | 142 +++++++++++++++++++++
integration-tests/pom.xml | 1 +
pom.xml | 2 +-
poms/bom/pom.xml | 5 +
poms/bom/src/main/generated/flattened-full-pom.xml | 5 +
.../src/main/generated/flattened-reduced-pom.xml | 5 +
.../generated/flattened-reduced-verbose-pom.xml | 5 +
tooling/scripts/test-categories.yaml | 1 +
25 files changed, 486 insertions(+), 122 deletions(-)
diff --git a/docs/modules/ROOT/examples/components/ibm-watson-language.yml b/docs/modules/ROOT/examples/components/ibm-watson-language.yml
index ff503ed224..638c497289 100644
--- a/docs/modules/ROOT/examples/components/ibm-watson-language.yml
+++ b/docs/modules/ROOT/examples/components/ibm-watson-language.yml
@@ -2,11 +2,11 @@
# This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page
cqArtifactId: camel-quarkus-ibm-watson-language
cqArtifactIdBase: ibm-watson-language
-cqNativeSupported: false
-cqStatus: Preview
+cqNativeSupported: true
+cqStatus: Stable
cqDeprecated: false
cqJvmSince: 3.30.0
-cqNativeSince: n/a
+cqNativeSince: 3.35.0
cqCamelPartName: ibm-watson-language
cqCamelPartTitle: IBM Watson Language
cqCamelPartDescription: Perform natural language processing using IBM Watson Natural Language Understanding
diff --git a/docs/modules/ROOT/pages/reference/extensions/ibm-watson-language.adoc b/docs/modules/ROOT/pages/reference/extensions/ibm-watson-language.adoc
index 2ec0217f06..d42967cbb6 100644
--- a/docs/modules/ROOT/pages/reference/extensions/ibm-watson-language.adoc
+++ b/docs/modules/ROOT/pages/reference/extensions/ibm-watson-language.adoc
@@ -4,17 +4,17 @@
= IBM Watson Language
:linkattrs:
:cq-artifact-id: camel-quarkus-ibm-watson-language
-:cq-native-supported: false
-:cq-status: Preview
-:cq-status-deprecation: Preview
+:cq-native-supported: true
+:cq-status: Stable
+:cq-status-deprecation: Stable
:cq-description: Perform natural language processing using IBM Watson Natural Language Understanding
:cq-deprecated: false
:cq-jvm-since: 3.30.0
-:cq-native-since: n/a
+:cq-native-since: 3.35.0
ifeval::[{doc-show-badges} == true]
[.badges]
-[.badge-key]##JVM since##[.badge-supported]##3.30.0## [.badge-key]##Native##[.badge-unsupported]##unsupported##
+[.badge-key]##JVM since##[.badge-supported]##3.30.0## [.badge-key]##Native since##[.badge-supported]##3.35.0##
endif::[]
Perform natural language processing using IBM Watson Natural Language Understanding
@@ -29,6 +29,10 @@ Please refer to the above link for usage and configuration details.
[id="extensions-ibm-watson-language-maven-coordinates"]
== Maven coordinates
+https://{link-quarkus-code-generator}/?extension-search=camel-quarkus-ibm-watson-language[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>
diff --git a/extensions-jvm/ibm-watson-language/deployment/src/main/java/org/apache/camel/quarkus/component/ibm/watson/language/deployment/IbmWatsonLanguageProcessor.java b/extensions-jvm/ibm-watson-language/deployment/src/main/java/org/apache/camel/quarkus/component/ibm/watson/language/deployment/IbmWatsonLanguageProcessor.java
deleted file mode 100644
index 26c1334982..0000000000
--- a/extensions-jvm/ibm-watson-language/deployment/src/main/java/org/apache/camel/quarkus/component/ibm/watson/language/deployment/IbmWatsonLanguageProcessor.java
+++ /dev/null
@@ -1,46 +0,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.
- */
-package org.apache.camel.quarkus.component.ibm.watson.language.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 IbmWatsonLanguageProcessor {
-
- private static final Logger LOG = Logger.getLogger(IbmWatsonLanguageProcessor.class);
- private static final String FEATURE = "camel-ibm-watson-language";
-
- @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/pom.xml b/extensions-jvm/pom.xml
index 0251dc69e6..47c7364058 100644
--- a/extensions-jvm/pom.xml
+++ b/extensions-jvm/pom.xml
@@ -65,7 +65,6 @@
<module>huaweicloud-smn</module>
<module>ibm-secrets-manager</module>
<module>ibm-watson-discovery</module>
- <module>ibm-watson-language</module>
<module>iec60870</module>
<module>ignite</module>
<module>irc</module>
diff --git a/extensions-jvm/ibm-watson-language/deployment/pom.xml b/extensions/ibm-watson-language/deployment/pom.xml
similarity index 100%
rename from extensions-jvm/ibm-watson-language/deployment/pom.xml
rename to extensions/ibm-watson-language/deployment/pom.xml
diff --git a/extensions/ibm-watson-language/deployment/src/main/java/org/apache/camel/quarkus/component/ibm/watson/language/deployment/IbmWatsonLanguageProcessor.java b/extensions/ibm-watson-language/deployment/src/main/java/org/apache/camel/quarkus/component/ibm/watson/language/deployment/IbmWatsonLanguageProcessor.java
new file mode 100644
index 0000000000..9812175807
--- /dev/null
+++ b/extensions/ibm-watson-language/deployment/src/main/java/org/apache/camel/quarkus/component/ibm/watson/language/deployment/IbmWatsonLanguageProcessor.java
@@ -0,0 +1,72 @@
+/*
+ * 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.ibm.watson.language.deployment;
+
+import com.ibm.cloud.sdk.core.security.IamToken;
+import io.quarkus.deployment.annotations.BuildProducer;
+import io.quarkus.deployment.annotations.BuildStep;
+import io.quarkus.deployment.builditem.CombinedIndexBuildItem;
+import io.quarkus.deployment.builditem.FeatureBuildItem;
+import io.quarkus.deployment.builditem.IndexDependencyBuildItem;
+import io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem;
+import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;
+import org.jboss.jandex.ClassInfo;
+
+/**
+ * Quarkus extension processor for IBM Watson Natural Language Understanding support.
+ */
+class IbmWatsonLanguageProcessor {
+
+ private static final String FEATURE = "camel-ibm-watson-language";
+
+ @BuildStep
+ FeatureBuildItem feature() {
+ return new FeatureBuildItem(FEATURE);
+ }
+
+ @BuildStep
+ void registerForReflection(
+ CombinedIndexBuildItem combinedIndex,
+ BuildProducer<ReflectiveClassBuildItem> reflectiveClass) {
+ // Register Watson SDK authentication classes for reflection
+ // IamToken needs reflection for Gson deserialization of IAM auth responses
+ reflectiveClass.produce(ReflectiveClassBuildItem.builder(IamToken.class.getName())
+ .methods().constructors().fields().build());
+
+ // Register all Watson NLU model classes for reflection
+ // These are POJOs used by Gson for JSON serialization/deserialization
+ for (ClassInfo classInfo : combinedIndex.getIndex().getKnownClasses()) {
+ String className = classInfo.name().toString();
+ if (className.startsWith("com.ibm.watson.natural_language_understanding.v1.model.")) {
+ reflectiveClass.produce(ReflectiveClassBuildItem.builder(className)
+ .methods().constructors().fields().build());
+ }
+ }
+ }
+
+ @BuildStep
+ void addDependencies(BuildProducer<IndexDependencyBuildItem> indexDependency) {
+ // Index Watson NLU dependency so we can scan model classes in registerForReflection()
+ indexDependency.produce(new IndexDependencyBuildItem("com.ibm.watson", "natural-language-understanding"));
+ }
+
+ @BuildStep
+ void addResources(BuildProducer<NativeImageResourceBuildItem> nativeImageResource) {
+ nativeImageResource.produce(new NativeImageResourceBuildItem("java-sdk-version.properties"));
+ nativeImageResource.produce(new NativeImageResourceBuildItem("sdk-core-version.properties"));
+ }
+}
diff --git a/extensions-jvm/ibm-watson-language/pom.xml b/extensions/ibm-watson-language/pom.xml
similarity index 96%
rename from extensions-jvm/ibm-watson-language/pom.xml
rename to extensions/ibm-watson-language/pom.xml
index a8feee0434..69ad0f67a7 100644
--- a/extensions-jvm/ibm-watson-language/pom.xml
+++ b/extensions/ibm-watson-language/pom.xml
@@ -21,7 +21,7 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-extensions-jvm</artifactId>
+ <artifactId>camel-quarkus-extensions</artifactId>
<version>3.35.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
diff --git a/extensions-jvm/ibm-watson-language/runtime/pom.xml b/extensions/ibm-watson-language/runtime/pom.xml
similarity index 91%
rename from extensions-jvm/ibm-watson-language/runtime/pom.xml
rename to extensions/ibm-watson-language/runtime/pom.xml
index f0755e61ad..76fa4c678f 100644
--- a/extensions-jvm/ibm-watson-language/runtime/pom.xml
+++ b/extensions/ibm-watson-language/runtime/pom.xml
@@ -32,6 +32,7 @@
<properties>
<camel.quarkus.jvmSince>3.30.0</camel.quarkus.jvmSince>
+ <camel.quarkus.nativeSince>3.35.0</camel.quarkus.nativeSince>
</properties>
<dependencies>
@@ -43,6 +44,15 @@
<groupId>org.apache.camel</groupId>
<artifactId>camel-ibm-watson-language</artifactId>
</dependency>
+ <dependency>
+ <groupId>com.ibm.cloud</groupId>
+ <artifactId>sdk-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.graalvm.sdk</groupId>
+ <artifactId>nativeimage</artifactId>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
<build>
diff --git a/extensions-jvm/ibm-watson-language/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions/ibm-watson-language/runtime/src/main/resources/META-INF/quarkus-extension.yaml
similarity index 98%
rename from extensions-jvm/ibm-watson-language/runtime/src/main/resources/META-INF/quarkus-extension.yaml
rename to extensions/ibm-watson-language/runtime/src/main/resources/META-INF/quarkus-extension.yaml
index f80bf110ee..484707365e 100644
--- a/extensions-jvm/ibm-watson-language/runtime/src/main/resources/META-INF/quarkus-extension.yaml
+++ b/extensions/ibm-watson-language/runtime/src/main/resources/META-INF/quarkus-extension.yaml
@@ -26,7 +26,6 @@ description: "Perform natural language processing using IBM Watson Natural Langu
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/ibm-watson-language.html"
categories:
- "integration"
diff --git a/extensions/pom.xml b/extensions/pom.xml
index c5956445c9..82e27c9a2f 100644
--- a/extensions/pom.xml
+++ b/extensions/pom.xml
@@ -139,6 +139,7 @@
<module>hl7</module>
<module>http</module>
<module>ibm-cos</module>
+ <module>ibm-watson-language</module>
<module>ical</module>
<module>infinispan</module>
<module>infinispan-cluster-service</module>
diff --git a/integration-tests-jvm/ibm-watson-language/src/main/java/org/apache/camel/quarkus/component/ibm/watson/language/it/IbmWatsonLanguageResource.java b/integration-tests-jvm/ibm-watson-language/src/main/java/org/apache/camel/quarkus/component/ibm/watson/language/it/IbmWatsonLanguageResource.java
deleted file mode 100644
index 4ff0afb901..0000000000
--- a/integration-tests-jvm/ibm-watson-language/src/main/java/org/apache/camel/quarkus/component/ibm/watson/language/it/IbmWatsonLanguageResource.java
+++ /dev/null
@@ -1,50 +0,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.
- */
-package org.apache.camel.quarkus.component.ibm.watson.language.it;
-
-import jakarta.enterprise.context.ApplicationScoped;
-import jakarta.inject.Inject;
-import jakarta.ws.rs.GET;
-import jakarta.ws.rs.Path;
-import jakarta.ws.rs.Produces;
-import jakarta.ws.rs.core.MediaType;
-import jakarta.ws.rs.core.Response;
-import org.apache.camel.CamelContext;
-import org.jboss.logging.Logger;
-
-@Path("/ibm-watson-language")
-@ApplicationScoped
-public class IbmWatsonLanguageResource {
-
- private static final Logger LOG = Logger.getLogger(IbmWatsonLanguageResource.class);
-
- private static final String COMPONENT_IBM_WATSON_LANGUAGE = "ibm-watson-language";
- @Inject
- CamelContext context;
-
- @Path("/load/component/ibm-watson-language")
- @GET
- @Produces(MediaType.TEXT_PLAIN)
- public Response loadComponentIbmWatsonLanguage() throws Exception {
- /* This is an autogenerated test */
- if (context.getComponent(COMPONENT_IBM_WATSON_LANGUAGE) != null) {
- return Response.ok().build();
- }
- LOG.warnf("Could not load [%s] from the Camel context", COMPONENT_IBM_WATSON_LANGUAGE);
- return Response.status(500, COMPONENT_IBM_WATSON_LANGUAGE + " could not be loaded from the Camel context").build();
- }
-}
diff --git a/integration-tests-jvm/pom.xml b/integration-tests-jvm/pom.xml
index 33ae81867c..db9dc65c25 100644
--- a/integration-tests-jvm/pom.xml
+++ b/integration-tests-jvm/pom.xml
@@ -64,7 +64,6 @@
<module>huaweicloud-smn</module>
<module>ibm-secrets-manager</module>
<module>ibm-watson-discovery</module>
- <module>ibm-watson-language</module>
<module>iec60870</module>
<module>ignite</module>
<module>irc</module>
diff --git a/integration-tests-jvm/ibm-watson-language/pom.xml b/integration-tests/ibm-watson-language/pom.xml
similarity index 65%
rename from integration-tests-jvm/ibm-watson-language/pom.xml
rename to integration-tests/ibm-watson-language/pom.xml
index e3c2478594..5609ddba25 100644
--- a/integration-tests-jvm/ibm-watson-language/pom.xml
+++ b/integration-tests/ibm-watson-language/pom.xml
@@ -35,10 +35,18 @@
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-ibm-watson-language</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>
@@ -76,7 +84,47 @@
</exclusion>
</exclusions>
</dependency>
+ <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>
</dependencies>
</profile>
+ <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>
</profiles>
</project>
diff --git a/integration-tests/ibm-watson-language/src/main/java/org/apache/camel/quarkus/component/ibm/watson/language/it/IbmWatsonLanguageResource.java b/integration-tests/ibm-watson-language/src/main/java/org/apache/camel/quarkus/component/ibm/watson/language/it/IbmWatsonLanguageResource.java
new file mode 100644
index 0000000000..be30278a52
--- /dev/null
+++ b/integration-tests/ibm-watson-language/src/main/java/org/apache/camel/quarkus/component/ibm/watson/language/it/IbmWatsonLanguageResource.java
@@ -0,0 +1,65 @@
+/*
+ * 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.ibm.watson.language.it;
+
+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.MediaType;
+import jakarta.ws.rs.core.Response;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.component.ibm.watson.language.WatsonLanguageConstants;
+
+@Path("/ibm-watson-language")
+@ApplicationScoped
+public class IbmWatsonLanguageResource {
+ @Inject
+ ProducerTemplate producerTemplate;
+
+ @Path("/analyze/text/{operation}")
+ @POST
+ @Consumes(MediaType.TEXT_PLAIN)
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response analyzeText(@PathParam("operation") String operation, String text) {
+ try {
+ String endpoint = "direct:analyze-text-" + operation;
+ Object result = producerTemplate.requestBodyAndHeader(endpoint, text,
+ WatsonLanguageConstants.TEXT, text);
+ return Response.ok(result).build();
+ } catch (Exception e) {
+ return Response.status(500).entity(e.getMessage()).build();
+ }
+ }
+
+ @Path("/analyze/url")
+ @POST
+ @Consumes(MediaType.TEXT_PLAIN)
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response analyzeUrl(String url) {
+ try {
+ Object result = producerTemplate.requestBodyAndHeader("direct:analyze-url", url,
+ WatsonLanguageConstants.URL, url);
+ return Response.ok(result).build();
+ } catch (Exception e) {
+ return Response.status(500).entity(e.getMessage()).build();
+ }
+ }
+}
diff --git a/integration-tests/ibm-watson-language/src/main/java/org/apache/camel/quarkus/component/ibm/watson/language/it/IbmWatsonLanguageRoutes.java b/integration-tests/ibm-watson-language/src/main/java/org/apache/camel/quarkus/component/ibm/watson/language/it/IbmWatsonLanguageRoutes.java
new file mode 100644
index 0000000000..f806446ab3
--- /dev/null
+++ b/integration-tests/ibm-watson-language/src/main/java/org/apache/camel/quarkus/component/ibm/watson/language/it/IbmWatsonLanguageRoutes.java
@@ -0,0 +1,84 @@
+/*
+ * 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.ibm.watson.language.it;
+
+import java.util.Optional;
+
+import jakarta.enterprise.context.ApplicationScoped;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.ibm.watson.language.WatsonLanguageConstants;
+import org.apache.camel.component.ibm.watson.language.WatsonLanguageOperations;
+import org.eclipse.microprofile.config.inject.ConfigProperty;
+
+@ApplicationScoped
+public class IbmWatsonLanguageRoutes extends RouteBuilder {
+
+ @ConfigProperty(name = "camel.ibm.watson.serviceUrl")
+ Optional<String> serviceUrl;
+
+ @ConfigProperty(name = "camel.ibm.watson.apiKey")
+ Optional<String> apiKey;
+
+ @Override
+ public void configure() {
+ if (serviceUrl.isPresent() && apiKey.isPresent()) {
+ String baseUri = String.format("ibm-watson-language:test?serviceUrl=RAW(%s)&apiKey=RAW(%s)",
+ serviceUrl.get(), apiKey.get());
+
+ // Analyze text with sentiment
+ from("direct:analyze-text-sentiment")
+ .setHeader(WatsonLanguageConstants.OPERATION, constant(WatsonLanguageOperations.analyzeText))
+ .setHeader(WatsonLanguageConstants.ANALYZE_SENTIMENT, constant(true))
+ .to(baseUri);
+
+ // Analyze text with emotion
+ from("direct:analyze-text-emotion")
+ .setHeader(WatsonLanguageConstants.OPERATION, constant(WatsonLanguageOperations.analyzeText))
+ .setHeader(WatsonLanguageConstants.ANALYZE_EMOTION, constant(true))
+ .to(baseUri);
+
+ // Analyze text with entities
+ from("direct:analyze-text-entities")
+ .setHeader(WatsonLanguageConstants.OPERATION, constant(WatsonLanguageOperations.analyzeText))
+ .setHeader(WatsonLanguageConstants.ANALYZE_ENTITIES, constant(true))
+ .to(baseUri);
+
+ // Analyze text with keywords
+ from("direct:analyze-text-keywords")
+ .setHeader(WatsonLanguageConstants.OPERATION, constant(WatsonLanguageOperations.analyzeText))
+ .setHeader(WatsonLanguageConstants.ANALYZE_KEYWORDS, constant(true))
+ .to(baseUri);
+
+ // Analyze text with concepts
+ from("direct:analyze-text-concepts")
+ .setHeader(WatsonLanguageConstants.OPERATION, constant(WatsonLanguageOperations.analyzeText))
+ .setHeader(WatsonLanguageConstants.ANALYZE_CONCEPTS, constant(true))
+ .to(baseUri);
+
+ // Analyze text with categories
+ from("direct:analyze-text-categories")
+ .setHeader(WatsonLanguageConstants.OPERATION, constant(WatsonLanguageOperations.analyzeText))
+ .setHeader(WatsonLanguageConstants.ANALYZE_CATEGORIES, constant(true))
+ .to(baseUri);
+
+ // Analyze URL operation
+ from("direct:analyze-url")
+ .setHeader(WatsonLanguageConstants.OPERATION, constant(WatsonLanguageOperations.analyzeUrl))
+ .to(baseUri);
+ }
+ }
+}
diff --git a/integration-tests/ibm-watson-language/src/main/resources/application.properties b/integration-tests/ibm-watson-language/src/main/resources/application.properties
new file mode 100644
index 0000000000..8f019552e4
--- /dev/null
+++ b/integration-tests/ibm-watson-language/src/main/resources/application.properties
@@ -0,0 +1,22 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+# Watson Natural Language Understanding Configuration
+# For JVM mode tests: use system properties -Dcamel.ibm.watson.serviceUrl=... -Dcamel.ibm.watson.apiKey=...
+# For native mode tests: use environment variables CAMEL_IBM_WATSON_SERVICEURL=... CAMEL_IBM_WATSON_APIKEY=...
+# When not provided, routes are not created and tests are skipped
+camel.ibm.watson.serviceUrl=${CAMEL_IBM_WATSON_SERVICEURL:}
+camel.ibm.watson.apiKey=${CAMEL_IBM_WATSON_APIKEY:}
\ No newline at end of file
diff --git a/integration-tests-jvm/ibm-watson-language/src/test/java/org/apache/camel/quarkus/component/ibm/watson/language/it/IbmWatsonLanguageTest.java b/integration-tests/ibm-watson-language/src/test/java/org/apache/camel/quarkus/component/ibm/watson/language/it/IbmWatsonLanguageIT.java
similarity index 64%
rename from integration-tests-jvm/ibm-watson-language/src/test/java/org/apache/camel/quarkus/component/ibm/watson/language/it/IbmWatsonLanguageTest.java
rename to integration-tests/ibm-watson-language/src/test/java/org/apache/camel/quarkus/component/ibm/watson/language/it/IbmWatsonLanguageIT.java
index 8e98c20338..4ba190cca0 100644
--- a/integration-tests-jvm/ibm-watson-language/src/test/java/org/apache/camel/quarkus/component/ibm/watson/language/it/IbmWatsonLanguageTest.java
+++ b/integration-tests/ibm-watson-language/src/test/java/org/apache/camel/quarkus/component/ibm/watson/language/it/IbmWatsonLanguageIT.java
@@ -16,19 +16,12 @@
*/
package org.apache.camel.quarkus.component.ibm.watson.language.it;
-import io.quarkus.test.junit.QuarkusTest;
-import io.restassured.RestAssured;
-import org.junit.jupiter.api.Test;
+import io.quarkus.test.junit.QuarkusIntegrationTest;
+import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
-@QuarkusTest
-class IbmWatsonLanguageTest {
-
- @Test
- public void loadComponentIbmWatsonLanguage() {
- /* A simple autogenerated test */
- RestAssured.get("/ibm-watson-language/load/component/ibm-watson-language")
- .then()
- .statusCode(200);
- }
+@EnabledIfEnvironmentVariable(named = "CAMEL_IBM_WATSON_APIKEY", matches = ".*", disabledReason = "IBM Watson API Key not provided")
+@EnabledIfEnvironmentVariable(named = "CAMEL_IBM_WATSON_SERVICEURL", matches = ".*", disabledReason = "IBM Watson Service URL not provided")
+@QuarkusIntegrationTest
+class IbmWatsonLanguageIT extends IbmWatsonLanguageTest {
}
diff --git a/integration-tests/ibm-watson-language/src/test/java/org/apache/camel/quarkus/component/ibm/watson/language/it/IbmWatsonLanguageTest.java b/integration-tests/ibm-watson-language/src/test/java/org/apache/camel/quarkus/component/ibm/watson/language/it/IbmWatsonLanguageTest.java
new file mode 100644
index 0000000000..e7685968d5
--- /dev/null
+++ b/integration-tests/ibm-watson-language/src/test/java/org/apache/camel/quarkus/component/ibm/watson/language/it/IbmWatsonLanguageTest.java
@@ -0,0 +1,142 @@
+/*
+ * 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.ibm.watson.language.it;
+
+import io.quarkus.test.junit.QuarkusTest;
+import io.restassured.RestAssured;
+import io.restassured.http.ContentType;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
+
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.hasKey;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.not;
+import static org.hamcrest.Matchers.notNullValue;
+
+@EnabledIfSystemProperty(named = "camel.ibm.watson.apiKey", matches = ".*", disabledReason = "IBM Watson API Key not provided")
+@EnabledIfSystemProperty(named = "camel.ibm.watson.serviceUrl", matches = ".*", disabledReason = "IBM Watson Service URL not provided")
+@QuarkusTest
+class IbmWatsonLanguageTest {
+
+ @Test
+ public void testAnalyzeTextSentiment() {
+ String text = "I love using Apache Camel for integration! It makes my life so much easier.";
+
+ RestAssured.given()
+ .contentType(ContentType.TEXT)
+ .body(text)
+ .post("/ibm-watson-language/analyze/text/sentiment")
+ .then()
+ .statusCode(200)
+ .body("sentiment", notNullValue())
+ .body("sentiment.document", notNullValue())
+ .body("sentiment.document.label", is("positive"))
+ .body("language", equalTo("en"));
+ }
+
+ @Test
+ public void testAnalyzeTextEmotion() {
+ String text = "I am excited about this new feature! It's going to be amazing.";
+
+ RestAssured.given()
+ .contentType(ContentType.TEXT)
+ .body(text)
+ .post("/ibm-watson-language/analyze/text/emotion")
+ .then()
+ .statusCode(200)
+ .body("emotion", notNullValue())
+ .body("emotion.document", notNullValue())
+ .body("emotion.document.emotion", hasKey("joy"))
+ .body("emotion.document.emotion", hasKey("sadness"))
+ .body("language", equalTo("en"));
+ }
+
+ @Test
+ public void testAnalyzeTextEntities() {
+ String text = "IBM Watson is an artificial intelligence technology developed in New York.";
+
+ RestAssured.given()
+ .contentType(ContentType.TEXT)
+ .body(text)
+ .post("/ibm-watson-language/analyze/text/entities")
+ .then()
+ .statusCode(200)
+ .body("entities", notNullValue())
+ .body("entities.size()", not(0))
+ .body("language", equalTo("en"));
+ }
+
+ @Test
+ public void testAnalyzeTextKeywords() {
+ String text = "Apache Camel Quarkus provides fast startup times and low memory footprint for microservices.";
+
+ RestAssured.given()
+ .contentType(ContentType.TEXT)
+ .body(text)
+ .post("/ibm-watson-language/analyze/text/keywords")
+ .then()
+ .statusCode(200)
+ .body("keywords", notNullValue())
+ .body("keywords.size()", not(0))
+ .body("language", equalTo("en"));
+ }
+
+ @Test
+ public void testAnalyzeTextConcepts() {
+ String text = "Machine learning and artificial intelligence are transforming the technology industry.";
+
+ RestAssured.given()
+ .contentType(ContentType.TEXT)
+ .body(text)
+ .post("/ibm-watson-language/analyze/text/concepts")
+ .then()
+ .statusCode(200)
+ .body("concepts", notNullValue())
+ .body("concepts.size()", not(0))
+ .body("language", equalTo("en"));
+ }
+
+ @Test
+ public void testAnalyzeTextCategories() {
+ String text = "The stock market experienced significant volatility today as investors reacted to the latest economic data.";
+
+ RestAssured.given()
+ .contentType(ContentType.TEXT)
+ .body(text)
+ .post("/ibm-watson-language/analyze/text/categories")
+ .then()
+ .statusCode(200)
+ .body("categories", notNullValue())
+ .body("categories.size()", not(0))
+ .body("language", equalTo("en"));
+ }
+
+ @Test
+ public void testAnalyzeUrl() {
+ String url = "https://www.ibm.com/watson";
+
+ RestAssured.given()
+ .contentType(ContentType.TEXT)
+ .body(url)
+ .post("/ibm-watson-language/analyze/url")
+ .then()
+ .statusCode(200)
+ .body("language", notNullValue())
+ .body("retrievedUrl", equalTo(url));
+ }
+}
diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml
index b9d959a23a..4394714861 100644
--- a/integration-tests/pom.xml
+++ b/integration-tests/pom.xml
@@ -112,6 +112,7 @@
<module>hl7</module>
<module>http-grouped</module>
<module>ibm-cos</module>
+ <module>ibm-watson-language</module>
<module>infinispan</module>
<module>infinispan-common</module>
<module>infinispan-quarkus-client</module>
diff --git a/pom.xml b/pom.xml
index cff9d6cb3b..16d615cd19 100644
--- a/pom.xml
+++ b/pom.xml
@@ -117,7 +117,7 @@
<hapi-base.version>${hapi-base-version}</hapi-base.version>
<hapi-fhir.version>${hapi-fhir-version}</hapi-fhir.version>
<hapi-fhir-core.version>6.7.9</hapi-fhir-core.version><!-- @sync ca.uhn.hapi.fhir:hapi-fhir:${hapi-fhir.version} prop:fhir_core_version -->
- <ibm.java-sdk-core.version>9.23.1</ibm.java-sdk-core.version><!-- Required because of https://github.com/apache/camel-quarkus/issues/7269 -->
+ <ibm.java-sdk-core.version>9.25.0</ibm.java-sdk-core.version><!-- Required because of https://github.com/apache/camel-quarkus/issues/7269 -->
<ibm.mq.client.version>9.4.5.0</ibm.mq.client.version>
<icu4j.version>${icu4j-version}</icu4j.version>
<influxdb.version>${influx-java-driver-version}</influxdb.version>
diff --git a/poms/bom/pom.xml b/poms/bom/pom.xml
index 6047f7f5b2..ff51cea39d 100644
--- a/poms/bom/pom.xml
+++ b/poms/bom/pom.xml
@@ -7475,6 +7475,11 @@
<artifactId>re2j</artifactId>
<version>${re2j.version}</version>
</dependency>
+ <dependency>
+ <groupId>com.ibm.cloud</groupId>
+ <artifactId>sdk-core</artifactId>
+ <version>${ibm.java-sdk-core.version}</version>
+ </dependency>
<dependency>
<groupId>com.ibm.icu</groupId>
<artifactId>icu4j</artifactId>
diff --git a/poms/bom/src/main/generated/flattened-full-pom.xml b/poms/bom/src/main/generated/flattened-full-pom.xml
index 296c678f85..babf2e42f3 100644
--- a/poms/bom/src/main/generated/flattened-full-pom.xml
+++ b/poms/bom/src/main/generated/flattened-full-pom.xml
@@ -7358,6 +7358,11 @@
<artifactId>re2j</artifactId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
<version>1.7</version><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
</dependency>
+ <dependency>
+ <groupId>com.ibm.cloud</groupId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
+ <artifactId>sdk-core</artifactId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
+ <version>9.25.0</version><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
+ </dependency>
<dependency>
<groupId>com.ibm.icu</groupId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
<artifactId>icu4j</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 3279532795..298b22aec9 100644
--- a/poms/bom/src/main/generated/flattened-reduced-pom.xml
+++ b/poms/bom/src/main/generated/flattened-reduced-pom.xml
@@ -7337,6 +7337,11 @@
<artifactId>re2j</artifactId>
<version>1.7</version>
</dependency>
+ <dependency>
+ <groupId>com.ibm.cloud</groupId>
+ <artifactId>sdk-core</artifactId>
+ <version>9.25.0</version>
+ </dependency>
<dependency>
<groupId>com.ibm.icu</groupId>
<artifactId>icu4j</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 0c273b9be3..50a087bd6e 100644
--- a/poms/bom/src/main/generated/flattened-reduced-verbose-pom.xml
+++ b/poms/bom/src/main/generated/flattened-reduced-verbose-pom.xml
@@ -7337,6 +7337,11 @@
<artifactId>re2j</artifactId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
<version>1.7</version><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
</dependency>
+ <dependency>
+ <groupId>com.ibm.cloud</groupId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
+ <artifactId>sdk-core</artifactId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
+ <version>9.25.0</version><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
+ </dependency>
<dependency>
<groupId>com.ibm.icu</groupId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
<artifactId>icu4j</artifactId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
diff --git a/tooling/scripts/test-categories.yaml b/tooling/scripts/test-categories.yaml
index 790327c7a6..b4ecdfe4ca 100644
--- a/tooling/scripts/test-categories.yaml
+++ b/tooling/scripts/test-categories.yaml
@@ -188,6 +188,7 @@ group-10:
- google-secret-manager
- groovy
- ibm-cos
+ - ibm-watson-language
- jolokia
- joor
- langchain4j-tokenizer