Search in sources :

Example 6 with ObjectMessage

use of jakarta.jms.ObjectMessage in project spring-framework by spring-projects.

the class SimpleMessageConverterTests method testSerializableConversion.

@Test
public void testSerializableConversion() throws JMSException {
    Session session = mock(Session.class);
    ObjectMessage message = mock(ObjectMessage.class);
    Integer content = 5;
    given(session.createObjectMessage(content)).willReturn(message);
    given(message.getObject()).willReturn(content);
    SimpleMessageConverter converter = new SimpleMessageConverter();
    Message msg = converter.toMessage(content, session);
    assertThat(converter.fromMessage(msg)).isEqualTo(content);
}
Also used : Message(jakarta.jms.Message) BytesMessage(jakarta.jms.BytesMessage) TextMessage(jakarta.jms.TextMessage) MapMessage(jakarta.jms.MapMessage) ObjectMessage(jakarta.jms.ObjectMessage) ObjectMessage(jakarta.jms.ObjectMessage) SimpleMessageConverter(org.springframework.jms.support.converter.SimpleMessageConverter) Session(jakarta.jms.Session) Test(org.junit.jupiter.api.Test)

Aggregations

ObjectMessage (jakarta.jms.ObjectMessage)6 Test (org.junit.jupiter.api.Test)6 Session (jakarta.jms.Session)4 BytesMessage (jakarta.jms.BytesMessage)2 MapMessage (jakarta.jms.MapMessage)2 Message (jakarta.jms.Message)2 TextMessage (jakarta.jms.TextMessage)2 SimpleMessageConverter (org.springframework.jms.support.converter.SimpleMessageConverter)2 Serializable (java.io.Serializable)1 MessagingMessageListenerAdapter (org.springframework.jms.listener.adapter.MessagingMessageListenerAdapter)1