Skip to content

Commit

Permalink
Test preserve headers type (#19)
Browse files Browse the repository at this point in the history
Signed-off-by: Pavol Loffay <ploffay@redhat.com>
  • Loading branch information
pavolloffay authored Nov 1, 2018
1 parent 1d1e033 commit 8b10a26
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.util.AbstractMap;
import java.util.HashMap;
import java.util.Map;
import org.junit.Assert;
import org.junit.Test;
import org.springframework.integration.support.MutableMessageHeaders;
import org.springframework.messaging.Message;
Expand Down Expand Up @@ -79,4 +80,21 @@ public void shouldPreserveTimestampAndId() {
assertThat(copiedMessage.getHeaders()).contains(new AbstractMap.SimpleEntry<>("id", "1"));
}

@Test
public void testPreserveType() {
MutableMessageHeaders headers = new MutableMessageHeaders(new HashMap<>());
headers.put("int", new Integer(1));
headers.put("double", new Double(2.2));
headers.put("string", "foo");

MessageTextMap<String> textmap = new MessageTextMap<>(MessageBuilder.createMessage("test", headers));
textmap.iterator();
textmap.put("bar", "baz");

Message<String> message = textmap.getMessage();
Assert.assertEquals(new Double(2.2), message.getHeaders().get("double"));
Assert.assertEquals(new Integer(1), message.getHeaders().get("int"));
Assert.assertEquals("foo", message.getHeaders().get("string"));
Assert.assertEquals("baz", message.getHeaders().get("bar"));
}
}

0 comments on commit 8b10a26

Please sign in to comment.