Versions Compared

Key

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

...

Method

Description

from(endpointUri)

Matches only when Exchanges are incoming from that particular endpoint. The endpointUri can be a pattern, which is the same pattern matching used by Intercept.

fromRoute(routeId)

Camel 2.4: Matches only when Exchanges are incoming from that particular route. The routeId can be a pattern, which is the same pattern matching used by Intercept.

filter(predicate)

Filters out unwanted Exchanges (only messages passing (true) the predicate is used).

wereSentTo(endpointUri)

Camel 2.9: Matches only when Exchanges has at any point been sent to the given endpoint. The endpointUri can be a pattern, which is the same pattern matching used by Intercept.

whenReceived(number)

Matches when X number or more messages has been received.

whenDone(number)

Matches when X number or more messages is done.

whenDoneByIndex(index)

Camel 2.8: Matches when the n'th (index) message is done.

whenComplete(number)

Matches when X number or more messages is complete.

whenFailed(number)

Matches when X number or more messages is failed.

whenExactlyDone(number)

Matches when exactly X number of messages is done.

whenExactlyComplete(number)

Matches when exactly X number of messages is complete.

whenExactlyFailed(number)

Matches when exactly X number of messages is failed.

whenBodiesReceived(bodies)

Matches when the message bodies has been received in the same order. This method is non strict which means that it will disregard any additional received messages.

whenExactBodiesReceived(bodies)

Matches when the message bodies has been received in the same order. This method is strict which means the exact number of message bodies is expected.

whenBodiesDone(bodies)

Matches when the message bodies are done in the same order. This method is non strict which means that it will disregard any additional done messages.

whenExactBodiesDone(bodies)

Matches when the message bodies are done in the same order. This method is strict which means the exact number of message bodies is expected.

whenAnyReceivedMatches(predicate)

Matches if any one of the received messages matched the Predicate.

whenAllReceivedMatches(predicate)

Matches only when all of the received messages matched the Predicate.

whenAnyDoneMatches(predicate)

Matches if any one of the done messages matched the Predicate.

whenAllDoneMatches(predicate)

Matches only when all of the done messages matched the Predicate.

whenReceivedSatisfied(mock)

Matches if the Mock is satisfied for received messages. Is used for fine grained matching by setting the expectations on the Mock which already have a great library for doing so.

whenReceivedNotSatisfied(mock)

Matches if the Mock is not satisfied for received messages. Is used for fine grained matching by setting the expectations on the Mock which already have a great library for doing so.

whenDoneSatisfied(mock)

Matches if the Mock is satisfied for messages done. Is used for fine grained matching by setting the expectations on the Mock which already have a great library for doing so.

whenDoneNotSatisfied(mock)

Matches if the Mock is not satisfied for messages done. Is used for fine grained matching by setting the expectations on the Mock which already have a great library for doing so.

and

Appends an additional expressions using the and operator.

or

Appends an additional expressions using the or operator.

not

Appends an additional expressions using the not operator.

...

You can combine multiple expressions as much as you like. However we suggest to use the mock for fine grained expectations that you may already know how to use.

You can also specify that the Exchanges must have been sent to a given endpoint. For example in the following we expect the message to be sent to mock:bar

Code Block

        NotifyBuilder notify = new NotifyBuilder(context)
                .wereSentTo("mock:bar")
                .create();

You can combine this with any of the other expectations, such as, to only match if 3+ messages are done, and were sent to the mock:bar endpoint:

Code Block

        NotifyBuilder notify = new NotifyBuilder(context)
                .whenDone(3).wereSentTo("mock:bar")
                .create();

You can add additional {{wereSentTo}}s, such as the following two:

Code Block

        NotifyBuilder notify = new NotifyBuilder(context)
                .wereSentTo("activemq:queue:foo").wereSentTo("activemq:queue:bar")
                .create();

As well as you can expect a number of messages to be done, and a message to fail, which has to be sent to another endpoint:

Code Block

        NotifyBuilder notify = new NotifyBuilder(context)
                .whenDone(3).wereSentTo("activemq:queue:goodOrder")
                .and().whenFailed(1).wereSentTo("activemq:queue:badOrder")
                .create();