Yeah, I found this one: 
http://camel.465427.n5.nabble.com/spring-boot-test-mocks-td5773902.html

It seems that at this time (Camel version 2.16.0) @MockEndpoints didn't work at 
all. With my Camel version (2.17.3) it basically works as long as the Spring 
context is not restarted. 

So I moved my test-project to current Camel release 2.19.0 and the result is 
the same. 

All Mocks that are created with @MockEndpoints become deaf as soon as the 
Spring Context is restarted (@DirtiesContext). At least with SpringBoot 
1.4.2.RELEASE.

The workaround with destinations set through properties that is mentioned in 
the above discussion is still valid. 
=> .to("{{myDestinationProperty}}")

Should I raise a Jira Issue?

Regards
Stephan


-----Ursprüngliche Nachricht-----
Von: Claus Ibsen [mailto:claus.ib...@gmail.com]
Gesendet: Freitag, 9. Juni 2017 19:20
An: users@camel.apache.org
Betreff: Re: Deaf MockEndpoints when using Spring @DirtiesContext

Search a bit more on these user forums I think some people have discussed this 
before, also they may got a workaround or it works in a newer release. 2.17.x 
is EOL.

On Fri, Jun 9, 2017 at 1:53 PM, Burkard Stephan <stephan.burk...@visana.ch> 
wrote:
> Hi
>
> I attached a tiny example project to show a strange effect when I use 
> Spring's @DirtiesContext in Camel route tests.
>
> *** Setup:
> - SpringBoot 1.4.2.RELEASE
> - Camel 2.17.3
> - In the project you will find two test classes with two test cases 
> each
> - One test class uses @DirtiesContext, the other does not
> - Let's call them DirtiesContext and StandardContext for easier 
> descriptions
> - Note: I know that these tests do not need @DirtiesContext. This is 
> just to show the problem
>
> *** Results
> - The tests of StandardContext are running fine
> - The first test of DirtiesContext runs fine
> - The second fails because the MockEndpoints receive no more messages
>
> *** Cause
> - The DirtiesContext "Context-Reboot" seems to "destroy" the 
> MockEndpoints
> - In the project ClassMode.AFTER_EACH_TEST_METHOD is used
> - If you switch to ClassMode.BEFORE_EACH_TEST_METHOD, both test cases 
> of that test class fail
>
> *** Cause II
> - In IntelliJ, when I run all tests and StandardContext tests are 
> running after the DirtiesContext tests, they fail too
> - In Maven, this is NOT the case, but I guess this depends on using a 
> process per class or not
>
> Is this a known problem? Should I raise a Jira issue for it?
>
> Regards
> Stephan
>



--
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2

Reply via email to