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

Reply via email to