Below is builder from camel core & writting junit testcases with it & camel core version used is 2.22.1.
new ExchangeBuilder(null)
.withBody(body)
.withHeader(header, headerValue)
.build();
Junit testcases is throwing error when calling above builder - java.lang.IllegalArgumentException: CamelContext must be specified on: Message[]
You'll have to provide constructor of
ExchangeBuilder
a instance of CamelContext. If your test class inherits from CamelTestBuilder you can usecontext()
method to obtain it during a test.If you're not using one of the camel-test modules you'll have to create and configure one manually using e.g
new DefaultCamelContext();
. For testing routes use of one of the camel-test modules is highly recommended though as they make things a lot easier.