[ https://issues.apache.org/jira/browse/CAMEL-13491?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16855120#comment-16855120 ]
Jan Hallonsten commented on CAMEL-13491: ---------------------------------------- I have been looking at the code now and I must admit that my knowledge of JUnit internals is not the best so I might have missed something. Is there any way to know in the @After annotated tearDown method that the currently running test method is the last in the test class and that it is time to stop the camel context? From my point of view that is why we have the @AfterClass annotation to be able to run code after all test methods have been executed. So for now I am inclined to move the tearDown back to a static @AfterClass annotated method. Since the @AfterClass method needs to be static, doing that would mess up test classes that override doPostTearDown and/or cleanupResources, expecting them to be executed after the camel context is stopped. Any input or suggestions on how to fix it? > CamelTestSupport.isCreateCamelContextPerClass no longer works for junit4 tests > ------------------------------------------------------------------------------ > > Key: CAMEL-13491 > URL: https://issues.apache.org/jira/browse/CAMEL-13491 > Project: Camel > Issue Type: Bug > Components: camel-test > Affects Versions: 2.23.0 > Reporter: Jan Hallonsten > Priority: Major > Fix For: 3.0.0 > > > With the changes in > org.apache.camel.test.junit4.CamelTestSupport done during the work on > https://issues.apache.org/jira/browse/CAMEL-12534 the camel context is now > recreated for every test regardless of the return value from > isCreateCamelContextPerClass() > . Since junit4 creates a new instance of the class for every test the > variable tests will be recreated and initialized to 0 for every test. > This condition in tearDown will always be true > {code:java} > // code placeholder > if (tests.compareAndSet(v, v - 1)) { > if (v == 1) { > {code} > which stops the camel context after every test. -- This message was sent by Atlassian JIRA (v7.6.3#76005)