Hi,
I am running a JUnit test and doing the following:

template.sendBodyAndHeader("direct:a", "answer", "recipientListHeader", "mock:x,mock:y");
intercept(header("recipientListHeader").matchesRegex("mock:[xe],mock:[gy]")).to("mock:z");

from("direct:a").recipientList(header("recipientListHeader").tokenize(","));

Doubt #1:

When the messages are actually sent, will the either have:

 a. one of the headers (mock:x or mock:y) OR
 b. both the headers (mock:x and mock:y) ?

Doubt #2:

According to me (just an educated guess) the right answer is 'a'. Assuming this is the answer no messages should be intercepted and mock:z should not get anything. However, when I run the test:

MockEndpoint x = getMockEndpoint("mock:x");
       MockEndpoint y = getMockEndpoint("mock:y");
       MockEndpoint z = getMockEndpoint("mock:z");
x.expectedBodiesReceived("answer");
       y.expectedBodiesReceived("answer");
       z.expectedBodiesReceived("answer");
       z.expectedMinimumMessageCount(100);

       sendBody();
       assertMockEndpointsSatisifed();

it is still shows all tests as successful. How is this happening? The exact output is:

 org.apache.camel.impl.DefaultCamelContext <init>
INFO: JMX enabled. Using InstrumentationLifecycleStrategy.
 org.apache.camel.component.mock.MockEndpoint assertIsSatisfied
INFO: Asserting: Endpoint[mock:z] is satisfied
 org.apache.camel.component.mock.MockEndpoint assertIsSatisfied
INFO: Asserting: Endpoint[mock:y] is satisfied
 org.apache.camel.component.mock.MockEndpoint assertIsSatisfied
INFO: Asserting: Endpoint[mock:x] is satisfied

Now, even if I'm wrong and 'a' is not the answer to doubt#1, and messages do reach mock:z, how can it get 100 messages?

Thanks,
Sylvester

Reply via email to