citrusframework / citrusframework/citrus
purgeEndpoints fails if endpoint was not used before
- Dominant language
- Java
- Stars
- 485
- Forks
- 155
- Avg merge
- 4d 22h
- Merged PRs (30d)
- 6
Description
**Citrus Version**
tested with 2.7.6
**Expected behavior**
Calling purgeEndpoints with an endpoint that was not used to send messages has the same behaviour as calling the method with an endpoint that has no messages in the queues anymore because they already are consumed.
In my case this problem occurred in a larger integration test where one execution path lead to the situation that no messages where sent. But the purgeEndpoints method was called at the end of one step in the test to ensure that no messages are present in the queues before executing the next steps of the test.
**Actual behavior**
Calling purgeEndpoints with an endpoint that was not used to send messages leads to an exception:
CitrusRuntimeException: Failed to get correlation key for 'citrus_message_correlator_[clientId]'
Whereas calling the method with an endpoint with no messages results in a log entry:
DEBUG com.consol.citrus.actions.PurgeEndpointAction - Purged 0 messages from endpoint
**Test case sample**
`public class PurgeEndpointTest extends TestNGCitrusTestRunner {
@CitrusEndpoint @HttpClientConfig(requestUrl = "http://localhost:8080")
private HttpClient todoClient;
@CitrusEndpoint @HttpServerConfig(autoStart = true)
private HttpServer todoServer;
@CitrusTest
@Test
public void testPurgeEndpointWorks() {
send(builder -> builder.endpoint(todoClient).payload("some text"));
receive(builder -> builder.endpoint(todoClient));
purgeEndpoints(builder -> builder.endpoint(todoClient));
}
@CitrusTest @Test
public void testPurgeEndpointNotWorking() {
purgeEndpoints(builder -> builder.endpoint(todoClient));
}
}`
**Hint**
The problem is located in the PollingCorrelationManager in line 95 to 97. Maybe it is possible to not throw an exception here but log, e.g. a warning.
best regards,
Chris
Contributor guide
Assessment
This issue has not been assessed yet.