Testing messages

Spring Integration provides a class that can help to build certain payloads such as the following example:

Message<String> message = MessageBuilder.withPayload("Test").build()

These messages can be put on the channel by grabbing the handle of an actual channel definition. This can be used for negative as well as positive testing. For example, if a service activator listening on the channel expects a message with the payload type File, then putting a message with a payload String should indicate an error. Let's write a quick test for our transformer, which accepts Message with the payload SyndEntry and converts it to SoFeed. The following code snippet is our transformer class:

import org.springframework.messaging.Message; import com.cpandey.siexample.pojo.SoFeed; ...

Get Spring Integration Essentials now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.