use of org.springframework.messaging.converter.GenericMessageConverter in project spring-framework by spring-projects.
the class JmsMessagingTemplateTests method receiveAndConvertWithConversion.
@Test
public void receiveAndConvertWithConversion() {
javax.jms.Message jmsMessage = createJmsTextMessage("123");
given(jmsTemplate.receive("myQueue")).willReturn(jmsMessage);
messagingTemplate.setMessageConverter(new GenericMessageConverter());
Integer payload = messagingTemplate.receiveAndConvert("myQueue", Integer.class);
assertEquals(Integer.valueOf(123), payload);
verify(jmsTemplate).receive("myQueue");
}
use of org.springframework.messaging.converter.GenericMessageConverter in project spring-framework by spring-projects.
the class MessageReceivingTemplateTests method receiveAndConvertNoConverter.
@Test
public void receiveAndConvertNoConverter() {
Message<?> expected = new GenericMessage<Object>("payload");
this.template.setDefaultDestination("home");
this.template.setReceiveMessage(expected);
this.template.setMessageConverter(new GenericMessageConverter());
try {
this.template.receiveAndConvert(Writer.class);
} catch (MessageConversionException ex) {
assertTrue("Invalid exception message '" + ex.getMessage() + "'", ex.getMessage().contains("payload"));
assertSame(expected, ex.getFailedMessage());
}
}
use of org.springframework.messaging.converter.GenericMessageConverter in project spring-framework by spring-projects.
the class MessageReceivingTemplateTests method receiveAndConvertFailed.
@Test
public void receiveAndConvertFailed() {
Message<?> expected = new GenericMessage<Object>("not a number test");
this.template.setReceiveMessage(expected);
this.template.setMessageConverter(new GenericMessageConverter());
thrown.expect(MessageConversionException.class);
thrown.expectCause(isA(ConversionFailedException.class));
this.template.receiveAndConvert("somewhere", Integer.class);
}
Aggregations