use of jakarta.jms.ObjectMessage in project spring-framework by spring-projects.
the class MethodJmsListenerEndpointTests method resolveObjectPayload.
@Test
void resolveObjectPayload() throws JMSException {
MessagingMessageListenerAdapter listener = createDefaultInstance(MyBean.class);
MyBean myBean = new MyBean();
myBean.name = "myBean name";
Session session = mock(Session.class);
ObjectMessage message = mock(ObjectMessage.class);
given(message.getObject()).willReturn(myBean);
listener.onMessage(message, session);
assertDefaultListenerMethodInvocation();
}
use of jakarta.jms.ObjectMessage in project spring-framework by spring-projects.
the class MessageListenerAdapterTests method testWithMessageContentsDelegateForObjectMessageWithPlainObject.
@Test
void testWithMessageContentsDelegateForObjectMessageWithPlainObject() throws Exception {
ObjectMessage objectMessage = mock(ObjectMessage.class);
given(objectMessage.getObject()).willReturn(OBJECT);
MessageContentsDelegate delegate = mock(MessageContentsDelegate.class);
MessageListenerAdapter adapter = new MessageListenerAdapter(delegate);
adapter.onMessage(objectMessage);
verify(delegate).handleMessage(OBJECT);
}
use of jakarta.jms.ObjectMessage in project spring-framework by spring-projects.
the class MessageListenerAdapterTests method testWithMessageContentsDelegateForObjectMessage.
@Test
void testWithMessageContentsDelegateForObjectMessage() throws Exception {
ObjectMessage objectMessage = mock(ObjectMessage.class);
given(objectMessage.getObject()).willReturn(NUMBER);
MessageContentsDelegate delegate = mock(MessageContentsDelegate.class);
MessageListenerAdapter adapter = new MessageListenerAdapter(delegate);
adapter.onMessage(objectMessage);
verify(delegate).handleMessage(NUMBER);
}
use of jakarta.jms.ObjectMessage in project spring-framework by spring-projects.
the class MessagingMessageConverterTests method simpleObject.
@Test
public void simpleObject() throws Exception {
Session session = mock(Session.class);
Serializable payload = mock(Serializable.class);
ObjectMessage jmsMessage = mock(ObjectMessage.class);
given(session.createObjectMessage(payload)).willReturn(jmsMessage);
this.converter.toMessage(MessageBuilder.withPayload(payload).build(), session);
verify(session).createObjectMessage(payload);
}
use of jakarta.jms.ObjectMessage in project spring-framework by spring-projects.
the class SimpleMessageConverterTests method testToMessageSimplyReturnsMessageAsIsIfSuppliedWithMessage.
@Test
public void testToMessageSimplyReturnsMessageAsIsIfSuppliedWithMessage() throws JMSException {
Session session = mock(Session.class);
ObjectMessage message = mock(ObjectMessage.class);
SimpleMessageConverter converter = new SimpleMessageConverter();
Message msg = converter.toMessage(message, session);
assertThat(msg).isSameAs(message);
}
Aggregations