use of jakarta.jms.Session in project spring-framework by spring-projects.
the class MethodJmsListenerEndpointTests method resolveCustomHeaderNameAndPayloadWithHeaderNameSet.
@Test
void resolveCustomHeaderNameAndPayloadWithHeaderNameSet() throws JMSException {
MessagingMessageListenerAdapter listener = createDefaultInstance(String.class, int.class);
Session session = mock(Session.class);
StubTextMessage message = createSimpleJmsTextMessage("my payload");
message.setIntProperty("myCounter", 24);
listener.onMessage(message, session);
assertDefaultListenerMethodInvocation();
}
use of jakarta.jms.Session in project spring-framework by spring-projects.
the class MethodJmsListenerEndpointTests method emptySendTo.
@Test
void emptySendTo() throws JMSException {
MessagingMessageListenerAdapter listener = createDefaultInstance(String.class);
TextMessage reply = mock(TextMessage.class);
Session session = mock(Session.class);
given(session.createTextMessage("content")).willReturn(reply);
assertThatExceptionOfType(ReplyFailureException.class).isThrownBy(() -> listener.onMessage(createSimpleJmsTextMessage("content"), session)).withCauseInstanceOf(InvalidDestinationException.class);
}
use of jakarta.jms.Session in project spring-framework by spring-projects.
the class MethodJmsListenerEndpointTests method resolveGenericMessage.
@Test
void resolveGenericMessage() throws JMSException {
MessagingMessageListenerAdapter listener = createDefaultInstance(Message.class);
Session session = mock(Session.class);
listener.onMessage(createSimpleJmsTextMessage("test"), session);
assertDefaultListenerMethodInvocation();
}
use of jakarta.jms.Session in project spring-framework by spring-projects.
the class MethodJmsListenerEndpointTests method processAndReply.
@Test
void processAndReply() throws JMSException {
MessagingMessageListenerAdapter listener = createDefaultInstance(String.class);
String body = "echo text";
String correlationId = "link-1234";
Destination replyDestination = new Destination() {
};
TextMessage reply = mock(TextMessage.class);
QueueSender queueSender = mock(QueueSender.class);
Session session = mock(Session.class);
given(session.createTextMessage(body)).willReturn(reply);
given(session.createProducer(replyDestination)).willReturn(queueSender);
listener.setDefaultResponseDestination(replyDestination);
StubTextMessage inputMessage = createSimpleJmsTextMessage(body);
inputMessage.setJMSCorrelationID(correlationId);
listener.onMessage(inputMessage, session);
assertDefaultListenerMethodInvocation();
verify(reply).setJMSCorrelationID(correlationId);
verify(queueSender).send(reply);
verify(queueSender).close();
}
use of jakarta.jms.Session in project spring-framework by spring-projects.
the class MethodJmsListenerEndpointTests method processAndReplyWithSendTo.
private void processAndReplyWithSendTo(MessagingMessageListenerAdapter listener, String replyDestinationName, boolean pubSubDomain, QosSettings replyQosSettings) throws JMSException {
String body = "echo text";
String correlationId = "link-1234";
Destination replyDestination = new Destination() {
};
DestinationResolver destinationResolver = mock(DestinationResolver.class);
TextMessage reply = mock(TextMessage.class);
QueueSender queueSender = mock(QueueSender.class);
Session session = mock(Session.class);
given(destinationResolver.resolveDestinationName(session, replyDestinationName, pubSubDomain)).willReturn(replyDestination);
given(session.createTextMessage(body)).willReturn(reply);
given(session.createProducer(replyDestination)).willReturn(queueSender);
listener.setDestinationResolver(destinationResolver);
StubTextMessage inputMessage = createSimpleJmsTextMessage(body);
inputMessage.setJMSCorrelationID(correlationId);
listener.onMessage(inputMessage, session);
verify(destinationResolver).resolveDestinationName(session, replyDestinationName, pubSubDomain);
verify(reply).setJMSCorrelationID(correlationId);
if (replyQosSettings != null) {
verify(queueSender).send(reply, replyQosSettings.getDeliveryMode(), replyQosSettings.getPriority(), replyQosSettings.getTimeToLive());
} else {
verify(queueSender).send(reply);
}
verify(queueSender).close();
}
Aggregations