Gangaraju Gangaraju - 1 year ago 233
Java Question

Camel testing - java.lang.IllegalArgumentException: defaultEndpoint must be specified

I am trying to create testcases for my camel route using . I need to verify the the processors in the route. But the simple test is not working for me.

public class CamelRouteTest extends CamelTestSupport {

public String isMockEndpointsAndSkip() {
// override this method and return the pattern for which endpoints to mock,
// and skip sending to the original endpoint.
return "mock:result";

public void verifyMessageCount() throws Exception {

protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
public void configure() throws Exception {


java.lang.IllegalArgumentException: defaultEndpoint must be specified
at org.apache.camel.util.ObjectHelper.notNull(
at org.apache.camel.impl.DefaultProducerTemplate.getMandatoryDefaultEndpoint(
at org.apache.camel.impl.DefaultProducerTemplate.sendBody(

Answer Source

The template.sendBody("Test") try to send Test to the default endpoint. As in your code this is not configured it fails.

You could:

  • specify which endpoint to use

    template.sendBody("direct:start", "Test");
  • get an endpoint from the context and set it as the default endpoint

    Endpoint endpoint = context.getEndpoint("direct:start");
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download