use of org.springframework.jms.listener.adapter.MessagingMessageListenerAdapter in project spring-framework by spring-projects.
the class MethodJmsListenerEndpointTests method setExtraCollaborators.
@Test
void setExtraCollaborators() {
MessageConverter messageConverter = mock(MessageConverter.class);
DestinationResolver destinationResolver = mock(DestinationResolver.class);
this.container.setMessageConverter(messageConverter);
this.container.setDestinationResolver(destinationResolver);
MessagingMessageListenerAdapter listener = createInstance(this.factory, getListenerMethod("resolveObjectPayload", MyBean.class), this.container);
DirectFieldAccessor accessor = new DirectFieldAccessor(listener);
assertThat(accessor.getPropertyValue("messageConverter")).isSameAs(messageConverter);
assertThat(accessor.getPropertyValue("destinationResolver")).isSameAs(destinationResolver);
}
use of org.springframework.jms.listener.adapter.MessagingMessageListenerAdapter in project spring-framework by spring-projects.
the class MethodJmsListenerEndpointTests method resolveMessageAndSession.
@Test
void resolveMessageAndSession() throws JMSException {
MessagingMessageListenerAdapter listener = createDefaultInstance(jakarta.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 invalidMessagePayloadType.
@Test
void invalidMessagePayloadType() throws JMSException {
MessagingMessageListenerAdapter listener = createDefaultInstance(Message.class);
Session session = mock(Session.class);
// Message<String> as Message<Integer>
assertThatExceptionOfType(ListenerExecutionFailedException.class).isThrownBy(() -> listener.onMessage(createSimpleJmsTextMessage("test"), session)).withCauseInstanceOf(MessageConversionException.class);
}
use of org.springframework.jms.listener.adapter.MessagingMessageListenerAdapter in project spring-framework by spring-projects.
the class MethodJmsListenerEndpointTests method processFromTopicAndReplyWithSendToQueue.
@Test
void processFromTopicAndReplyWithSendToQueue() throws JMSException {
String methodName = "processAndReplyWithSendTo";
SimpleMessageListenerContainer container = new SimpleMessageListenerContainer();
container.setPubSubDomain(true);
container.setReplyPubSubDomain(false);
MessagingMessageListenerAdapter listener = createInstance(this.factory, getListenerMethod(methodName, String.class), container);
processAndReplyWithSendTo(listener, "replyDestination", false);
assertListenerMethodInvocation(this.sample, methodName);
}
use of org.springframework.jms.listener.adapter.MessagingMessageListenerAdapter in project spring-framework by spring-projects.
the class MethodJmsListenerEndpointTests method processFromQueueAndReplyWithSendToTopic.
@Test
void processFromQueueAndReplyWithSendToTopic() throws JMSException {
String methodName = "processAndReplyWithSendTo";
SimpleMessageListenerContainer container = new SimpleMessageListenerContainer();
container.setReplyPubSubDomain(true);
MessagingMessageListenerAdapter listener = createInstance(this.factory, getListenerMethod(methodName, String.class), container);
processAndReplyWithSendTo(listener, "replyDestination", true);
assertListenerMethodInvocation(this.sample, methodName);
}
Aggregations