PR: https://github.com/apache/camel/pull/15146/files
> In short: what is the advised way to use CamelTestSupport (in the future)? It depends on the needs of your code: - For those cases, I recommend setting up using setupResources. - If your test code is extremely complex, then create your own base class and specialize the AbstractTestSupport. This is what Camel Quarkus is doing. I think most projects don't need to do this > If this is work-in-progress, where can we track it to keep up-to-date? This is a multi-release effort as there is a lot of code (within Camel and in the community) that relies on this. The first ticket related to this refactoring has a link to the current (4.7.0) and upcoming changes (4.8.0 and 4.9.0). Notably, for 4.8.0, a lot of the restricted APIs will be set as a final so that code won't be able to rely on them anymore: https://issues.apache.org/jira/browse/CAMEL-20838. For 4.9.0 the plan is to decouple the JUnit 5 extension code from the CamelTestSupport: https://issues.apache.org/jira/browse/CAMEL-20837 For 4.10.x and beyond: remove the legacy APIs, create additional interfaces and/or utilities methods to simplify migrating away from those The most important thing, IMHO, is to ensure that the code does not rely on any of those restricted APIs. If possible, prefer using JUnit 5 APIs (i.e.: setup things with @BeforeEach, for instance) whenever possible. Once the code migrates away from those, it should be relatively simple to keep up to date. I also strongly recommend avoiding @TestInstance(TestInstance.Lifecycle. PER_CLASS) with classes that extend CamelTestSupport. For a reference of the changes that might be needed for 4.9.0, you can look at a tag I created with my WIP code: https://github.com/orpiske/camel/commits/camel-20837-extensions-reference. There are 5 changes in there: the first one is the migration to extensions, and the last 4 are adjustments to just a few classes that were still abusing the API. Kind regards On Tue, Aug 13, 2024 at 4:58 PM Otavio Rodolfo Piske <angusyo...@gmail.com> wrote: > Hi, > > Thanks for reporting this! I replied on StackOverflow, but copying my > response here for context: > <https://stackoverflow.com/posts/78866973/timeline> > > "... I probably shouldn't have been that restrictive with the > TestExecutionConfiguration class. Preventing enabling withAdviceWith is a > mistake and I logged it as CAMEL-21078 > <https://issues.apache.org/jira/browse/CAMEL-21078>. It will be fixed for > Camel 4.8.0 ..." > > Kind regards > > > > On Tue, Aug 13, 2024 at 8:52 AM Claus Ibsen <claus.ib...@gmail.com> wrote: > >> Hi >> >> Yeah that is a good question. AdviceWith is a great feature for unit >> testing and we should ensure it's still possible and easy to use. >> Otavio is leading this effort and it would be good to get his attention to >> this matter. >> >> >> >> On Mon, Aug 12, 2024 at 10:00 AM Castermans, Thom >> <thom.casterm...@ordina.nl.invalid> wrote: >> >> > Hello Camel users, >> > >> > >> > (Prefix: I have asked this question on Stack Overflow [1] last week, but >> > think this might be a better venue. I will update the Q&A with anything >> I >> > learn here.) >> > >> > Our team has recently upgraded to Camel 4.7.0 and learned about the >> > ongoing work to streamline the CamelTestSupport class (CAMEL-20785, >> > CAMEL-20843). This impacted our route unit tests, which extend >> > CamelTestSupport and override `isUseAdviceWith` to return true, in >> order to >> > avoid the Camel context restarting upon actually advicing a route. We >> > manually start the context in each test. >> > >> > In the process of resolving the deprecations introduced by the upgrade, >> we >> > were trying to figure out what the advised (no pun intended) way forward >> > is. We found the `setupResources` method that can be overridden, but >> also >> > warns about doing that in its JavaDoc. We also found >> > `testConfigurationBuilder.withUseAdviceWith(true);`, but since that >> method >> > is protected, it cannot be called from the unit test. Is that >> intentional? >> > >> > In short: what is the advised way to use CamelTestSupport (in the >> future)? >> > If this is work-in-progress, where can we track it to keep up-to-date? >> > >> > >> > Best regards, thank you, >> > Thom Castermans >> > >> > >> > [1]: >> > >> https://stackoverflow.com/questions/78844486/how-can-i-enable-useadvicewith-in-a-cameltestsupport-unit-test >> > >> > Disclaimer >> > Dit bericht met eventuele bijlagen is vertrouwelijk en uitsluitend >> bestemd >> > voor de geadresseerde. Indien u niet de bedoelde ontvanger bent, wordt u >> > verzocht de afzender te waarschuwen en dit bericht met eventuele >> bijlagen >> > direct te verwijderen en/of te vernietigen. Het is niet toegestaan dit >> > bericht en eventuele bijlagen te vermenigvuldigen, door te sturen, >> openbaar >> > te maken, op te slaan of op andere wijze te gebruiken. Ordina Holding >> B.V. >> > en/of haar groepsmaatschappijen accepteren geen verantwoordelijkheid of >> > aansprakelijkheid voor schade die voortvloeit uit de inhoud en/of de >> > verzending van dit bericht. >> > >> > This e-mail and any attachments are confidential and are solely intended >> > for the addressee. If you are not the intended recipient, please notify >> the >> > sender and delete and/or destroy this message and any attachments >> > immediately. It is prohibited to copy, to distribute, to disclose or to >> use >> > this e-mail and any attachments in any other way. Ordina Holding B.V. >> > and/or its group companies do not accept any responsibility nor >> liability >> > for any damage resulting from the content of and/or the transmission of >> > this message. >> > >> >> >> -- >> Claus Ibsen >> ----------------- >> @davsclaus >> Camel in Action 2: https://www.manning.com/ibsen2 >> > > > -- > Otavio R. Piske > http://orpiske.net > -- Otavio R. Piske http://orpiske.net