diff --git a/demo/sample-quarkus/pom.xml b/demo/sample-quarkus/pom.xml
index 7a3381dc..791ebeb0 100644
--- a/demo/sample-quarkus/pom.xml
+++ b/demo/sample-quarkus/pom.xml
@@ -116,6 +116,11 @@
citrus-mail
test
+
+ org.citrusframework
+ citrus-sql
+ test
+
org.citrusframework
citrus-validation-text
diff --git a/demo/sample-quarkus/src/test/java/org/apache/camel/demo/FoodMarketApplicationTest.java b/demo/sample-quarkus/src/test/java/org/apache/camel/demo/FoodMarketApplicationTest.java
index bb6f999a..968432c5 100644
--- a/demo/sample-quarkus/src/test/java/org/apache/camel/demo/FoodMarketApplicationTest.java
+++ b/demo/sample-quarkus/src/test/java/org/apache/camel/demo/FoodMarketApplicationTest.java
@@ -17,8 +17,10 @@
package org.apache.camel.demo;
-import com.fasterxml.jackson.databind.ObjectMapper;
+import javax.sql.DataSource;
+
import io.quarkus.test.junit.QuarkusTest;
+import jakarta.inject.Inject;
import org.apache.camel.demo.model.Booking;
import org.apache.camel.demo.model.Product;
import org.apache.camel.demo.model.Supply;
@@ -34,11 +36,13 @@
import org.citrusframework.quarkus.CitrusSupport;
import org.junit.jupiter.api.Test;
+import static org.citrusframework.actions.ExecuteSQLAction.Builder.sql;
import static org.citrusframework.actions.ReceiveMessageAction.Builder.receive;
import static org.citrusframework.actions.SendMessageAction.Builder.send;
import static org.citrusframework.actions.SleepAction.Builder.delay;
import static org.citrusframework.container.Iterate.Builder.iterate;
import static org.citrusframework.container.Parallel.Builder.parallel;
+import static org.citrusframework.container.RepeatOnErrorUntilTrue.Builder.repeatOnError;
import static org.citrusframework.dsl.JsonSupport.marshal;
@QuarkusTest
@@ -67,29 +71,43 @@ class FoodMarketApplicationTest {
@CitrusResource
private TestCaseRunner t;
- @CitrusResource
- private ObjectMapper mapper;
+ @Inject
+ DataSource dataSource;
@Test
void shouldCompleteOnSupply() {
Product product = new Product("Watermelon");
t.when(send()
.endpoint(products)
- .message().body(marshal(product, mapper)));
-
- t.then(delay().seconds(3L));
+ .message().body(marshal(product)));
+
+ t.then(repeatOnError()
+ .condition((i, context) -> i > 25)
+ .autoSleep(500)
+ .actions(sql().dataSource(dataSource)
+ .query()
+ .statement("select count(id) as found from product where product.name='%s'".formatted(product.getName()))
+ .validate("found", "1"))
+ );
Booking booking = new Booking("citrus-test", product, 100, 0.99D);
t.when(send()
.endpoint(bookings)
- .message().body(marshal(booking, mapper)));
-
- t.then(delay().milliseconds(1500L));
+ .message().body(marshal(booking)));
+
+ t.then(repeatOnError()
+ .condition((i, context) -> i > 25)
+ .autoSleep(500)
+ .actions(sql().dataSource(dataSource)
+ .query()
+ .statement("select count(id) as found from booking where booking.status='PENDING'")
+ .validate("found", "1"))
+ );
Supply supply = new Supply(product, 100, 0.99D);
t.when(send()
.endpoint(supplies)
- .message().body(marshal(supply, mapper)));
+ .message().body(marshal(supply)));
BookingCompletedEvent completedEvent = BookingCompletedEvent.from(booking);
completedEvent.setStatus(Booking.Status.COMPLETED.name());
@@ -98,10 +116,10 @@ void shouldCompleteOnSupply() {
t.then(parallel().actions(
receive()
.endpoint(completed)
- .message().body(marshal(completedEvent, mapper)),
+ .message().body(marshal(completedEvent)),
receive()
.endpoint(shipping)
- .message().body(marshal(shippingEvent, mapper))
+ .message().body(marshal(shippingEvent))
));
t.then(receive()
@@ -120,17 +138,24 @@ void shouldCompleteOnSupply() {
void shouldCompleteOnBooking() {
Product product = new Product("Pineapple");
- Supply supply = new Supply(product, 100, 0.99D);
+ Supply supply = new Supply(product, 100, 0.90D);
t.when(send()
- .endpoint(supplies)
- .message().body(marshal(supply, mapper)));
-
- t.then(delay().milliseconds(1500L));
+ .endpoint(supplies)
+ .message().body(marshal(supply)));
+
+ t.then(repeatOnError()
+ .condition((i, context) -> i > 25)
+ .autoSleep(500)
+ .actions(sql().dataSource(dataSource)
+ .query()
+ .statement("select count(id) as found from supply where supply.status='AVAILABLE'")
+ .validate("found", "1"))
+ );
Booking booking = new Booking("citrus-test", product, 100, 0.99D);
t.when(send()
- .endpoint(bookings)
- .message().body(marshal(booking, mapper)));
+ .endpoint(bookings)
+ .message().body(marshal(booking)));
BookingCompletedEvent completedEvent = BookingCompletedEvent.from(booking);
completedEvent.setStatus(Booking.Status.COMPLETED.name());
@@ -139,10 +164,10 @@ void shouldCompleteOnBooking() {
t.then(parallel().actions(
receive()
.endpoint(completed)
- .message().body(marshal(completedEvent, mapper)),
+ .message().body(marshal(completedEvent)),
receive()
.endpoint(shipping)
- .message().body(marshal(shippingEvent, mapper))
+ .message().body(marshal(shippingEvent))
));
t.then(receive()
@@ -168,7 +193,7 @@ void shouldCompleteAllMatchingBookings() {
.actions(
send()
.endpoint(bookings)
- .message().body(marshal(booking, mapper))));
+ .message().body(marshal(booking))));
t.variable("booking", booking);
t.$(delay().milliseconds(1000L));
@@ -183,20 +208,20 @@ void shouldCompleteAllMatchingBookings() {
t.then(parallel().actions(
send()
.endpoint(supplies)
- .message().body(marshal(supply, mapper)),
+ .message().body(marshal(supply)),
iterate()
.condition((i, context) -> i < 10)
.actions(
receive()
.endpoint(completed)
- .message().body(marshal(completedEvent, mapper))
+ .message().body(marshal(completedEvent))
),
iterate()
.condition((i, context) -> i < 10)
.actions(
receive()
.endpoint(shipping)
- .message().body(marshal(shippingEvent, mapper))
+ .message().body(marshal(shippingEvent))
)
));
}