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; import com.sun.syndication.feed.synd.SyndEntry; public class SoFeedDbTransformer { public SoFeed transformFeed(Message<SyndEntry> message){ SyndEntry entry = message.getPayload(); SoFeed soFeed...