From b3954a6642d6a060293604c92ae0b1ee4172b9a9 Mon Sep 17 00:00:00 2001 From: NeatGuyCoding <15627489+NeatGuyCoding@users.noreply.github.com> Date: Sat, 5 Jul 2025 21:36:46 +0800 Subject: [PATCH 1/3] Fix JmsClient javadoc and add more test cases Signed-off-by: NeatGuyCoding <15627489+NeatGuyCoding@users.noreply.github.com> --- .../main/java/org/springframework/jms/core/JmsClient.java | 8 ++++++-- .../java/org/springframework/jms/core/JmsClientTests.java | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/spring-jms/src/main/java/org/springframework/jms/core/JmsClient.java b/spring-jms/src/main/java/org/springframework/jms/core/JmsClient.java index 736380d21179..893d2e6c38f8 100644 --- a/spring-jms/src/main/java/org/springframework/jms/core/JmsClient.java +++ b/spring-jms/src/main/java/org/springframework/jms/core/JmsClient.java @@ -67,6 +67,7 @@ interface JmsClient { /** * Create a new {@code JmsClient} for the given {@link ConnectionFactory}. * @param connectionFactory the factory to obtain JMS connections from + * @return a new {@code JmsClient} instance */ static JmsClient create(ConnectionFactory connectionFactory) { return new DefaultJmsClient(connectionFactory, null); @@ -76,25 +77,28 @@ static JmsClient create(ConnectionFactory connectionFactory) { * Create a new {@code JmsClient} for the given {@link ConnectionFactory}. * @param connectionFactory the factory to obtain JMS connections from * @param messageConverter the message converter for payload objects + * @return a new {@code JmsClient} instance */ static JmsClient create(ConnectionFactory connectionFactory, MessageConverter messageConverter) { return new DefaultJmsClient(connectionFactory, messageConverter); } /** - * Create a new {@code JmsClient} for the given {@link ConnectionFactory}. + * Create a new {@code JmsClient} for the given {@link JmsOperations}. * @param jmsTemplate the {@link JmsTemplate} to use for performing operations * (can be a custom {@link JmsOperations} implementation as well) + * @return a new {@code JmsClient} instance */ static JmsClient create(JmsOperations jmsTemplate) { return new DefaultJmsClient(jmsTemplate, null); } /** - * Create a new {@code JmsClient} for the given {@link ConnectionFactory}. + * Create a new {@code JmsClient} for the given {@link JmsOperations}. * @param jmsTemplate the {@link JmsTemplate} to use for performing operations * (can be a custom {@link JmsOperations} implementation as well) * @param messageConverter the message converter for payload objects + * @return a new {@code JmsClient} instance */ static JmsClient create(JmsOperations jmsTemplate, MessageConverter messageConverter) { return new DefaultJmsClient(jmsTemplate, messageConverter); diff --git a/spring-jms/src/test/java/org/springframework/jms/core/JmsClientTests.java b/spring-jms/src/test/java/org/springframework/jms/core/JmsClientTests.java index a7731d2798ab..37cce526b0e2 100644 --- a/spring-jms/src/test/java/org/springframework/jms/core/JmsClientTests.java +++ b/spring-jms/src/test/java/org/springframework/jms/core/JmsClientTests.java @@ -121,7 +121,7 @@ void convertAndSendPayloadName() throws JMSException { } @Test - void convertAndSendPayloadAndHeaders() { + void convertAndSendPayloadAndHeaders() throws JMSException { Destination destination = new Destination() {}; Map headers = new HashMap<>(); headers.put("foo", "bar"); @@ -129,16 +129,20 @@ void convertAndSendPayloadAndHeaders() { this.jmsClient.destination(destination).send("Hello", headers); verify(this.jmsTemplate).send(eq(destination), this.messageCreator.capture()); assertTextMessage(this.messageCreator.getValue()); // see createTextMessage + TextMessage jmsMessage = createTextMessage(this.messageCreator.getValue()); + assertThat(jmsMessage.getStringProperty("foo")).isEqualTo("bar"); } @Test - void convertAndSendPayloadAndHeadersName() { + void convertAndSendPayloadAndHeadersName() throws JMSException { Map headers = new HashMap<>(); headers.put("foo", "bar"); this.jmsClient.destination("myQueue").send("Hello", headers); verify(this.jmsTemplate).send(eq("myQueue"), this.messageCreator.capture()); assertTextMessage(this.messageCreator.getValue()); // see createTextMessage + TextMessage jmsMessage = createTextMessage(this.messageCreator.getValue()); + assertThat(jmsMessage.getStringProperty("foo")).isEqualTo("bar"); } @Test From 6b603af15c6aeb6b634126139d9e60284a924c7f Mon Sep 17 00:00:00 2001 From: NeatGuyCoding <15627489+NeatGuyCoding@users.noreply.github.com> Date: Mon, 7 Jul 2025 07:26:42 +0800 Subject: [PATCH 2/3] revert changes as requested for fixing JmsClient javadoc Signed-off-by: NeatGuyCoding <15627489+NeatGuyCoding@users.noreply.github.com> --- .../java/org/springframework/jms/core/JmsClient.java | 4 ---- .../org/springframework/jms/core/JmsClientTests.java | 10 +++------- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/spring-jms/src/main/java/org/springframework/jms/core/JmsClient.java b/spring-jms/src/main/java/org/springframework/jms/core/JmsClient.java index 893d2e6c38f8..1c71e9f1a7d6 100644 --- a/spring-jms/src/main/java/org/springframework/jms/core/JmsClient.java +++ b/spring-jms/src/main/java/org/springframework/jms/core/JmsClient.java @@ -67,7 +67,6 @@ interface JmsClient { /** * Create a new {@code JmsClient} for the given {@link ConnectionFactory}. * @param connectionFactory the factory to obtain JMS connections from - * @return a new {@code JmsClient} instance */ static JmsClient create(ConnectionFactory connectionFactory) { return new DefaultJmsClient(connectionFactory, null); @@ -77,7 +76,6 @@ static JmsClient create(ConnectionFactory connectionFactory) { * Create a new {@code JmsClient} for the given {@link ConnectionFactory}. * @param connectionFactory the factory to obtain JMS connections from * @param messageConverter the message converter for payload objects - * @return a new {@code JmsClient} instance */ static JmsClient create(ConnectionFactory connectionFactory, MessageConverter messageConverter) { return new DefaultJmsClient(connectionFactory, messageConverter); @@ -87,7 +85,6 @@ static JmsClient create(ConnectionFactory connectionFactory, MessageConverter me * Create a new {@code JmsClient} for the given {@link JmsOperations}. * @param jmsTemplate the {@link JmsTemplate} to use for performing operations * (can be a custom {@link JmsOperations} implementation as well) - * @return a new {@code JmsClient} instance */ static JmsClient create(JmsOperations jmsTemplate) { return new DefaultJmsClient(jmsTemplate, null); @@ -98,7 +95,6 @@ static JmsClient create(JmsOperations jmsTemplate) { * @param jmsTemplate the {@link JmsTemplate} to use for performing operations * (can be a custom {@link JmsOperations} implementation as well) * @param messageConverter the message converter for payload objects - * @return a new {@code JmsClient} instance */ static JmsClient create(JmsOperations jmsTemplate, MessageConverter messageConverter) { return new DefaultJmsClient(jmsTemplate, messageConverter); diff --git a/spring-jms/src/test/java/org/springframework/jms/core/JmsClientTests.java b/spring-jms/src/test/java/org/springframework/jms/core/JmsClientTests.java index 37cce526b0e2..d30370d63fcc 100644 --- a/spring-jms/src/test/java/org/springframework/jms/core/JmsClientTests.java +++ b/spring-jms/src/test/java/org/springframework/jms/core/JmsClientTests.java @@ -121,7 +121,7 @@ void convertAndSendPayloadName() throws JMSException { } @Test - void convertAndSendPayloadAndHeaders() throws JMSException { + void convertAndSendPayloadAndHeaders() { Destination destination = new Destination() {}; Map headers = new HashMap<>(); headers.put("foo", "bar"); @@ -129,20 +129,16 @@ void convertAndSendPayloadAndHeaders() throws JMSException { this.jmsClient.destination(destination).send("Hello", headers); verify(this.jmsTemplate).send(eq(destination), this.messageCreator.capture()); assertTextMessage(this.messageCreator.getValue()); // see createTextMessage - TextMessage jmsMessage = createTextMessage(this.messageCreator.getValue()); - assertThat(jmsMessage.getStringProperty("foo")).isEqualTo("bar"); } @Test - void convertAndSendPayloadAndHeadersName() throws JMSException { + void convertAndSendPayloadAndHeadersName() { Map headers = new HashMap<>(); headers.put("foo", "bar"); this.jmsClient.destination("myQueue").send("Hello", headers); verify(this.jmsTemplate).send(eq("myQueue"), this.messageCreator.capture()); assertTextMessage(this.messageCreator.getValue()); // see createTextMessage - TextMessage jmsMessage = createTextMessage(this.messageCreator.getValue()); - assertThat(jmsMessage.getStringProperty("foo")).isEqualTo("bar"); } @Test @@ -516,4 +512,4 @@ protected TextMessage createTextMessage(MessageCreator creator) throws JMSExcept return (TextMessage) message; } -} +} \ No newline at end of file From 04e2bb7d3149d5b344a6994c74a7670422070593 Mon Sep 17 00:00:00 2001 From: NeatGuyCoding <15627489+NeatGuyCoding@users.noreply.github.com> Date: Mon, 7 Jul 2025 09:21:52 +0800 Subject: [PATCH 3/3] revert changes as requested for fixing JmsClient javadoc fix checkstyle Signed-off-by: NeatGuyCoding <15627489+NeatGuyCoding@users.noreply.github.com> --- .../test/java/org/springframework/jms/core/JmsClientTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-jms/src/test/java/org/springframework/jms/core/JmsClientTests.java b/spring-jms/src/test/java/org/springframework/jms/core/JmsClientTests.java index d30370d63fcc..a7731d2798ab 100644 --- a/spring-jms/src/test/java/org/springframework/jms/core/JmsClientTests.java +++ b/spring-jms/src/test/java/org/springframework/jms/core/JmsClientTests.java @@ -512,4 +512,4 @@ protected TextMessage createTextMessage(MessageCreator creator) throws JMSExcept return (TextMessage) message; } -} \ No newline at end of file +}