You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by GitBox <gi...@apache.org> on 2022/12/31 19:40:19 UTC

[GitHub] [camel-quarkus] ppalaga opened a new issue, #4362: Multiple test methods do not work in a class extending CamelQuarkusTestSupport

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

   Originally reported by @guhilling via chat.
   
   A reproducer project is here: https://github.com/guhilling/camel-quarkus-demos
   


-- 
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-unsubscribe@camel.apache.org.apache.org

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


[GitHub] [camel-quarkus] JiriOndrusek commented on issue #4362: Multiple test methods do not work in a class extending CamelQuarkusTestSupport

Posted by GitBox <gi...@apache.org>.
JiriOndrusek commented on issue #4362:
URL: https://github.com/apache/camel-quarkus/issues/4362#issuecomment-1370567318

   Hi @guhilling  thanks for spotting this. I refactored my fork obviously a little bit more to make the test work (and didn;t notice this last change).
   
   - First of all, the behaviour with not working `doBeforeEach()` seems like a bug, I'll look at it.
   - Working solution is to use @BeforeEach, as it is used in my [fork](https://github.com/JiriOndrusek/camel-quarkus-demos/blob/workaround/src/test/java/de/hilling/camel/SampleRouteBuilderTest.java#L51-L59).
   
   You can try my modified version from https://github.com/JiriOndrusek/camel-quarkus-demos/tree/workaround, which works.
   
   Please use workaround with `@BeforeEach` until I fix the bug.


-- 
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-unsubscribe@camel.apache.org

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


[GitHub] [camel-quarkus] JiriOndrusek commented on issue #4362: Multiple test methods do not work in a class extending CamelQuarkusTestSupport

Posted by GitBox <gi...@apache.org>.
JiriOndrusek commented on issue #4362:
URL: https://github.com/apache/camel-quarkus/issues/4362#issuecomment-1373393603

   The right approach to solve your problem is to configure which routes should be started in test.
   
   You can use application.properties like 
   
   ```
   quarkus.camel.routes-discovery.exclude-patterns=t
   quarkus.camel.routes-discovery.include-patterns=
   ```
   
   It should be even possible to modify those for different tests using profiles. 


-- 
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-unsubscribe@camel.apache.org

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


[GitHub] [camel-quarkus] guhilling commented on issue #4362: Multiple test methods do not work in a class extending CamelQuarkusTestSupport

Posted by GitBox <gi...@apache.org>.
guhilling commented on issue #4362:
URL: https://github.com/apache/camel-quarkus/issues/4362#issuecomment-1373466828

   I just want to explicitly instantiate just _some_ of the RouteBuilders. So their routes can be tested in isolation. The logic in the samples is purely in the routes, correct. I've updated the example in GitHub. Now it works.
   I would just need a way to properly wrap multiple RouteBuilders into one to return them from "createRouteBuilder()"


-- 
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-unsubscribe@camel.apache.org

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


[GitHub] [camel-quarkus] guhilling commented on issue #4362: Multiple test methods do not work in a class extending CamelQuarkusTestSupport

Posted by GitBox <gi...@apache.org>.
guhilling commented on issue #4362:
URL: https://github.com/apache/camel-quarkus/issues/4362#issuecomment-1372161921

   @JiriOndrusek I got 3 routes created by 3 RouteBuilders in the project. In the test only 1 RouteBuilder is provided but all 3 routes are started.


-- 
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-unsubscribe@camel.apache.org

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


[GitHub] [camel-quarkus] JiriOndrusek commented on issue #4362: Multiple test methods do not work in a class extending CamelQuarkusTestSupport

Posted by GitBox <gi...@apache.org>.
JiriOndrusek commented on issue #4362:
URL: https://github.com/apache/camel-quarkus/issues/4362#issuecomment-1373453106

   @guhilling for me to get better understanding. How do you include route builder from `src/main/java`  into the application? In your example, there is no logic in `main` (https://github.com/guhilling/camel-quarkus-demos/blob/main/src/main/java/de/hilling/camel/SampleRouteBuilder.java)
   So I expect some kind of beans registration, @Produces, or similar....
   


-- 
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-unsubscribe@camel.apache.org

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


[GitHub] [camel-quarkus] JiriOndrusek commented on issue #4362: Multiple test methods do not work in a class extending CamelQuarkusTestSupport

Posted by GitBox <gi...@apache.org>.
JiriOndrusek commented on issue #4362:
URL: https://github.com/apache/camel-quarkus/issues/4362#issuecomment-1373485701

   @guhilling  I'll try to help from the top of my head. I'll simulate it in about an hour.
   
    You can use `quarkus.camel.routes-discovery.include-patterns=some/package/RouteBuilder1` to include only RouteBuilder1 into the context.
    
   How it works: camel-quarkus app gathers all routeBuilders and then apply exclude/include patterns into the class of RouteBuilder, See this [code](https://github.com/apache/camel-quarkus/blob/main/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/RegistryRoutesLoaders.java#L117).
   Therefore if you include only some routeBuilders, only those will be present for the tests.
   
   I'll  work on an test covering this scenario later,but I hope that this idea helps you.


-- 
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-unsubscribe@camel.apache.org

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


[GitHub] [camel-quarkus] JiriOndrusek commented on issue #4362: Multiple test methods do not work in a class extending CamelQuarkusTestSupport

Posted by GitBox <gi...@apache.org>.
JiriOndrusek commented on issue #4362:
URL: https://github.com/apache/camel-quarkus/issues/4362#issuecomment-1373540600

   @guhilling I'm glad to know it works.  Don't hesitate to ping me in case there is any issue.


-- 
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-unsubscribe@camel.apache.org

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


[GitHub] [camel-quarkus] JiriOndrusek commented on issue #4362: Multiple test methods do not work in a class extending CamelQuarkusTestSupport

Posted by GitBox <gi...@apache.org>.
JiriOndrusek commented on issue #4362:
URL: https://github.com/apache/camel-quarkus/issues/4362#issuecomment-1373444751

   I'm trying to simulate the same scenario via the extension test. Once it succeeds, I'll show you an example and explain what is needed


-- 
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-unsubscribe@camel.apache.org

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


[GitHub] [camel-quarkus] guhilling commented on issue #4362: Multiple test methods do not work in a class extending CamelQuarkusTestSupport

Posted by GitBox <gi...@apache.org>.
guhilling commented on issue #4362:
URL: https://github.com/apache/camel-quarkus/issues/4362#issuecomment-1372011702

   Hi @JiriOndrusek : One more question: It seems that in my tests all of the routes are always started. They work, even if I don't provide a createRouteBuilder()-method. Is this to be expected (still on 15.1 ...).
   createRouteBuilder() _is_ needed, though, when running multiple test methods ...


-- 
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-unsubscribe@camel.apache.org

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


[GitHub] [camel-quarkus] JiriOndrusek commented on issue #4362: Multiple test methods do not work in a class extending CamelQuarkusTestSupport

Posted by GitBox <gi...@apache.org>.
JiriOndrusek commented on issue #4362:
URL: https://github.com/apache/camel-quarkus/issues/4362#issuecomment-1368703129

   Yes, I'll look into it.


-- 
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-unsubscribe@camel.apache.org

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


[GitHub] [camel-quarkus] JiriOndrusek commented on issue #4362: Multiple test methods do not work in a class extending CamelQuarkusTestSupport

Posted by GitBox <gi...@apache.org>.
JiriOndrusek commented on issue #4362:
URL: https://github.com/apache/camel-quarkus/issues/4362#issuecomment-1372063835

   Hi @guhilling  thanks for the finding of another possible problem. I just want to specify what do you need.
   
   - In camel-quarkus context is started by default. So it is always running. (I can re-phrase doc, to make it more clear. This is the text form the doc `Starting and stopping CamelContext in Camel Quarkus is generally bound to starting and stopping the application and this holds also when testing.`)
   - As you can see [here](https://github.com/apache/camel-quarkus/blob/main/test-framework/junit5/src/test/java/org/apache/camel/quarkus/test/junit5/patterns/AdviceWithAnotherRouteTest.java#L54), route has to be started manually.
   - There is no coverage in tests taking care of auro-starting/stopping routes. I'll fix that. What code are you using to force camel-quarkus to not start routes (to be sure that the fix covers your usecase)?
   
   
   


-- 
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-unsubscribe@camel.apache.org

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


[GitHub] [camel-quarkus] JiriOndrusek commented on issue #4362: Multiple test methods do not work in a class extending CamelQuarkusTestSupport

Posted by GitBox <gi...@apache.org>.
JiriOndrusek commented on issue #4362:
URL: https://github.com/apache/camel-quarkus/issues/4362#issuecomment-1373382460

   I got an idea what could be wrong. Is this scenario similar to yours?
   
   - There are 2 RouteBuilders in the main code `src/main/java` - creating 2 routes
   - 1 RouteBuilder in the test  ('src/test/java')- creating 1 route
   -  Expected result is **1 route started** in the test execution
   - > In reality **3 routes are started** in the test execution
   
   I think that this is the expected behavior with the quarkus.
   
   Let me explain. 
   
   1. When execution a test.  Quarkus scans the whole code base (in this case src/main and src/test) and discovers 2 RouteBuilders.
   2. Camel-quarkus is started and both RouteBuilders are used to create routes, which are automatically started.
   During a beforeEachCalback (or similar one), the routeBuilder in the test is discovered and used -> there are currently 3 running routes. (I recently proposed a change which adds a warning, when this happens - https://github.com/apache/camel-quarkus/issues/4381)
   3. The test sees all 3 routes.
   
   I'd like to ask @ppalaga about his opinion.
   
   I think that as tests are testing application, some routes created by the application should stay running. (and are covered by the tests)
   I can imagine that test should stop the routes if need be.
   
   On the other hand having some kind of helper (or configurable behavior) which will ease the app's routes handling might help.
   
   What do you think @ppalaga?
   
   


-- 
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-unsubscribe@camel.apache.org

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


[GitHub] [camel-quarkus] guhilling commented on issue #4362: Multiple test methods do not work in a class extending CamelQuarkusTestSupport

Posted by GitBox <gi...@apache.org>.
guhilling commented on issue #4362:
URL: https://github.com/apache/camel-quarkus/issues/4362#issuecomment-1373439900

   @JiriOndrusek Will that help? If I only create a Wrapper for some of the "real" RouteBuilder?
   Nevertheless I don't understand why the routes aren't started. Especially as the configure()-method is actually called (I tried in debug).


-- 
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-unsubscribe@camel.apache.org

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


[GitHub] [camel-quarkus] ppalaga commented on issue #4362: Multiple test methods do not work in a class extending CamelQuarkusTestSupport

Posted by GitBox <gi...@apache.org>.
ppalaga commented on issue #4362:
URL: https://github.com/apache/camel-quarkus/issues/4362#issuecomment-1368270921

   @JiriOndrusek would you like to have a look?


-- 
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-unsubscribe@camel.apache.org

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


[GitHub] [camel-quarkus] aldettinger closed issue #4362: Multiple test methods do not work in a class extending CamelQuarkusTestSupport

Posted by GitBox <gi...@apache.org>.
aldettinger closed issue #4362: Multiple test methods do not work in a class extending CamelQuarkusTestSupport 
URL: https://github.com/apache/camel-quarkus/issues/4362


-- 
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-unsubscribe@camel.apache.org

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


[GitHub] [camel-quarkus] guhilling commented on issue #4362: Multiple test methods do not work in a class extending CamelQuarkusTestSupport

Posted by GitBox <gi...@apache.org>.
guhilling commented on issue #4362:
URL: https://github.com/apache/camel-quarkus/issues/4362#issuecomment-1373504835

   @JiriOndrusek Thanks! I'm aware of the include/exclude feature. But: I want to create the RouteBuilders depending on the test class using createRouteBuilders(). It works fine, now!
   (Updated example in Github)
   Now no "global" routes are started and everything works as desired! Of course it _can_ make sense to create some Routes that are started "globally". But I need to prepare some examples for a workshop so I'd like to do some proper "unit"-testing


-- 
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-unsubscribe@camel.apache.org

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


[GitHub] [camel-quarkus] JiriOndrusek commented on issue #4362: Multiple test methods do not work in a class extending CamelQuarkusTestSupport

Posted by GitBox <gi...@apache.org>.
JiriOndrusek commented on issue #4362:
URL: https://github.com/apache/camel-quarkus/issues/4362#issuecomment-1373430920

   I think the better property in your case would be something like `quarkus.camel.routes-discovery.include-patterns=test.package/**`


-- 
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-unsubscribe@camel.apache.org

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


[GitHub] [camel-quarkus] guhilling commented on issue #4362: Multiple test methods do not work in a class extending CamelQuarkusTestSupport

Posted by GitBox <gi...@apache.org>.
guhilling commented on issue #4362:
URL: https://github.com/apache/camel-quarkus/issues/4362#issuecomment-1371990972

   Thanks a lot @JiriOndrusek, will do as soon as 2.16 is released!


-- 
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-unsubscribe@camel.apache.org

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


[GitHub] [camel-quarkus] JiriOndrusek commented on issue #4362: Multiple test methods do not work in a class extending CamelQuarkusTestSupport

Posted by GitBox <gi...@apache.org>.
JiriOndrusek commented on issue #4362:
URL: https://github.com/apache/camel-quarkus/issues/4362#issuecomment-1372094670

   I might have understand your question wrongly. Are you describing a scenario, where a test does not contain any route, but still can access running routes from the other tests?


-- 
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-unsubscribe@camel.apache.org

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


[GitHub] [camel-quarkus] guhilling commented on issue #4362: Multiple test methods do not work in a class extending CamelQuarkusTestSupport

Posted by GitBox <gi...@apache.org>.
guhilling commented on issue #4362:
URL: https://github.com/apache/camel-quarkus/issues/4362#issuecomment-1373420187

   I tried setting "quarkus.camel.main.routes-discovery.enabled=false". But now the routes from "createRouteBuilder" also aren't run: I try to use it to configure specific RouteBuilders from "src/main" like this:
   ```    @Override
       protected RoutesBuilder createRouteBuilder() {
           return new RouteBuilder() {
               @Override
               public void configure() throws Exception {
                   new SampleDataRouteBuilder().configure();
                   new OrderLogRouteBuilder().configure();
               }
           };
       }
   ```


-- 
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-unsubscribe@camel.apache.org

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


[GitHub] [camel-quarkus] JiriOndrusek commented on issue #4362: Multiple test methods do not work in a class extending CamelQuarkusTestSupport

Posted by GitBox <gi...@apache.org>.
JiriOndrusek commented on issue #4362:
URL: https://github.com/apache/camel-quarkus/issues/4362#issuecomment-1369885091

   The problem is caused by the usage of the `javax.enterprise.inject.Produces` in the test (line https://github.com/guhilling/camel-quarkus-demos/blob/main/src/test/java/de/hilling/camel/SampleRouteBuilderTest.java#L35). 
   
   The `CamelQuarkusTestSupport` aims to help replace Camel's CamelTestSupport tests. `@Produce` can not be used with them and CamrlQuarkusTestSupport does not work with them easily. Using @Produce to create routeBuilders is not recommanded.
   
   Here are some problems caused by the differences of lifecycle in Camel and CamelQuarkus:
   
   • Application is started once for all the tests together. Therefore all @Produces methods are applied together - in case there were several Test classes each producing its own route builder - this will force application to create all routes at the start (even if they are not necessary for the first test class)
   • Support of `CamelTestSupport` like tests forces camel-quarkus to emulate several lifecycle actions without stopping the application. Which leads for example to stopping and removing routes and creating them again for another test method/classes.
   • . Fully supported style of registering RouteBuilders is to use overriding method. 
   
   
   Please replace following code (lines https://github.com/guhilling/camel-quarkus-demos/blob/main/src/test/java/de/hilling/camel/SampleRouteBuilderTest.java#L33-L39)
   
   ```
       @Configuration
       public static class TestConfig {
           @Produces
           RoutesBuilder route() {
               return new SampleRouteBuilder();
           }
       }
   ```
   
   with 
   
   ```
       @Override
       protected RouteBuilder createRouteBuilder() {
           return new SampleRouteBuilder();
       }
   ```
   
   and the tests will finish successfully.
   
   I've added the suggestion to not use @Produce with RouteBuilders int the documentation.


-- 
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-unsubscribe@camel.apache.org

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


[GitHub] [camel-quarkus] guhilling commented on issue #4362: Multiple test methods do not work in a class extending CamelQuarkusTestSupport

Posted by GitBox <gi...@apache.org>.
guhilling commented on issue #4362:
URL: https://github.com/apache/camel-quarkus/issues/4362#issuecomment-1370051100

   Thanks for the hint! Unfortunately now I need to put the "advising" (AdviceWith.adviceWith(context() ...) into the test-methods directly as it won't work in "doBeforeEach()" ... Any idea for that?


-- 
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-unsubscribe@camel.apache.org

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


[GitHub] [camel-quarkus] guhilling commented on issue #4362: Multiple test methods do not work in a class extending CamelQuarkusTestSupport

Posted by GitBox <gi...@apache.org>.
guhilling commented on issue #4362:
URL: https://github.com/apache/camel-quarkus/issues/4362#issuecomment-1370584515

   Hi @JiriOndrusek thanks. Using the workaround for now!


-- 
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-unsubscribe@camel.apache.org

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


[GitHub] [camel-quarkus] JiriOndrusek commented on issue #4362: Multiple test methods do not work in a class extending CamelQuarkusTestSupport

Posted by GitBox <gi...@apache.org>.
JiriOndrusek commented on issue #4362:
URL: https://github.com/apache/camel-quarkus/issues/4362#issuecomment-1371925136

   Hi @guhilling  you can return to original code without a workaround, the issue was fixed. (use of `doBeforeEach()` is prefferred)


-- 
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-unsubscribe@camel.apache.org

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