Search in sources :

Example 1 with MessagingMessageConverter

use of org.springframework.amqp.support.converter.MessagingMessageConverter in project spring-amqp by spring-projects.

the class RabbitMessagingTemplateTests method verifyConverter.

@Test
public void verifyConverter() {
    RabbitTemplate template = new RabbitTemplate(mock(ConnectionFactory.class));
    RabbitMessagingTemplate rmt = new RabbitMessagingTemplate(template);
    rmt.afterPropertiesSet();
    assertThat(TestUtils.getPropertyValue(rmt, "amqpMessageConverter.payloadConverter")).isSameAs(template.getMessageConverter());
    rmt = new RabbitMessagingTemplate(template);
    MessagingMessageConverter amqpMessageConverter = new MessagingMessageConverter();
    MessageConverter payloadConverter = mock(MessageConverter.class);
    amqpMessageConverter.setPayloadConverter(payloadConverter);
    rmt.setAmqpMessageConverter(amqpMessageConverter);
    rmt.afterPropertiesSet();
    assertThat(TestUtils.getPropertyValue(rmt, "amqpMessageConverter.payloadConverter")).isSameAs(payloadConverter);
}
Also used : ConnectionFactory(org.springframework.amqp.rabbit.connection.ConnectionFactory) MessagingMessageConverter(org.springframework.amqp.support.converter.MessagingMessageConverter) SimpleMessageConverter(org.springframework.amqp.support.converter.SimpleMessageConverter) GenericMessageConverter(org.springframework.messaging.converter.GenericMessageConverter) MessageConverter(org.springframework.amqp.support.converter.MessageConverter) MessagingMessageConverter(org.springframework.amqp.support.converter.MessagingMessageConverter) Test(org.junit.jupiter.api.Test)

Example 2 with MessagingMessageConverter

use of org.springframework.amqp.support.converter.MessagingMessageConverter in project spring-cloud-contract by spring-cloud.

the class ContractVerifierHelper method convert.

@Override
protected ContractVerifierMessage convert(Message message) {
    MessagingMessageConverter messageConverter = new MessagingMessageConverter(this.messageConverter, new SimpleAmqpHeaderMapper());
    org.springframework.messaging.Message<?> messagingMessage;
    messagingMessage = (org.springframework.messaging.Message<?>) messageConverter.fromMessage(message);
    return new ContractVerifierMessage(messagingMessage.getPayload(), messagingMessage.getHeaders());
}
Also used : ContractVerifierMessage(org.springframework.cloud.contract.verifier.messaging.internal.ContractVerifierMessage) SimpleAmqpHeaderMapper(org.springframework.amqp.support.SimpleAmqpHeaderMapper) MessagingMessageConverter(org.springframework.amqp.support.converter.MessagingMessageConverter)

Aggregations

MessagingMessageConverter (org.springframework.amqp.support.converter.MessagingMessageConverter)2 Test (org.junit.jupiter.api.Test)1 ConnectionFactory (org.springframework.amqp.rabbit.connection.ConnectionFactory)1 SimpleAmqpHeaderMapper (org.springframework.amqp.support.SimpleAmqpHeaderMapper)1 MessageConverter (org.springframework.amqp.support.converter.MessageConverter)1 SimpleMessageConverter (org.springframework.amqp.support.converter.SimpleMessageConverter)1 ContractVerifierMessage (org.springframework.cloud.contract.verifier.messaging.internal.ContractVerifierMessage)1 GenericMessageConverter (org.springframework.messaging.converter.GenericMessageConverter)1