[
https://issues.apache.org/jira/browse/CAMEL-12947?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16714085#comment-16714085
]
Antoine Wils commented on CAMEL-12947:
--------------------------------------
[~davsclaus] it make sense but then the assertion is on the missing message in
the count. In other word, you have to know that you forgot to assert the
message count. The error did come from a less experienced developer that did
not figure out that his mock was not injected in the route.
Isn't it logic that any assertion verifies its prerequisites and fails if they
are not met? That was my assumption at least.
> MockEndpoint.expectedHeaderReceived should fail when no exchange received
> -------------------------------------------------------------------------
>
> Key: CAMEL-12947
> URL: https://issues.apache.org/jira/browse/CAMEL-12947
> Project: Camel
> Issue Type: Bug
> Components: camel-test
> Affects Versions: 2.22.1
> Reporter: Antoine Wils
> Assignee: Ramu
> Priority: Minor
>
> When expecting headers to be passed to a MockEndpoint that is never called
> the test should fail if the MockEndpoint was never called.
> However it is succeeding.
> Here an example of Junit 4 test succeeding when it should fail
> {code:java}
> import org.apache.camel.EndpointInject;
> import org.apache.camel.builder.RouteBuilder;
> import org.apache.camel.component.mock.MockEndpoint;
> import org.apache.camel.test.junit4.CamelTestSupport;
> import org.junit.Test;
> public class Test extends CamelTestSupport {
> @EndpointInject(uri = "mock:direct:foo")
> private MockEndpoint fooProducerMock;
> @Override
> public RouteBuilder createRouteBuilder() throws Exception {
> return new RouteBuilder() {
> @Override
> public void configure() throws Exception {}
> };
> }
> @Test
> public void failWhenHeaderAbsent() throws InterruptedException {
> fooProducerMock.expectedHeaderReceived("ghost", "you should be visible");
> MockEndpoint.assertIsSatisfied(context);
> }
> }
> {code}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)