use of javax.jms.TextMessage in project spring-framework by spring-projects.
the class SimpleMessageConverterTests method testStringConversion.
@Test
public void testStringConversion() throws JMSException {
Session session = mock(Session.class);
TextMessage message = mock(TextMessage.class);
String content = "test";
given(session.createTextMessage(content)).willReturn(message);
given(message.getText()).willReturn(content);
SimpleMessageConverter converter = new SimpleMessageConverter();
Message msg = converter.toMessage(content, session);
assertEquals(content, converter.fromMessage(msg));
}
use of javax.jms.TextMessage in project spring-framework by spring-projects.
the class MappingJackson2MessageConverterTests method toTextMessageWithAnotherJsonViewClass.
@Test
public void toTextMessageWithAnotherJsonViewClass() throws JMSException {
converter.setTargetType(MessageType.TEXT);
TextMessage textMessageMock = mock(TextMessage.class);
MyAnotherBean bean = new MyAnotherBean("test", "lengthy description");
given(sessionMock.createTextMessage(isA(String.class))).willReturn(textMessageMock);
converter.toMessage(bean, sessionMock, Full.class);
verify(textMessageMock).setStringProperty("__typeid__", MyAnotherBean.class.getName());
verify(sessionMock).createTextMessage("{\"name\":\"test\",\"description\":\"lengthy description\"}");
}
use of javax.jms.TextMessage in project spring-framework by spring-projects.
the class MappingJackson2MessageConverterTests method toTextMessageWithObject.
@Test
public void toTextMessageWithObject() throws Exception {
converter.setTargetType(MessageType.TEXT);
TextMessage textMessageMock = mock(TextMessage.class);
Date toBeMarshalled = new Date();
given(sessionMock.createTextMessage(isA(String.class))).willReturn(textMessageMock);
converter.toMessage(toBeMarshalled, sessionMock);
verify(textMessageMock).setStringProperty("__typeid__", Date.class.getName());
}
use of javax.jms.TextMessage in project spring-framework by spring-projects.
the class MappingJackson2MessageConverterTests method fromTextMessageAsMap.
@Test
public void fromTextMessageAsMap() throws Exception {
TextMessage textMessageMock = mock(TextMessage.class);
Map<String, String> unmarshalled = Collections.singletonMap("foo", "bar");
String text = "{\"foo\":\"bar\"}";
given(textMessageMock.getStringProperty("__typeid__")).willReturn(HashMap.class.getName());
given(textMessageMock.getText()).willReturn(text);
Object result = converter.fromMessage(textMessageMock);
assertEquals("Invalid result", result, unmarshalled);
}
use of javax.jms.TextMessage in project spring-framework by spring-projects.
the class MappingJackson2MessageConverterTests method toTextMessageWithJsonViewClass.
@Test
public void toTextMessageWithJsonViewClass() throws JMSException {
converter.setTargetType(MessageType.TEXT);
TextMessage textMessageMock = mock(TextMessage.class);
MyAnotherBean bean = new MyAnotherBean("test", "lengthy description");
given(sessionMock.createTextMessage(isA(String.class))).willReturn(textMessageMock);
converter.toMessage(bean, sessionMock, Summary.class);
verify(textMessageMock).setStringProperty("__typeid__", MyAnotherBean.class.getName());
verify(sessionMock).createTextMessage("{\"name\":\"test\"}");
}
Aggregations