use of org.springframework.jms.StubTextMessage 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 org.springframework.jms.StubTextMessage 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 org.springframework.jms.StubTextMessage 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();
}
use of org.springframework.jms.StubTextMessage in project spring-framework by spring-projects.
the class MethodJmsListenerEndpointTests method resolveJmsMessageHeaderAccessor.
@Test
void resolveJmsMessageHeaderAccessor() throws JMSException {
MessagingMessageListenerAdapter listener = createDefaultInstance(JmsMessageHeaderAccessor.class);
Session session = mock(Session.class);
StubTextMessage message = createSimpleJmsTextMessage("my payload");
message.setBooleanProperty("customBoolean", true);
message.setJMSPriority(9);
listener.onMessage(message, session);
assertDefaultListenerMethodInvocation();
}
use of org.springframework.jms.StubTextMessage in project spring-framework by spring-projects.
the class MethodJmsListenerEndpointTests method resolveHeaders.
@Test
void resolveHeaders() throws JMSException {
MessagingMessageListenerAdapter listener = createDefaultInstance(String.class, Map.class);
Session session = mock(Session.class);
StubTextMessage message = createSimpleJmsTextMessage("my payload");
message.setIntProperty("customInt", 1234);
message.setJMSMessageID("abcd-1234");
listener.onMessage(message, session);
assertDefaultListenerMethodInvocation();
}
Aggregations