From 5e4f9fca2cba72e0dee4227090ca6b1741a8947d Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Tue, 31 Mar 2015 21:36:52 +0300 Subject: [PATCH] INT-3690: AMQP Content-Type Mapping for MimeType JIRA: https://jira.spring.io/browse/INT-3690 **Cherry-pick to 4.0.x and 4.1.x** --- .../amqp/support/DefaultAmqpHeaderMapper.java | 6 ++++-- .../support/DefaultAmqpHeaderMapperTests.java | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/spring-integration-amqp/src/main/java/org/springframework/integration/amqp/support/DefaultAmqpHeaderMapper.java b/spring-integration-amqp/src/main/java/org/springframework/integration/amqp/support/DefaultAmqpHeaderMapper.java index fb3bd2b6c7..4c62abe477 100644 --- a/spring-integration-amqp/src/main/java/org/springframework/integration/amqp/support/DefaultAmqpHeaderMapper.java +++ b/spring-integration-amqp/src/main/java/org/springframework/integration/amqp/support/DefaultAmqpHeaderMapper.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,6 +30,7 @@ import org.springframework.amqp.support.AmqpHeaders; import org.springframework.integration.IntegrationMessageHeaderAccessor; import org.springframework.integration.mapping.AbstractHeaderMapper; import org.springframework.integration.mapping.support.JsonHeaders; +import org.springframework.util.MimeType; import org.springframework.util.ReflectionUtils; import org.springframework.util.ReflectionUtils.FieldCallback; import org.springframework.util.ReflectionUtils.FieldFilter; @@ -359,7 +360,8 @@ public class DefaultAmqpHeaderMapper extends AbstractHeaderMapper headerMap = new HashMap(); + + MimeType contentType = MimeType.valueOf("text/html"); + headerMap.put(AmqpHeaders.CONTENT_TYPE, contentType); + + MessageHeaders integrationHeaders = new MessageHeaders(headerMap); + MessageProperties amqpProperties = new MessageProperties(); + headerMapper.fromHeadersToRequest(integrationHeaders, amqpProperties); + + assertEquals("text/html", amqpProperties.getContentType()); + } + + @Test public void toHeaders() { DefaultAmqpHeaderMapper headerMapper = new DefaultAmqpHeaderMapper();