use of org.springframework.jms.listener.adapter.MessagingMessageListenerAdapter in project spring-framework by spring-projects.
the class MethodJmsListenerEndpointTests method resolveMessageAndSession.
@Test
public void resolveMessageAndSession() throws JMSException {
MessagingMessageListenerAdapter listener = createDefaultInstance(javax.jms.Message.class, Session.class);
Session session = mock(Session.class);
listener.onMessage(createSimpleJmsTextMessage("test"), session);
assertDefaultListenerMethodInvocation();
}
use of org.springframework.jms.listener.adapter.MessagingMessageListenerAdapter in project spring-framework by spring-projects.
the class MethodJmsListenerEndpointTests method emptySendTo.
@Test
public 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);
thrown.expect(ReplyFailureException.class);
thrown.expectCause(Matchers.isA(InvalidDestinationException.class));
listener.onMessage(createSimpleJmsTextMessage("content"), session);
}
use of org.springframework.jms.listener.adapter.MessagingMessageListenerAdapter in project spring-framework by spring-projects.
the class MethodJmsListenerEndpointTests method resolveGenericMessage.
@Test
public void resolveGenericMessage() throws JMSException {
MessagingMessageListenerAdapter listener = createDefaultInstance(Message.class);
Session session = mock(Session.class);
listener.onMessage(createSimpleJmsTextMessage("test"), session);
assertDefaultListenerMethodInvocation();
}
use of org.springframework.jms.listener.adapter.MessagingMessageListenerAdapter in project spring-framework by spring-projects.
the class MethodJmsListenerEndpointTests method validatePayloadInvalid.
@Test
public void validatePayloadInvalid() throws JMSException {
DefaultMessageHandlerMethodFactory customFactory = new DefaultMessageHandlerMethodFactory();
customFactory.setValidator(testValidator("invalid value"));
Method method = getListenerMethod("validatePayload", String.class);
MessagingMessageListenerAdapter listener = createInstance(customFactory, method);
Session session = mock(Session.class);
thrown.expect(ListenerExecutionFailedException.class);
// test is an invalid value
listener.onMessage(createSimpleJmsTextMessage("invalid value"), session);
}
use of org.springframework.jms.listener.adapter.MessagingMessageListenerAdapter in project spring-framework by spring-projects.
the class MethodJmsListenerEndpointTests method processAndReply.
@Test
public 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();
}
Aggregations