You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Claus Ibsen (JIRA)" <ji...@apache.org> on 2015/07/10 11:51:04 UTC

[jira] [Resolved] (CAMEL-7193) Assertions are applied an extra, unnecessary time after an assertion period

     [ https://issues.apache.org/jira/browse/CAMEL-7193?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Claus Ibsen resolved CAMEL-7193.
--------------------------------
    Resolution: Fixed

Thanks for the suggestion

> Assertions are applied an extra, unnecessary time after an assertion period
> ---------------------------------------------------------------------------
>
>                 Key: CAMEL-7193
>                 URL: https://issues.apache.org/jira/browse/CAMEL-7193
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-core
>            Reporter: Anders Rabo Thorbeck
>            Assignee: Claus Ibsen
>            Priority: Minor
>             Fix For: 2.16
>
>   Original Estimate: 2h
>  Remaining Estimate: 2h
>
> {{org.apache.camel.component.mock.MockEndpoint.expectedMessagesMatches(Predicate...)}} is implemented in such a way that, if the test at hand is run with an assert period, then an assertion will be run once before the assert period, but will then be run twice more (when it only needs to run once more) after the assertion period is up. 
> This is because the {{run()}} method of the {{org.apache.camel.component.mock.AssertionClause}} created in {{expectedMessagesMatches(Predicate...)}} calls {{AssertionClause.addPredicate(Predicate)}}, which has not been implemented as an [idempotent|http://en.wiktionary.org/wiki/idempotence] function.
> Therefore, when the assertion is run before the assert period, the {{Predicate}} is added to the {{AssertionClause}} once, and when the assertion is run again _after_ the assert period, the same {{Predicate}} is added again to the same {{AssertionClause}}, and so it is executed one more time than necessary.
> This can be fixed by making the method {{AssertionClause.addPredicate(Predicate)}} idempotent. Suggestions for doing so are:
> *  to change the type of {{org.apache.camel.component.mock.AssertionClause.predicates}} from {{List<Predicate>}} to {{Set<Predicate>}} ({{java.util.LinkedHashSet}} will preserve insertion order), or
> * to add a containment check in {{AssertionClause.addPredicate(Predicate)}}, before adding the {{Predicate}} to the list.
> I am not sure whether this will work with equality checking of anonymous Predicate classes with themselves.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)