Hi, I just ran your code with Camel 2.20.0 and it works without issues, but I can reproduce the problem with earlier releases such as 2.19.x and 2.18.x.
Were there any particular changes in Camel 2.20.0 that would make Minhtri's code work? Please note that the test code works in all versions of Camel when stream caching is disabled in the route. Thanks, Gregor On Fri, Nov 10, 2017 at 7:12 PM, Minhtri Tran <mtran7...@gmail.com> wrote: > Hello, > > I am currently having an issue with setting up multiple expectations > in a test case when streamCaching is enabled and json marshalling is > used. Every expectation except the first one fails. > > Here’s my test class: > > @RunWith(CamelSpringBootRunner.class) > > @SpringBootTest(classes = MyApplication.class) > > public class MyTest extends CamelTestSupport { > > > > @Test > > public void test() throws Exception { > > class Hello { > > Hello(String value) { > > this.value = value; > > } > > > > private String value; > > > > public String getValue() { > > return value; > > } > > > > public void setValue(String value) { > > this.value = value; > > } > > } > > > > MockEndpoint mock = getMockEndpoint("mock:dest"); > > mock.message(0).body().convertToString().contains("hello"); > > mock.message(0).body().convertToString().contains("world"); > > template.sendBody("direct:source", new Hello("hello world")); > > mock.assertIsSatisfied(); } > > > > @Override > > protected RoutesBuilder createRouteBuilder() throws Exception { > > return new RouteBuilder() { > > @Override > > public void configure() throws Exception { > > from("direct:source") > > .streamCaching() > > .marshal().json(JsonLibrary.Jackson) > > .to("mock:dest"); > > } > > }; > > } > > } > > > > This is the assertion error that I’m getting: > > java.lang.AssertionError: Assertion error at index 0 on mock > mock://dest with predicate: Simple: body contains world evaluated as: > contains world on Exchange[ID-A1504214-60132-1508506055845-1-2] > > > > Why is this happening? How can I set multiple expectations on the > same message body in this case? > > > > Thanks, > > Minhtri