Test a Camel route using Citrus? #38328
Replies: 1 comment
-
This is because Citrus will create its own CamelContext and uses it to send the message. Since this Citrus related CamelContext has not been started yet the test runs into the error We need to make Citrus aware of the CamelContext that is injected by Quarkus. In order to do this you can add This should be working: @QuarkusTest
@CitrusSupport
public class CamelRoute2Test extends CamelQuarkusTestSupport {
@CitrusResource
TestCaseRunner t;
@Inject
@BindToRegistry
CamelContext camelContext;
@Test
@DisplayName("Citrus Test")
void citrusTest() {
t.when(send(camel(camelContext).endpoint(direct("hello")::getUri))
.message()
.type(MessageType.PLAINTEXT)
.body("Hello"));
t.then(receive(camel(camelContext).endpoint(seda("greetings")::getUri))
.message()
.type(MessageType.PLAINTEXT)
.body("Hello from Citrus!"));
}
} Please be careful to reference the annotation in Please let me know if this is working for you. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
The Insight #149 was a really good presentation on how to unit test Quarkus using Citrus.
There's also support for Camel in Citrus but how does that work in Quarkus?
Are there any resources out there that can show a basic test class using JUnit in Quarkus with a Camel route?
I have tried to puzzle the documentation together for a test but I fail.
To me, it seems that Citrus works fine when using Camel in Spring or plain Quarkus but when combined something is missing and I don't know what…
My test class:
I have tried different approaches but it fails and I have exhausted my options, it seems:
My route to test
Using Quarkus 3.6.5 and Citrus 4.1.0
Please advise, thanks
M
Beta Was this translation helpful? Give feedback.
All reactions