Hi Nicolas

Thanks for sharing. It looks good and pretty similar to the other
extensions we have.

I will take a deeper look at the PR asap.

Regards
JB

On Thu, Feb 10, 2022 at 8:03 PM Nicolas Filotto <nfilo...@talend.com> wrote:
>
> Hi,
>
> I've just created a ticket https://issues.apache.org/jira/browse/CAMEL-17633 
> and proposed a PR https://github.com/apache/camel/pull/6929, to add the 
> support of Junit 5 for Camel CDI. I reused part of the code for JUnit 4, the 
> main difference is about the way to advice a route.
>
>
> So far, what I propose, is to rely on a new annotation (I know that it is not 
> consistent with other test components) called "AdviceRoute" to mark class of 
> type "AdviceWithRouteBuilder" and to bring the id of the route to advice.
>
> Here is an example:
>
> @ExtendWith(CamelCdiExtension.class)
> public class CamelCdiTest {
>     @AdviceRoute("main-route")
>     public class ReplaceDirectWithMockBuilder extends AdviceWithRouteBuilder {
>         @Override
>         public void configure() throws Exception {
>             weaveByToUri("direct:out").replace().to("mock:test");
>         }
>     }
> }
> In the previous example, the AdviceWithRouteBuilder of type 
> ReplaceDirectWithMockBuilder advises the route whose identifier is main-route.
>
> The JUnit extension will automatically detect those classes, instantiate them 
> and delay the start-up of the Camel context to make sure that the "advice 
> process" works properly. In other words, you don't have to call explicitly 
> the method "AdviceWith.adviceWith" to advice a route and you don't have to 
> start manually the Camel context which I personally find not convenient. The 
> main drawback is the fact that you can only advice a route by id which limits 
> the possibilities.
>
> What do you think of it? Do you have any feedbacks/questions/remarks to share?
>
> Thank you in advance for your answers,
> Regards,
> Nicolas
>
> As a recipient of an email from Talend, your contact personal data will be on 
> our systems. Please see our privacy notice (updated August 2020) at Talend, 
> Inc. <https://www.talend.com/contacts-privacy-policy/>
>
>

Reply via email to