SimpleMessageTextCreator implements MessageCreator { @Override public Message createMessage(Session session) throws JMSException { Message jmsMessage = messageConverter.toMessage(message.getText(), session); for (Entry<String, String> e : message.getProps().entrySet()) { jmsMessage.setStringProperty(e.getKey(), e.getValue()); } return jmsMessage; } SimpleMessageTextCreator(SimpleMessage message); @Override Message createMessage(Session session);  }
@SuppressWarnings("unchecked") @Test public void convertTextMessageWithoutUserProperties() throws JMSException { SimpleMessage m = new SimpleMessage("test", "queue1"); SimpleMessageTextCreator sut = new SimpleMessageTextCreator(m); TextMessage result = (TextMessage) sut.createMessage(mockSession); assertThat(result.getText()).isEqualTo("test"); assertThat(Collections.list(result.getPropertyNames())).isEmpty(); }
@SuppressWarnings("unchecked") @Test public void convertTextMessageWithUserProperties() throws JMSException { Map<String, String> props = new HashMap<>(); props.put("mykey1", "myval1"); props.put("mykey2", "myval2"); SimpleMessage m = new SimpleMessage("test", "queue1", props); SimpleMessageTextCreator sut = new SimpleMessageTextCreator(m); TextMessage result = (TextMessage) sut.createMessage(mockSession); assertThat(result.getText()).isEqualTo("test"); assertThat(result.getStringProperty("mykey1")).isEqualTo("myval1"); assertThat(result.getStringProperty("mykey2")).isEqualTo("myval2"); assertThat(Collections.list(result.getPropertyNames())).hasSize(2); }