You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by gn...@apache.org on 2026/03/19 12:14:05 UTC
(camel) branch main updated: CAMEL-23205: Fix OpenAI embedding ITs to check exchange exceptions and skip when no model
This is an automated email from the ASF dual-hosted git repository.
gnodet pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 83b16ef5ffe6 CAMEL-23205: Fix OpenAI embedding ITs to check exchange exceptions and skip when no model
83b16ef5ffe6 is described below
commit 83b16ef5ffe69998464635ebaffb3e045895902c
Author: Guillaume Nodet <gn...@gmail.com>
AuthorDate: Thu Mar 19 13:13:58 2026 +0100
CAMEL-23205: Fix OpenAI embedding ITs to check exchange exceptions and skip when no model
- Add assertion for exchange exceptions after template.request() calls
to surface real errors instead of misleading ClassCastExceptions
- Throw IllegalStateException in setupResources() when embedding model
is not available, so tests fail fast with a clear message
---
.../component/openai/integration/OpenAIEmbeddingsIT.java | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/components/camel-ai/camel-openai/src/test/java/org/apache/camel/component/openai/integration/OpenAIEmbeddingsIT.java b/components/camel-ai/camel-openai/src/test/java/org/apache/camel/component/openai/integration/OpenAIEmbeddingsIT.java
index 45cf8ec8a28b..f67e04874639 100644
--- a/components/camel-ai/camel-openai/src/test/java/org/apache/camel/component/openai/integration/OpenAIEmbeddingsIT.java
+++ b/components/camel-ai/camel-openai/src/test/java/org/apache/camel/component/openai/integration/OpenAIEmbeddingsIT.java
@@ -55,6 +55,10 @@ public class OpenAIEmbeddingsIT extends CamelTestSupport {
if (apiKey == null || apiKey.isEmpty()) {
apiKey = "dummy";
}
+ if (ObjectHelper.isEmpty(embeddingModel)) {
+ throw new IllegalStateException(
+ "Embedding model not available. Set the ollama.embedding.model system property or use a container with embedding support.");
+ }
}
@Override
@@ -101,6 +105,7 @@ public class OpenAIEmbeddingsIT extends CamelTestSupport {
Exchange result = template.request("direct:embedding",
e -> e.getIn().setBody("Apache Camel is an integration framework"));
+ assertThat(result.getException()).as("Exchange should not have an exception").isNull();
mockResponse.assertIsSatisfied();
assertThat(result).isNotNull();
@@ -128,6 +133,7 @@ public class OpenAIEmbeddingsIT extends CamelTestSupport {
Exchange result = template.request("direct:embeddingWithEncodingFormatFloat",
e -> e.getIn().setBody("Apache Camel is an integration framework"));
+ assertThat(result.getException()).as("Exchange should not have an exception").isNull();
mockResponse.assertIsSatisfied();
assertThat(result).isNotNull();
@@ -157,6 +163,7 @@ public class OpenAIEmbeddingsIT extends CamelTestSupport {
Exchange result = template.request("direct:embedding",
e -> e.getIn().setBody(inputs));
+ assertThat(result.getException()).as("Exchange should not have an exception").isNull();
mockResponse.assertIsSatisfied();
assertThat(result).isNotNull();
@@ -182,6 +189,8 @@ public class OpenAIEmbeddingsIT extends CamelTestSupport {
Exchange result1 = template.request("direct:embedding",
e -> e.getIn().setBody("Apache Camel is an integration framework"));
+ assertThat(result1.getException()).as("Exchange should not have an exception").isNull();
+
@SuppressWarnings("unchecked")
List<Float> embedding1 = (List<Float>) result1.getMessage().getBody();
assertThat(embedding1).isNotEmpty();
@@ -192,6 +201,8 @@ public class OpenAIEmbeddingsIT extends CamelTestSupport {
e.getIn().setHeader(OpenAIConstants.REFERENCE_EMBEDDING, embedding1);
});
+ assertThat(result2.getException()).as("Exchange should not have an exception").isNull();
+
@SuppressWarnings("unchecked")
List<Float> embedding2 = (List<Float>) result2.getMessage().getBody();
assertThat(embedding2).isNotEmpty();