use of jakarta.jms.Session 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);
}
use of jakarta.jms.Session in project spring-framework by spring-projects.
the class SimpleMessageConverterTests method testMapConversionWhereMapHasNNullForKey.
@Test
public void testMapConversionWhereMapHasNNullForKey() throws JMSException {
MapMessage message = mock(MapMessage.class);
Session session = mock(Session.class);
given(session.createMapMessage()).willReturn(message);
Map<Object, String> content = new HashMap<>(1);
content.put(null, "value1");
SimpleMessageConverter converter = new SimpleMessageConverter();
assertThatExceptionOfType(MessageConversionException.class).isThrownBy(() -> converter.toMessage(content, session));
}
use of jakarta.jms.Session in project spring-framework by spring-projects.
the class SimpleMessageConverterTests method testMapConversion.
@Test
public void testMapConversion() throws JMSException {
Session session = mock(Session.class);
MapMessage message = mock(MapMessage.class);
Map<String, String> content = new HashMap<>(2);
content.put("key1", "value1");
content.put("key2", "value2");
given(session.createMapMessage()).willReturn(message);
given(message.getMapNames()).willReturn(Collections.enumeration(content.keySet()));
given(message.getObject("key1")).willReturn("value1");
given(message.getObject("key2")).willReturn("value2");
SimpleMessageConverter converter = new SimpleMessageConverter();
Message msg = converter.toMessage(content, session);
assertThat(converter.fromMessage(msg)).isEqualTo(content);
verify(message).setObject("key1", "value1");
verify(message).setObject("key2", "value2");
}
use of jakarta.jms.Session 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);
}
Aggregations