samipeltola81 opened a new issue, #7264:
URL: https://github.com/apache/camel-quarkus/issues/7264

   ### Bug description
   
   When you have multiple tests in the same test class file and you are 
advicing processors with **weaveById**, any test after the first one will fail 
if: 
   
   1) You have the AdviceWith-commands in @BeforeEach or doBeforeEach-method
   2) The routes are defined in a separate RouteBuilder-class
   
   The reason is that it can no longer find the original processor with the id 
while advicing. 
   
   Interestingly, this problem only occurs if you define the routes in a 
separate RouteBuilder-class. If the routes are 
   defined through createRouteBuilder() in the test class, the issue does not 
occur.  
   
   Since the 
[documentation](https://camel.apache.org/camel-quarkus/3.20.x/user-guide/testing.html#_cameltestsupport_style_of_testing)'s
 only AdviceWith example uses @BeforeEach and usually you are advice existing 
routes defined in a separate RouteBuilder-class, this inconsistency seems a bit 
odd.
   
   As
   
   ```
    @BeforeEach
       public void beforeEach() throws Exception {
           AdviceWith.adviceWith(this.context, "advisedRoute", route -> {
               // If you redefine the id on the mock processor, it will fix the 
test as well
               
route.weaveById("target-id").replace().to("mock:target").id("target-id");
           });
       }
   ```
   
   **Reproducer**
   https://github.com/samipeltola81/advicewith


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@camel.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to