use of jakarta.jms.TextMessage in project spring-framework by spring-projects.
the class JmsMessagingTemplateTests method convertAndSendPayloadName.
@Test
public void convertAndSendPayloadName() throws JMSException {
this.messagingTemplate.convertAndSend("myQueue", "my Payload");
verify(this.jmsTemplate).send(eq("myQueue"), this.messageCreator.capture());
TextMessage textMessage = createTextMessage(this.messageCreator.getValue());
assertThat(textMessage.getText()).isEqualTo("my Payload");
}
use of jakarta.jms.TextMessage in project spring-framework by spring-projects.
the class JmsMessagingTemplateTests method convertAndSendDefaultDestination.
@Test
public void convertAndSendDefaultDestination() throws JMSException {
Destination destination = new Destination() {
};
this.messagingTemplate.setDefaultDestination(destination);
this.messagingTemplate.convertAndSend("my Payload");
verify(this.jmsTemplate).send(eq(destination), this.messageCreator.capture());
TextMessage textMessage = createTextMessage(this.messageCreator.getValue());
assertThat(textMessage.getText()).isEqualTo("my Payload");
}
use of jakarta.jms.TextMessage in project spring-framework by spring-projects.
the class MessageListenerAdapterTests method testWithMessageDelegate.
@Test
void testWithMessageDelegate() throws Exception {
TextMessage textMessage = mock(TextMessage.class);
MessageDelegate delegate = mock(MessageDelegate.class);
MessageListenerAdapter adapter = new MessageListenerAdapter(delegate);
// we DON'T want the default SimpleMessageConversion happening...
adapter.setMessageConverter(null);
adapter.onMessage(textMessage);
verify(delegate).handleMessage(textMessage);
}
use of jakarta.jms.TextMessage in project spring-framework by spring-projects.
the class MessageListenerAdapterTests method testWithResponsiveMessageDelegateWhenReturnTypeIsAJMSMessageAndNoMessageConverterIsSupplied.
@Test
void testWithResponsiveMessageDelegateWhenReturnTypeIsAJMSMessageAndNoMessageConverterIsSupplied() throws Exception {
Queue destination = mock(Queue.class);
final TextMessage sentTextMessage = mock(TextMessage.class);
// correlation ID is queried when response is being created...
given(sentTextMessage.getJMSCorrelationID()).willReturn(CORRELATION_ID);
// Reply-To is queried when response is being created...
given(sentTextMessage.getJMSReplyTo()).willReturn(destination);
TextMessage responseMessage = mock(TextMessage.class);
QueueSender queueSender = mock(QueueSender.class);
Session session = mock(Session.class);
given(session.createProducer(destination)).willReturn(queueSender);
ResponsiveJmsTextMessageReturningMessageDelegate delegate = mock(ResponsiveJmsTextMessageReturningMessageDelegate.class);
given(delegate.handleMessage(sentTextMessage)).willReturn(responseMessage);
final MessageListenerAdapter adapter = new MessageListenerAdapter(delegate) {
@Override
protected Object extractMessage(Message message) {
return message;
}
};
adapter.setMessageConverter(null);
adapter.onMessage(sentTextMessage, session);
verify(responseMessage).setJMSCorrelationID(CORRELATION_ID);
verify(queueSender).send(responseMessage);
verify(queueSender).close();
}
use of jakarta.jms.TextMessage in project spring-framework by spring-projects.
the class MessageListenerAdapterTests method testWithResponsiveMessageDelegate_DoesNotSendReturnTextMessageIfNoSessionSupplied.
@Test
void testWithResponsiveMessageDelegate_DoesNotSendReturnTextMessageIfNoSessionSupplied() throws Exception {
TextMessage textMessage = mock(TextMessage.class);
ResponsiveMessageDelegate delegate = mock(ResponsiveMessageDelegate.class);
given(delegate.handleMessage(textMessage)).willReturn(TEXT);
MessageListenerAdapter adapter = new MessageListenerAdapter(delegate);
// we DON'T want the default SimpleMessageConversion happening...
adapter.setMessageConverter(null);
adapter.onMessage(textMessage);
}
Aggregations