gnodet-bot commented on code in PR #30604: URL: https://github.com/apache/camel/pull/30604#discussion_r4658979615
########## docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc: ########## @@ -7209,6 +7209,12 @@ The public method `MNSEndpoint.initClient()` now returns the `MNSClient` that th requests with, instead of `void`. A call that ignores the result compiles as before, but code compiled against an earlier version must be recompiled, and a subclass that overrides `initClient()` must return the client. +=== camel-alibaba-mns - ClientConfigurations has only the operation, the queue name and the topic name + +The record `ClientConfigurations` of `camel-alibaba-mns` no longer has the components `accessKey`, `secretKey`, `region` Review Comment: 💬 **Nit:** In Camel, "component" means a specific thing (a Camel connector). The sentence `no longer has the components accessKey...` will read oddly to Camel users who will think it refers to Camel components. Consider: `no longer has the fields` or `no longer has the record components`. ```suggestion The record `ClientConfigurations` of `camel-alibaba-mns` no longer has the fields `accessKey`, `secretKey`, `region` ``` ########## components/camel-alibaba/camel-alibaba-mns/src/test/java/org/apache/camel/component/alibaba/mns/MNSProducerWithoutKeysTest.java: ########## @@ -0,0 +1,94 @@ +/* + * 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.mns; + +import com.aliyun.mns.client.CloudQueue; +import com.aliyun.mns.client.CloudTopic; +import com.aliyun.mns.client.MNSClient; +import com.aliyun.mns.model.Message; +import com.aliyun.mns.model.TopicMessage; +import org.apache.camel.BindToRegistry; +import org.apache.camel.Exchange; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.alibaba.mns.constants.MNSHeaders; +import org.apache.camel.test.junit6.CamelTestSupport; +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +class MNSProducerWithoutKeysTest extends CamelTestSupport { + + private final TestConfiguration testConfiguration = new TestConfiguration(); + + @BindToRegistry("mnsClient") + MNSClient mnsClient = mock(MNSClient.class); + + CloudQueue cloudQueue = mock(CloudQueue.class); + + CloudTopic cloudTopic = mock(CloudTopic.class); + + @Override + protected RouteBuilder createRouteBuilder() { + return new RouteBuilder() { + @Override + public void configure() { + from("direct:send") + .to("alibaba-mns:" + testConfiguration.getProperty("queue") + "?mnsClient=#mnsClient"); + from("direct:publish") + .to("alibaba-mns:topic:" + testConfiguration.getProperty("topic") + "?mnsClient=#mnsClient"); + from("direct:delete") + .to("alibaba-mns:" + testConfiguration.getProperty("queue") + + "?operation=deleteMessage&mnsClient=#mnsClient"); + } + }; + } + + @Test + void testSendMessage() { + when(mnsClient.getQueueRef(testConfiguration.getProperty("queue"))).thenReturn(cloudQueue); + + Exchange exchange = template.send("direct:send", e -> e.getMessage().setBody("hello mns")); + + assertThat(exchange.getException()).isNull(); + verify(cloudQueue).putMessage(any(Message.class)); + } + + @Test + void testPublishMessage() { + when(mnsClient.getTopicRef(testConfiguration.getProperty("topic"))).thenReturn(cloudTopic); + + Exchange exchange = template.send("direct:publish", e -> e.getMessage().setBody("hello topic")); + + assertThat(exchange.getException()).isNull(); + verify(cloudTopic).publishMessage(any(TopicMessage.class)); + } + + @Test + void testDeleteMessage() throws Exception { Review Comment: 💬 **Nit:** `throws Exception` is not needed — `testDeleteMessage` only calls Camel's `template.send()` and `assertThat()`/`verify()`, none of which throw checked exceptions. The other two test methods correctly omit it. ```suggestion void testDeleteMessage() { ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
