O'Reilly logo

Spring Integration Essentials by Chandan Pandey

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required