Class HeaderMatcher<T>
java.lang.Object
org.hamcrest.BaseMatcher<T>
org.hamcrest.TypeSafeMatcher<Message<T>>
org.springframework.integration.test.matcher.HeaderMatcher<T>
- All Implemented Interfaces:
org.hamcrest.Matcher<Message<T>>
,org.hamcrest.SelfDescribing
public final class HeaderMatcher<T> extends org.hamcrest.TypeSafeMatcher<Message<T>>
Are the
MessageHeaders
of a Message
containing any entry
or multiple that match?
For example using Assert.assertThat(Object, Matcher)
for a single
entry:
ANY_HEADER_KEY = "foo";
ANY_HEADER_VALUE = "bar";
assertThat(message, hasEntry(ANY_HEADER_KEY, ANY_HEADER_VALUE));
assertThat(message, hasEntry(ANY_HEADER_KEY, is(String.class)));
assertThat(message, hasEntry(ANY_HEADER_KEY, notNullValue()));
assertThat(message, hasEntry(ANY_HEADER_KEY, is(ANY_HEADER_VALUE)));
For multiple entries to match all:
Map<String, Object> expectedInHeaderMap = new HashMap<String, Object>();
expectedInHeaderMap.put(ANY_HEADER_KEY, ANY_HEADER_VALUE);
expectedInHeaderMap.put(OTHER_HEADER_KEY, is(OTHER_HEADER_VALUE));
assertThat(message, HeaderMatcher.hasAllEntries(expectedInHeaderMap));
For a single key:
ANY_HEADER_KEY = "foo"; assertThat(message, HeaderMatcher.hasKey(ANY_HEADER_KEY));
- Author:
- Alex Peters, Iwein Fuld, Artem Bilan, Gary Russell
-
Method Summary
Modifier and Type Method Description void
describeTo(org.hamcrest.Description description)
static <P> HeaderMatcher<P>
hasAllHeaders(Map<String,?> entries)
static <P, V> HeaderMatcher<P>
hasCorrelationId(V value)
static <P> HeaderMatcher<P>
hasExpirationDate(Date value)
static <P> HeaderMatcher<P>
hasExpirationDate(org.hamcrest.Matcher<Long> matcher)
static <P, V> HeaderMatcher<P>
hasHeader(String key, org.hamcrest.Matcher<V> valueMatcher)
static <P, V> HeaderMatcher<P>
hasHeader(String key, V value)
static <P> HeaderMatcher<P>
hasHeaderKey(String key)
static <P, V> HeaderMatcher<P>
hasMessageId(V value)
static <P> HeaderMatcher<P>
hasSequenceNumber(Integer value)
static <P> HeaderMatcher<P>
hasSequenceNumber(org.hamcrest.Matcher<Integer> matcher)
static <P> HeaderMatcher<P>
hasSequenceSize(Integer value)
static <P> HeaderMatcher<P>
hasSequenceSize(org.hamcrest.Matcher<Integer> value)
static <P> HeaderMatcher<P>
hasTimestamp(Date value)
static <P> HeaderMatcher<P>
hasTimestamp(org.hamcrest.Matcher<Long> matcher)
boolean
matchesSafely(Message<T> item)
Methods inherited from class org.hamcrest.TypeSafeMatcher
describeMismatch, describeMismatchSafely, matches
-
Method Details
-
matchesSafely
-
describeTo
public void describeTo(org.hamcrest.Description description) -
hasHeader
-
hasHeader
-
hasHeaderKey
-
hasAllHeaders
-
hasMessageId
-
hasCorrelationId
-
hasSequenceNumber
-
hasSequenceNumber
-
hasSequenceSize
-
hasSequenceSize
-
hasExpirationDate
-
hasExpirationDate
-
hasTimestamp
-
hasTimestamp
-