The purgeQueues-action does not work for me as expected; the queue does not seem to get purged.
For the setup: my system under tests receives a text/plain body via http/post and sends this body to an artemis topic.
For the test, I simply send some string to the system under test and then receive the corresponding JMS message. The JMS-setup on the citrus-side looks like this:
@Configuration
public class Jms {
public static final String ENDPOINT = "JMS_ENDPOINT";
public static final String CONNECTION_FACTORY = "CONNECTION_FACTORY";
@Bean
@Qualifier(CONNECTION_FACTORY)
public ConnectionFactory purgeConnectionFactory(
@Value("${test-config.artemis.url}") String url,
@Value("${test-config.artemis.username}") String username,
@Value("${test-config.artemis.password}") String password) {
return new ActiveMQJMSConnectionFactory(url, username, password);
}
@Bean
@Qualifier(ENDPOINT)
public JmsEndpoint jmsEndpoint(
@Qualifier(CONNECTION_FACTORY) ConnectionFactory connectionFactory,
@Value("${test-config.artemis.receive.fqqn}") String fqqn) { // fqqn in this case is `messages::citrus`
return new JmsEndpointBuilder()
.connectionFactory(connectionFactory)
.pubSubDomain(true)
.destination(fqqn)
.autoStart(true)
.build();
}
}
This works fine and as expected.
Now what I want to do is to clear the queue identified by the fqqn, so I implemented the following:
@Configuration
public class BeforeTestSequence {
@Bean
public SequenceBeforeTest beforeTest(
@Qualifier(Jms.CONNECTION_FACTORY) ConnectionFactory connectionFactory,
@Value("${test-config.artemis.receive.fqqn}") String fqqn) {
return SequenceBeforeTest.Builder.beforeTest()
.actions(
purgeQueues()
.connectionFactory(connectionFactory)
.queue(fqqn))
.build();
}
}
This does not work as expected. In a "normal run", the test is green. However, if the queue messages::citrus already exists (from a previous run for example) and I write some message to that queue and THEN trigger the tests, the validation fails. The test "sees" the message i send beforehand, so the cleanup that should be happening does not happfen. In fact, I debugged into PurgeJmsQueuesAction::purgeDestination and the message received was always null.
start artemis (docker-compose --file local-deployment/docker-compose.yml up --detach)
start service (./mvnw --projects service quarkus:dev)
run the citrus tests however you like
To send an interfering message to the queue, execute the following curl after the tests have run at least once (i.e. after the queue for citrus was created)`:
curl -v -X POST localhost:8080/send --data "ouch" --header "Content-Type: text/plain"
If you want to access the artemis broker, go to localhost:8161/console, credentials are artemis/artemis.****
reported in https://citrusframework.zulipchat.com/#narrow/stream/259943-citrus/topic/Problems.20with.20purgeQueues.20action.
The purgeQueues-action does not work for me as expected; the queue does not seem to get purged.
For the setup: my system under tests receives a text/plain body via http/post and sends this body to an artemis topic.
For the test, I simply send some string to the system under test and then receive the corresponding JMS message. The JMS-setup on the citrus-side looks like this:
This works fine and as expected.
Now what I want to do is to clear the queue identified by the fqqn, so I implemented the following:
This does not work as expected. In a "normal run", the test is green. However, if the queue messages::citrus already exists (from a previous run for example) and I write some message to that queue and THEN trigger the tests, the validation fails. The test "sees" the message i send beforehand, so the cleanup that should be happening does not happfen. In fact, I debugged into PurgeJmsQueuesAction::purgeDestination and the message received was always null.
If you need a full reproducer: https://github.com/turing85/citrus-playground/tree/feature/before-test-sequence
To reproduce:
start artemis (
docker-compose --file local-deployment/docker-compose.yml up --detach
) start service (./mvnw --projects service quarkus:dev
) run the citrus tests however you like To send an interfering message to the queue, execute the following curl after the tests have run at least once (i.e. after the queue for citrus was created)`:curl -v -X POST localhost:8080/send --data "ouch" --header "Content-Type: text/plain"
If you want to access the artemis broker, go to localhost:8161/console, credentials are artemis/artemis.****