Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing transacted routes with Quarkus and CamelTestSupport fails #3379

Closed
radio042 opened this issue Dec 10, 2021 · 9 comments
Closed

Testing transacted routes with Quarkus and CamelTestSupport fails #3379

radio042 opened this issue Dec 10, 2021 · 9 comments

Comments

@radio042
Copy link

Dear all,

I have problems testing routes with CamelTestSupport in a Quarkus project when a transacted() definition is part of the route.

Describe the bug

The exchanges do not seem to reach the endpoints, when "transacted()" is part of the route.

Snippets:

  • Route:
from("direct:in").transacted().to("mock:out");
  • Test:
MockEndpoint mockEndpoint = getMockEndpoint("mock:out");
mockEndpoint.expectedMessageCount(1);
template.sendBody("direct:in", "hello");
assertMockEndpointsSatisfied();

Here's a Gist of my test setup and the pom.xml: https://gist.github.com/radio042/b71717d5634eaa634c9affc1021eacfb#file-transactedtest-java

Expected behavior

Messages sent to a route with a transacted() definition using CamelTestSupport in a Quarkus project reach the endpoints and the test is green.

Actual behavior

The test fails with java.lang.AssertionError: mock://out Received message count. Expected: <1> but was: <0>

How to Reproduce?

Run the test from the gist inside a Quarkus project

@zhfeng
Copy link
Contributor

zhfeng commented Dec 10, 2021

Well, I think we've not support the CamelTestSupport yet with Camel Quarkus. Is there any reason you can not use QuarkusTest for running this test ?

@radio042
Copy link
Author

I can, but I'm getting the same behavior when annotating the Class with @QuarkusTest.

@zhfeng
Copy link
Contributor

zhfeng commented Dec 10, 2021

Please check with our JtaTest, or you can get more details about how to write a test with Quarkus from https://quarkus.io/guides/getting-started-testing

@radio042
Copy link
Author

radio042 commented Dec 10, 2021

Thanks for the links! The thing is, I am trying to test a camel route that has the transacted() definition, not transactions in general. The test would work once transacted() is commented out, so I assume that either the test setup is incomplete or the combination "Quarkus + CamelTestSupport + transacted()" does not work as I expect.

By the way, is this the right place to raise the issue? I opened it here, because there are a lot of examples of similar tests with Spring online that allegedly work.

@zhfeng
Copy link
Contributor

zhfeng commented Dec 11, 2021

I understand and just create a camel-test-demo to show how to use CamelTestSupport in camel-quarkus. Hope it is useful !

Free feel to give some feedback.

@zhfeng
Copy link
Contributor

zhfeng commented Dec 11, 2021

I'm not sure this is a good way but it just works.

@radio042
Copy link
Author

radio042 commented Dec 11, 2021

Perfect, this solved my problem! Thanks a lot. :) I think it's a good solution, after all in most cases it does not matter which specific CamelContext instance a test uses.

@ppalaga
Copy link
Contributor

ppalaga commented Dec 14, 2021

I understand and just create a camel-test-demo to show how to use CamelTestSupport in camel-quarkus. Hope it is useful !

What a cute hack, @zhfeng! Could you perhaps mention it in #1981 where some folks asked for CamelTestSupport?

Hm... on the same note, I wonder whether we could somehow set the context automatically. Either by having our own subclass of CamelTestSupport (ugly) or something nicer, like implementing a junit5 extension that would do it?

@zhfeng
Copy link
Contributor

zhfeng commented Dec 14, 2021

@ppalaga yeah, that could be a better way to have a junit5 extension. I will investigate it after the holidays.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants