Skip to content

Commit 8b10a26

Browse files
authored
Test preserve headers type (#19)
Signed-off-by: Pavol Loffay <[email protected]>
1 parent 1d1e033 commit 8b10a26

File tree

1 file changed

+18
-0
lines changed
  • opentracing-spring-messaging/src/test/java/io/opentracing/contrib/spring/integration/messaging

1 file changed

+18
-0
lines changed

opentracing-spring-messaging/src/test/java/io/opentracing/contrib/spring/integration/messaging/MessageTextMapTest.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import java.util.AbstractMap;
2020
import java.util.HashMap;
2121
import java.util.Map;
22+
import org.junit.Assert;
2223
import org.junit.Test;
2324
import org.springframework.integration.support.MutableMessageHeaders;
2425
import org.springframework.messaging.Message;
@@ -79,4 +80,21 @@ public void shouldPreserveTimestampAndId() {
7980
assertThat(copiedMessage.getHeaders()).contains(new AbstractMap.SimpleEntry<>("id", "1"));
8081
}
8182

83+
@Test
84+
public void testPreserveType() {
85+
MutableMessageHeaders headers = new MutableMessageHeaders(new HashMap<>());
86+
headers.put("int", new Integer(1));
87+
headers.put("double", new Double(2.2));
88+
headers.put("string", "foo");
89+
90+
MessageTextMap<String> textmap = new MessageTextMap<>(MessageBuilder.createMessage("test", headers));
91+
textmap.iterator();
92+
textmap.put("bar", "baz");
93+
94+
Message<String> message = textmap.getMessage();
95+
Assert.assertEquals(new Double(2.2), message.getHeaders().get("double"));
96+
Assert.assertEquals(new Integer(1), message.getHeaders().get("int"));
97+
Assert.assertEquals("foo", message.getHeaders().get("string"));
98+
Assert.assertEquals("baz", message.getHeaders().get("bar"));
99+
}
82100
}

0 commit comments

Comments
 (0)