|
|
@ -39,6 +39,7 @@ import static org.junit.Assert.*; |
|
|
|
* Test fixture for {@link MessageHeaderAccessor}. |
|
|
|
* Test fixture for {@link MessageHeaderAccessor}. |
|
|
|
* |
|
|
|
* |
|
|
|
* @author Rossen Stoyanchev |
|
|
|
* @author Rossen Stoyanchev |
|
|
|
|
|
|
|
* @author Sebastien Deleuze |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public class MessageHeaderAccessorTests { |
|
|
|
public class MessageHeaderAccessorTests { |
|
|
|
|
|
|
|
|
|
|
@ -88,6 +89,58 @@ public class MessageHeaderAccessorTests { |
|
|
|
assertEquals("baz", actual.get("bar")); |
|
|
|
assertEquals("baz", actual.get("bar")); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
|
|
|
public void removeHeaders() { |
|
|
|
|
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
|
|
|
|
map.put("foo", "bar"); |
|
|
|
|
|
|
|
map.put("bar", "baz"); |
|
|
|
|
|
|
|
GenericMessage<String> message = new GenericMessage<>("payload", map); |
|
|
|
|
|
|
|
MessageHeaderAccessor accessor = new MessageHeaderAccessor(message); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
accessor.removeHeaders("fo*"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MessageHeaders actual = accessor.getMessageHeaders(); |
|
|
|
|
|
|
|
assertEquals(2, actual.size()); |
|
|
|
|
|
|
|
assertNull(actual.get("foo")); |
|
|
|
|
|
|
|
assertEquals("baz", actual.get("bar")); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
|
|
|
public void copyHeaders() { |
|
|
|
|
|
|
|
Map<String, Object> map1 = new HashMap<>(); |
|
|
|
|
|
|
|
map1.put("foo", "bar"); |
|
|
|
|
|
|
|
GenericMessage<String> message = new GenericMessage<>("payload", map1); |
|
|
|
|
|
|
|
MessageHeaderAccessor accessor = new MessageHeaderAccessor(message); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> map2 = new HashMap<>(); |
|
|
|
|
|
|
|
map2.put("foo", "BAR"); |
|
|
|
|
|
|
|
map2.put("bar", "baz"); |
|
|
|
|
|
|
|
accessor.copyHeaders(map2); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MessageHeaders actual = accessor.getMessageHeaders(); |
|
|
|
|
|
|
|
assertEquals(3, actual.size()); |
|
|
|
|
|
|
|
assertEquals("BAR", actual.get("foo")); |
|
|
|
|
|
|
|
assertEquals("baz", actual.get("bar")); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
|
|
|
public void copyHeadersIfAbsent() { |
|
|
|
|
|
|
|
Map<String, Object> map1 = new HashMap<>(); |
|
|
|
|
|
|
|
map1.put("foo", "bar"); |
|
|
|
|
|
|
|
GenericMessage<String> message = new GenericMessage<>("payload", map1); |
|
|
|
|
|
|
|
MessageHeaderAccessor accessor = new MessageHeaderAccessor(message); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> map2 = new HashMap<>(); |
|
|
|
|
|
|
|
map2.put("foo", "BAR"); |
|
|
|
|
|
|
|
map2.put("bar", "baz"); |
|
|
|
|
|
|
|
accessor.copyHeadersIfAbsent(map2); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MessageHeaders actual = accessor.getMessageHeaders(); |
|
|
|
|
|
|
|
assertEquals(3, actual.size()); |
|
|
|
|
|
|
|
assertEquals("bar", actual.get("foo")); |
|
|
|
|
|
|
|
assertEquals("baz", actual.get("bar")); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void copyHeadersFromNullMap() { |
|
|
|
public void copyHeadersFromNullMap() { |
|
|
|
MessageHeaderAccessor headers = new MessageHeaderAccessor(); |
|
|
|
MessageHeaderAccessor headers = new MessageHeaderAccessor(); |
|
|
|