Book Image

Spring Integration Essentials

By : CHANDAN K PANDEY
Book Image

Spring Integration Essentials

By: CHANDAN K PANDEY

Overview of this book

This book is intended for developers who are either already involved with enterprise integration or planning to venture into the domain. Basic knowledge of Java and Spring is expected. For newer users, this book can be used to understand an integration scenario, what the challenges are, and how Spring Integration can be used to solve it. Prior experience of Spring Integration is not expected as this book will walk you through all the code examples.
Table of Contents (12 chapters)
11
Index

Testing headers


As we tested the payload, it's fairly easy to test headers. Let's write a header enricher and then a test case to validate it:

  <int:header-enricher 
    input-channel="filteredFeedChannel" output-channel="transformedChannel">
    <int:header name="testHeaderKey1" value="testHeaderValue1"/>
    <int:header name="testHeaderKey2" value="testHeaderValue2"/>
  </int:header-enricher>

Headers will be added to any message that is put on filteredFeedChannel. The following code snippet is the test to verify whether these headers are added or not:

import static org.junit.Assert.assertThat;
import static org.springframework.integration.test.matcher.HeaderMatcher.hasHeader;
import static org.springframework.integration.test.matcher.HeaderMatcher.hasHeaderKey;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.integration.channel.QueueChannel;
import org.springframework...