use of org.springframework.jms.StubTextMessage in project spring-framework by spring-projects.
the class AbstractJmsAnnotationDrivenTests method testJmsHandlerMethodFactoryConfiguration.
/**
* Test for {@link ValidationBean} with a validator ({@link TestValidator}) specified
* in a custom {@link org.springframework.messaging.handler.annotation.support.MessageHandlerMethodFactory}.
*
* The test should throw a {@link org.springframework.jms.listener.adapter.ListenerExecutionFailedException}
*/
protected void testJmsHandlerMethodFactoryConfiguration(ApplicationContext context) throws JMSException {
JmsListenerContainerTestFactory simpleFactory = context.getBean("defaultFactory", JmsListenerContainerTestFactory.class);
assertThat(simpleFactory.getListenerContainers().size()).isEqualTo(1);
MethodJmsListenerEndpoint endpoint = (MethodJmsListenerEndpoint) simpleFactory.getListenerContainers().get(0).getEndpoint();
SimpleMessageListenerContainer container = new SimpleMessageListenerContainer();
endpoint.setupListenerContainer(container);
MessagingMessageListenerAdapter listener = (MessagingMessageListenerAdapter) container.getMessageListener();
listener.onMessage(new StubTextMessage("failValidation"), mock(Session.class));
}
use of org.springframework.jms.StubTextMessage in project spring-framework by spring-projects.
the class JmsListenerContainerFactoryIntegrationTests method testMessageConverterIsUsed.
private void testMessageConverterIsUsed() throws JMSException {
MethodJmsListenerEndpoint endpoint = createDefaultMethodJmsEndpoint(this.listener.getClass(), "handleIt", String.class, String.class);
Message message = new StubTextMessage("foo-bar");
message.setStringProperty("my-header", "my-value");
invokeListener(endpoint, message);
assertListenerMethodInvocation("handleIt");
}
use of org.springframework.jms.StubTextMessage in project spring-framework by spring-projects.
the class MessagingMessageListenerAdapterTests method buildMessageWithStandardMessage.
@Test
public void buildMessageWithStandardMessage() throws JMSException {
Destination replyTo = new Destination() {
};
Message<String> result = MessageBuilder.withPayload("Response").setHeader("foo", "bar").setHeader(JmsHeaders.TYPE, "msg_type").setHeader(JmsHeaders.REPLY_TO, replyTo).build();
Session session = mock(Session.class);
given(session.createTextMessage("Response")).willReturn(new StubTextMessage("Response"));
MessagingMessageListenerAdapter listener = getSimpleInstance("echo", Message.class);
jakarta.jms.Message replyMessage = listener.buildMessage(session, result);
verify(session).createTextMessage("Response");
assertThat(replyMessage).as("reply should never be null").isNotNull();
assertThat(((TextMessage) replyMessage).getText()).isEqualTo("Response");
assertThat(replyMessage.getStringProperty("foo")).as("custom header not copied").isEqualTo("bar");
assertThat(replyMessage.getJMSType()).as("type header not copied").isEqualTo("msg_type");
assertThat(replyMessage.getJMSReplyTo()).as("replyTo header not copied").isEqualTo(replyTo);
}
use of org.springframework.jms.StubTextMessage in project spring-framework by spring-projects.
the class SimpleJmsHeaderMapperTests method jmsReplyToMappedToHeader.
@Test
public void jmsReplyToMappedToHeader() throws JMSException {
Destination replyTo = new Destination() {
};
jakarta.jms.Message jmsMessage = new StubTextMessage();
jmsMessage.setJMSReplyTo(replyTo);
assertInboundHeader(jmsMessage, JmsHeaders.REPLY_TO, replyTo);
}
use of org.springframework.jms.StubTextMessage in project spring-framework by spring-projects.
the class SimpleJmsHeaderMapperTests method destinationMappedToHeader.
@Test
public void destinationMappedToHeader() throws JMSException {
Destination destination = new Destination() {
};
jakarta.jms.Message jmsMessage = new StubTextMessage();
jmsMessage.setJMSDestination(destination);
assertInboundHeader(jmsMessage, JmsHeaders.DESTINATION, destination);
}
Aggregations