February 2015
Intermediate to advanced
198 pages
4h 17m
English
So far so good, how about handling error scenarios? How to test negative use cases and what to do with the failed test case? The following code snippet will help us in these matters:
@Test(expected = MessageTransformationException.class)
public void errorReportedWhenPayloadIsWrong() {
Message<String> message =
MessageBuilder.withPayload("this should fail").build();
filteredFeedChannel.send(message);
}The input channel expects a message with the payload type SyndEntry, but if a message with a String payload is sent—this must throw an exception. This is what has been tested. This can be further enhanced to monitor certain types of exception on channels with the ability to validate user-defined propagated messages.
Read now
Unlock full access