Reputation: 166
Is this possible to somehow run Citrus simulator scenario from within Citrus testcase?
I have an end-to-end test scenario. I send a message to the input endpoint and receive it from the very last endpoint:
<parallel>
<sequential>
<receive endpoint="...">
<message>
<resource file="..."/>
</message>
<header>
...
</header>
</receive>
</sequential>
<sequential>
<sleep seconds="10"/>
<send endpoint="...">
<message>
<resource file="..."/>
</message>
<header>
...
</header>
</send>
</sequential>
</parallel>
In the meantime my application performs some additional readings. I need to simulate replies for these readings and it would be great if I am able to include replies for these reading in this testcase or start a particular Simulator scenario together with running this testcase (no need to start additional external Java Simulator application before testing). Is this possible?
Best Regards
Upvotes: 0
Views: 194
Reputation: 1574
Let me see if I understood your scenario correctly:
You can achieve this with the <parallel>
& <sequential>
tags:
<parallel>
<sequential>
<!-- send initial request -->
<send ...>
<!-- receive response to the initial request -->
<receive ...>
</sequential>
<sequential>
<!-- simulate readings -->
</sequential>
</parallel>
You have two threads. In the first <sequential>
you send the initiating request (1) AND wait for a response (3).
In the second <sequential>
you simulate replies for your readings (2).
Both threads will run in parallel. Citrus will send the request, after which it will wait for a response with the <receive>
action. That response will only come after you finish simulating your readings (on the parallel thread) and your app will be capable of sending the correct response (I presume). This means that you either need to put a sleep between the <send>
and <receive>
inside your first <sequential>
OR configure a high enough timeout for the <receive>
action.
I have also answered an older question of yours related to Citrus and topics, and I presume, that is why you have two <sequential>
running in parallel with the <receive>
in the first one. If your app sends a response only after the readings are beings simulated, the setup that I have posted above should work, since the speed of the response should not be an issue. If speed is still an issue, something like this should work:
<parallel>
<sequential>
<!-- receive response to the initial request -->
<receive ...>
</sequential>
<sequential>
<!-- send initial request -->
<send ...>
</sequential>
<sequential>
<!-- simulate readings -->
</sequential>
</parallel>
Again, don't forget the timeout on the <receive>
action.
In case you need something like reusable test scenarios, maybe templates can help you.
Upvotes: 1