Skip to content

Commit b3954a6

Browse files
committed
Fix JmsClient javadoc and add more test cases
Signed-off-by: NeatGuyCoding <[email protected]>
1 parent 0111329 commit b3954a6

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

spring-jms/src/main/java/org/springframework/jms/core/JmsClient.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ interface JmsClient {
6767
/**
6868
* Create a new {@code JmsClient} for the given {@link ConnectionFactory}.
6969
* @param connectionFactory the factory to obtain JMS connections from
70+
* @return a new {@code JmsClient} instance
7071
*/
7172
static JmsClient create(ConnectionFactory connectionFactory) {
7273
return new DefaultJmsClient(connectionFactory, null);
@@ -76,25 +77,28 @@ static JmsClient create(ConnectionFactory connectionFactory) {
7677
* Create a new {@code JmsClient} for the given {@link ConnectionFactory}.
7778
* @param connectionFactory the factory to obtain JMS connections from
7879
* @param messageConverter the message converter for payload objects
80+
* @return a new {@code JmsClient} instance
7981
*/
8082
static JmsClient create(ConnectionFactory connectionFactory, MessageConverter messageConverter) {
8183
return new DefaultJmsClient(connectionFactory, messageConverter);
8284
}
8385

8486
/**
85-
* Create a new {@code JmsClient} for the given {@link ConnectionFactory}.
87+
* Create a new {@code JmsClient} for the given {@link JmsOperations}.
8688
* @param jmsTemplate the {@link JmsTemplate} to use for performing operations
8789
* (can be a custom {@link JmsOperations} implementation as well)
90+
* @return a new {@code JmsClient} instance
8891
*/
8992
static JmsClient create(JmsOperations jmsTemplate) {
9093
return new DefaultJmsClient(jmsTemplate, null);
9194
}
9295

9396
/**
94-
* Create a new {@code JmsClient} for the given {@link ConnectionFactory}.
97+
* Create a new {@code JmsClient} for the given {@link JmsOperations}.
9598
* @param jmsTemplate the {@link JmsTemplate} to use for performing operations
9699
* (can be a custom {@link JmsOperations} implementation as well)
97100
* @param messageConverter the message converter for payload objects
101+
* @return a new {@code JmsClient} instance
98102
*/
99103
static JmsClient create(JmsOperations jmsTemplate, MessageConverter messageConverter) {
100104
return new DefaultJmsClient(jmsTemplate, messageConverter);

spring-jms/src/test/java/org/springframework/jms/core/JmsClientTests.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,24 +121,28 @@ void convertAndSendPayloadName() throws JMSException {
121121
}
122122

123123
@Test
124-
void convertAndSendPayloadAndHeaders() {
124+
void convertAndSendPayloadAndHeaders() throws JMSException {
125125
Destination destination = new Destination() {};
126126
Map<String, Object> headers = new HashMap<>();
127127
headers.put("foo", "bar");
128128

129129
this.jmsClient.destination(destination).send("Hello", headers);
130130
verify(this.jmsTemplate).send(eq(destination), this.messageCreator.capture());
131131
assertTextMessage(this.messageCreator.getValue()); // see createTextMessage
132+
TextMessage jmsMessage = createTextMessage(this.messageCreator.getValue());
133+
assertThat(jmsMessage.getStringProperty("foo")).isEqualTo("bar");
132134
}
133135

134136
@Test
135-
void convertAndSendPayloadAndHeadersName() {
137+
void convertAndSendPayloadAndHeadersName() throws JMSException {
136138
Map<String, Object> headers = new HashMap<>();
137139
headers.put("foo", "bar");
138140

139141
this.jmsClient.destination("myQueue").send("Hello", headers);
140142
verify(this.jmsTemplate).send(eq("myQueue"), this.messageCreator.capture());
141143
assertTextMessage(this.messageCreator.getValue()); // see createTextMessage
144+
TextMessage jmsMessage = createTextMessage(this.messageCreator.getValue());
145+
assertThat(jmsMessage.getStringProperty("foo")).isEqualTo("bar");
142146
}
143147

144148
@Test

0 commit comments

Comments
 (0)