Search in sources :

Example 6 with Jackson2JsonMessageConverter

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

the class DefaultAmqpHeaderMapperTests method jsonTypeIdNotOverwritten.

// INT-2090
@Test
public void jsonTypeIdNotOverwritten() {
    DefaultAmqpHeaderMapper headerMapper = DefaultAmqpHeaderMapper.inboundMapper();
    MessageConverter converter = new Jackson2JsonMessageConverter();
    MessageProperties amqpProperties = new MessageProperties();
    converter.toMessage("123", amqpProperties);
    Map<String, Object> headerMap = new HashMap<String, Object>();
    headerMap.put("__TypeId__", "java.lang.Integer");
    MessageHeaders integrationHeaders = new MessageHeaders(headerMap);
    headerMapper.fromHeadersToRequest(integrationHeaders, amqpProperties);
    assertEquals("java.lang.String", amqpProperties.getHeaders().get("__TypeId__"));
    Object result = converter.fromMessage(new Message("123".getBytes(), amqpProperties));
    assertEquals(String.class, result.getClass());
}
Also used : Message(org.springframework.amqp.core.Message) MessageProperties(org.springframework.amqp.core.MessageProperties) HashMap(java.util.HashMap) MessageHeaders(org.springframework.messaging.MessageHeaders) Jackson2JsonMessageConverter(org.springframework.amqp.support.converter.Jackson2JsonMessageConverter) MessageConverter(org.springframework.amqp.support.converter.MessageConverter) Jackson2JsonMessageConverter(org.springframework.amqp.support.converter.Jackson2JsonMessageConverter) Test(org.junit.Test)

Aggregations

Jackson2JsonMessageConverter (org.springframework.amqp.support.converter.Jackson2JsonMessageConverter)6 Test (org.junit.Test)4 MessageProperties (org.springframework.amqp.core.MessageProperties)4 Channel (com.rabbitmq.client.Channel)3 Connection (org.springframework.amqp.rabbit.connection.Connection)3 ConnectionFactory (org.springframework.amqp.rabbit.connection.ConnectionFactory)3 SimpleMessageListenerContainer (org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer)3 ChannelAwareMessageListener (org.springframework.amqp.rabbit.listener.api.ChannelAwareMessageListener)3 BeanFactory (org.springframework.beans.factory.BeanFactory)3 DirectChannel (org.springframework.integration.channel.DirectChannel)3 QueueChannel (org.springframework.integration.channel.QueueChannel)3 JsonToObjectTransformer (org.springframework.integration.json.JsonToObjectTransformer)3 PollableChannel (org.springframework.messaging.PollableChannel)3 MessageConverter (org.springframework.amqp.support.converter.MessageConverter)2 SimpleMessageConverter (org.springframework.amqp.support.converter.SimpleMessageConverter)2 ObjectToJsonTransformer (org.springframework.integration.json.ObjectToJsonTransformer)2 Transformer (org.springframework.integration.transformer.Transformer)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1