This is an automated email from the ASF dual-hosted git repository.
davsclaus 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 077b2aebdd0b CAMEL-26972: camel-alibaba - manage com.aliyun:tea-util
next to tea-openapi (#30014)
077b2aebdd0b is described below
commit 077b2aebdd0b610c09434e6575dad41990c5ae04
Author: Saravanakumar Selvaraj <[email protected]>
AuthorDate: Sun Nov 15 15:04:12 2026 +0000
CAMEL-26972: camel-alibaba - manage com.aliyun:tea-util next to tea-openapi
(#30014)
…penapi
parent/pom.xml managed com.aliyun:tea-openapi but not com.aliyun:tea-util,
so camel-alibaba-fc kept the tea-util 0.2.23 and camel-alibaba-sms the
0.2.26 that their SDKs declare. tea-openapi 0.3.20 reads RuntimeOptions
fields that these versions lack: every fc request failed with a
NoSuchFieldError before it was sent, and every sms request that got a
response failed after it.
Manage tea-util at 0.2.28, the version that tea-openapi 0.3.20 declares.
New tests in camel-alibaba-fc and camel-alibaba-sms send one request with
the real SDK client through the producer to a local HTTP server and check
that the exchange succeeds. Without the managed version they fail with the
NoSuchFieldError.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
.../alibaba/fc/InvokeFunctionRealClientTest.java | 107 ++++++++++++++++++++
.../alibaba/sms/SendSmsRealClientTest.java | 110 +++++++++++++++++++++
parent/pom.xml | 7 ++
3 files changed, 224 insertions(+)
diff --git
a/components/camel-alibaba/camel-alibaba-fc/src/test/java/org/apache/camel/component/alibaba/fc/InvokeFunctionRealClientTest.java
b/components/camel-alibaba/camel-alibaba-fc/src/test/java/org/apache/camel/component/alibaba/fc/InvokeFunctionRealClientTest.java
new file mode 100644
index 000000000000..d8b797757647
--- /dev/null
+++
b/components/camel-alibaba/camel-alibaba-fc/src/test/java/org/apache/camel/component/alibaba/fc/InvokeFunctionRealClientTest.java
@@ -0,0 +1,107 @@
+/*
+ * 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.component.alibaba.fc;
+
+import java.io.OutputStream;
+import java.net.InetSocketAddress;
+import java.nio.charset.StandardCharsets;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import com.aliyun.fc_open20210406.Client;
+import com.aliyun.teaopenapi.models.Config;
+import com.sun.net.httpserver.HttpServer;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.spi.Registry;
+import org.apache.camel.test.junit6.CamelTestSupport;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * invokeFunction with the Function Compute client of the SDK, not a mock,
against a local HTTP server. tea-openapi
+ * fails with a NoSuchFieldError when the build resolves a tea-util older than
the one it declares (CAMEL-26972).
+ */
+class InvokeFunctionRealClientTest extends CamelTestSupport {
+
+ private final TestConfiguration testConfiguration = new
TestConfiguration();
+ private final List<String> actions = new CopyOnWriteArrayList<>();
+ private HttpServer server;
+
+ @Override
+ protected void setupResources() throws Exception {
+ super.setupResources();
+ server = HttpServer.create(new InetSocketAddress("127.0.0.1", 0), 0);
+ server.createContext("/", exchange -> {
+ actions.add(exchange.getRequestHeaders().getFirst("x-acs-action"));
+ byte[] answer = "hello fc".getBytes(StandardCharsets.UTF_8);
+ exchange.sendResponseHeaders(200, answer.length);
+ try (OutputStream out = exchange.getResponseBody()) {
+ out.write(answer);
+ }
+ });
+ server.start();
+ }
+
+ @Override
+ protected void cleanupResources() throws Exception {
+ if (server != null) {
+ server.stop(0);
+ }
+ super.cleanupResources();
+ }
+
+ @Override
+ protected void bindToRegistry(Registry registry) throws Exception {
+ // plain HTTP, so that the local server needs no TLS setup
+ Config config = new Config()
+ .setAccessKeyId(testConfiguration.getProperty("accessKey"))
+ .setAccessKeySecret(testConfiguration.getProperty("secretKey"))
+ .setRegionId(testConfiguration.getProperty("region"))
+ .setProtocol("HTTP")
+ .setEndpoint("127.0.0.1:" + server.getAddress().getPort());
+ registry.bind("fcClient", new Client(config));
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ from("direct:invoke")
+ .to("alibaba-fc:invokeFunction"
+ + "?serviceName=" +
testConfiguration.getProperty("serviceName")
+ + "&functionName=" +
testConfiguration.getProperty("functionName")
+ + "®ion=" +
testConfiguration.getProperty("region")
+ + "&fcClient=#fcClient");
+ }
+ };
+ }
+
+ @Test
+ void invokeFunctionSucceeds() {
+ // requestBody throws the exception of the exchange when the exchange
fails
+ @SuppressWarnings("unchecked")
+ Map<String, Object> response = template.requestBody("direct:invoke",
"{\"name\":\"camel\"}", Map.class);
+
+ assertThat(response)
+ .containsEntry("statusCode", 200)
+ .containsEntry("body", "hello
fc".getBytes(StandardCharsets.UTF_8));
+ assertThat(actions).containsExactly("InvokeFunction");
+ }
+}
diff --git
a/components/camel-alibaba/camel-alibaba-sms/src/test/java/org/apache/camel/component/alibaba/sms/SendSmsRealClientTest.java
b/components/camel-alibaba/camel-alibaba-sms/src/test/java/org/apache/camel/component/alibaba/sms/SendSmsRealClientTest.java
new file mode 100644
index 000000000000..5a60fc95bb9d
--- /dev/null
+++
b/components/camel-alibaba/camel-alibaba-sms/src/test/java/org/apache/camel/component/alibaba/sms/SendSmsRealClientTest.java
@@ -0,0 +1,110 @@
+/*
+ * 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.component.alibaba.sms;
+
+import java.io.OutputStream;
+import java.net.InetSocketAddress;
+import java.nio.charset.StandardCharsets;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import com.aliyun.dysmsapi20170525.Client;
+import com.aliyun.teaopenapi.models.Config;
+import com.sun.net.httpserver.HttpServer;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.spi.Registry;
+import org.apache.camel.test.junit6.CamelTestSupport;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * sendSms with the Short Message Service client of the SDK, not a mock,
against a local HTTP server. tea-openapi fails
+ * with a NoSuchFieldError when the build resolves a tea-util older than the
one it declares (CAMEL-26972).
+ */
+class SendSmsRealClientTest extends CamelTestSupport {
+
+ private final TestConfiguration testConfiguration = new
TestConfiguration();
+ private final List<String> actions = new CopyOnWriteArrayList<>();
+ private HttpServer server;
+
+ @Override
+ protected void setupResources() throws Exception {
+ super.setupResources();
+ server = HttpServer.create(new InetSocketAddress("127.0.0.1", 0), 0);
+ server.createContext("/", exchange -> {
+ actions.add(exchange.getRequestHeaders().getFirst("x-acs-action"));
+ byte[] answer =
"{\"Code\":\"OK\",\"Message\":\"OK\",\"BizId\":\"biz-123\",\"RequestId\":\"req-456\"}"
+ .getBytes(StandardCharsets.UTF_8);
+ exchange.getResponseHeaders().add("Content-Type",
"application/json");
+ exchange.sendResponseHeaders(200, answer.length);
+ try (OutputStream out = exchange.getResponseBody()) {
+ out.write(answer);
+ }
+ });
+ server.start();
+ }
+
+ @Override
+ protected void cleanupResources() throws Exception {
+ if (server != null) {
+ server.stop(0);
+ }
+ super.cleanupResources();
+ }
+
+ @Override
+ protected void bindToRegistry(Registry registry) throws Exception {
+ // plain HTTP, so that the local server needs no TLS setup
+ Config config = new Config()
+ .setAccessKeyId(testConfiguration.getProperty("accessKey"))
+ .setAccessKeySecret(testConfiguration.getProperty("secretKey"))
+ .setRegionId(testConfiguration.getProperty("region"))
+ .setProtocol("HTTP")
+ .setEndpoint("127.0.0.1:" + server.getAddress().getPort());
+ registry.bind("smsClient", new Client(config));
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ from("direct:send")
+ .to("alibaba-sms:sendSms"
+ + "?phoneNumbers=" +
testConfiguration.getProperty("phoneNumbers")
+ + "&signName=" +
testConfiguration.getProperty("signName")
+ + "&templateCode=" +
testConfiguration.getProperty("templateCode")
+ + "®ion=" +
testConfiguration.getProperty("region")
+ + "&smsClient=#smsClient");
+ }
+ };
+ }
+
+ @Test
+ void sendSmsSucceeds() {
+ // requestBody throws the exception of the exchange when the exchange
fails
+ @SuppressWarnings("unchecked")
+ Map<String, Object> response = template.requestBody("direct:send",
"ignored", Map.class);
+
+ assertThat(response)
+ .containsEntry("statusCode", 200)
+ .containsEntry("code", "OK");
+ assertThat(actions).containsExactly("SendSms");
+ }
+}
diff --git a/parent/pom.xml b/parent/pom.xml
index 22ce4c00d2b1..5ee01cade334 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -74,6 +74,8 @@
<aliyun-eventbridge-client-version>1.3.14</aliyun-eventbridge-client-version>
<aliyun-tablestore-version>5.17.14</aliyun-tablestore-version>
<tea-openapi-version>0.3.20</tea-openapi-version>
+ <!-- keep at least at the tea-util version that tea-openapi declares,
as the Alibaba SDKs declare older ones -->
+ <tea-util-version>0.2.28</tea-util-version>
<!-- the Alibaba SDKs declare com.aliyun:tea as an open version range,
so it is pinned in dependencyManagement -->
<tea-version>1.4.3</tea-version>
<amazon-kinesis-client-version>3.5.4</amazon-kinesis-client-version>
@@ -769,6 +771,11 @@
<artifactId>tea-openapi</artifactId>
<version>${tea-openapi-version}</version>
</dependency>
+ <dependency>
+ <groupId>com.aliyun</groupId>
+ <artifactId>tea-util</artifactId>
+ <version>${tea-util-version}</version>
+ </dependency>
<dependency>
<groupId>com.aliyun.openservices</groupId>
<artifactId>tablestore</artifactId>