Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Method

Description

mockEndpoints

Is used to easily mock all endpoints. See more details and examples at Mock.

mockEndpoints(pattern)

Is used to easily mock endpoints using a pattern. See more details and examples at Mock. See below for pattern matching.

weaveById(pattern)

Is used to select node(s) matching by id's, and weave in the following nodes. See below for pattern matching and examples.

weaveByToString(pattern)

Is used to select nodes(s) matching by their toString representation, and weave in the following nodes. See below for pattern matching and examples.

weaveByType(Class)

Camel 2.8: Is used to select node(s) matching by their class type (the classes from the org.apache.camel.model package), and weave in the following nodes. See below for examples.

weaveAddFirst

Camel 2.8: Is a short hand to easily weave in the following nodes in the start of the route.

weaveAddLast

Camel 2.8: Is a short hand to easily weave in the following nodes in the end of the route.

replaceFrom(uri)

Camel 2.9: To replace the route input to a new endpoint uri.

The pattern option is used for matching. It uses the same rules as the Intercept, which is applied in the following order:

...

Code Block
context.getRouteDefinitions().get(0).adviceWith(context, new AdviceWithRouteBuilder() {
    @Override
    public void configure() throws Exception {
        weaveAddFirst().to("mock:input");
        weaveAddLast().to("mock:output");
    }
});

Replace from

Available as of Camel 2.9

You may have routes which consumes messages from endpoints which you want to substitute with another endpoint for easier unit testing. For example a JMS endpoint could be replaced with a SEDA or Direct for unit testing a route, as shown below where we replace the input of the route to a "seda:foo" endpoint:

Code Block

context.getRouteDefinitions().get(0).adviceWith(context, new AdviceWithRouteBuilder() {
    @Override
    public void configure() throws Exception {
        replaceFrom("seda:foo");
    }
});