From 84e0a0dd9d0df0f28b6992789343987d9f232918 Mon Sep 17 00:00:00 2001 From: Clement Escoffier Date: Sat, 21 Sep 2024 17:57:49 +0200 Subject: [PATCH] Improve the Kafka messaging tests to avoid the issue when accessing a missing resource (because the code is commented out) --- .../KafkaDevServicesContinuousTestingTestCase.java | 3 --- ...cesContinuousTestingWorkingAppPropsTestCase.java | 2 -- .../kafka/deployment/testing/PriceResource.java | 11 ++++++++++- .../kafka/deployment/testing/PriceResourceET.java | 13 ++++++------- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/extensions/smallrye-reactive-messaging-kafka/deployment/src/test/java/io/quarkus/smallrye/reactivemessaging/kafka/deployment/testing/KafkaDevServicesContinuousTestingTestCase.java b/extensions/smallrye-reactive-messaging-kafka/deployment/src/test/java/io/quarkus/smallrye/reactivemessaging/kafka/deployment/testing/KafkaDevServicesContinuousTestingTestCase.java index 3f3ffca939217..0b0625c7a146f 100644 --- a/extensions/smallrye-reactive-messaging-kafka/deployment/src/test/java/io/quarkus/smallrye/reactivemessaging/kafka/deployment/testing/KafkaDevServicesContinuousTestingTestCase.java +++ b/extensions/smallrye-reactive-messaging-kafka/deployment/src/test/java/io/quarkus/smallrye/reactivemessaging/kafka/deployment/testing/KafkaDevServicesContinuousTestingTestCase.java @@ -6,7 +6,6 @@ import org.jboss.shrinkwrap.api.asset.StringAsset; import org.jboss.shrinkwrap.api.spec.JavaArchive; import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; @@ -43,7 +42,6 @@ public JavaArchive get() { //see https://github.com/quarkusio/quarkus/issues/19180 @Test - @Disabled("flaky") public void testContinuousTestingScenario1() { ContinuousTestingTestUtils utils = new ContinuousTestingTestUtils(); var result = utils.waitForNextCompletion(); @@ -68,7 +66,6 @@ public void testContinuousTestingScenario1() { } @Test - @Disabled("flaky") public void testContinuousTestingScenario2() { ContinuousTestingTestUtils utils = new ContinuousTestingTestUtils(); var result = utils.waitForNextCompletion(); diff --git a/extensions/smallrye-reactive-messaging-kafka/deployment/src/test/java/io/quarkus/smallrye/reactivemessaging/kafka/deployment/testing/KafkaDevServicesContinuousTestingWorkingAppPropsTestCase.java b/extensions/smallrye-reactive-messaging-kafka/deployment/src/test/java/io/quarkus/smallrye/reactivemessaging/kafka/deployment/testing/KafkaDevServicesContinuousTestingWorkingAppPropsTestCase.java index 908cd496497ed..e575d89389797 100644 --- a/extensions/smallrye-reactive-messaging-kafka/deployment/src/test/java/io/quarkus/smallrye/reactivemessaging/kafka/deployment/testing/KafkaDevServicesContinuousTestingWorkingAppPropsTestCase.java +++ b/extensions/smallrye-reactive-messaging-kafka/deployment/src/test/java/io/quarkus/smallrye/reactivemessaging/kafka/deployment/testing/KafkaDevServicesContinuousTestingWorkingAppPropsTestCase.java @@ -6,7 +6,6 @@ import org.jboss.shrinkwrap.api.asset.StringAsset; import org.jboss.shrinkwrap.api.spec.JavaArchive; import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; @@ -38,7 +37,6 @@ public JavaArchive get() { * See https://github.com/quarkusio/quarkus/issues/19180. */ @Test - @Disabled("flaky") public void testContinuousTestingScenario3() { ContinuousTestingTestUtils utils = new ContinuousTestingTestUtils(); var result = utils.waitForNextCompletion(); diff --git a/extensions/smallrye-reactive-messaging-kafka/deployment/src/test/java/io/quarkus/smallrye/reactivemessaging/kafka/deployment/testing/PriceResource.java b/extensions/smallrye-reactive-messaging-kafka/deployment/src/test/java/io/quarkus/smallrye/reactivemessaging/kafka/deployment/testing/PriceResource.java index 9c6f7dc20880d..d270fdc7b4d83 100644 --- a/extensions/smallrye-reactive-messaging-kafka/deployment/src/test/java/io/quarkus/smallrye/reactivemessaging/kafka/deployment/testing/PriceResource.java +++ b/extensions/smallrye-reactive-messaging-kafka/deployment/src/test/java/io/quarkus/smallrye/reactivemessaging/kafka/deployment/testing/PriceResource.java @@ -1,5 +1,8 @@ package io.quarkus.smallrye.reactivemessaging.kafka.deployment.testing; +import jakarta.ws.rs.GET; +import jakarta.ws.rs.Path; + // //import org.eclipse.microprofile.reactive.messaging.Channel; //import org.reactivestreams.Publisher; @@ -9,8 +12,14 @@ //import jakarta.ws.rs.Produces; //import jakarta.ws.rs.core.MediaType; // -//@Path("/prices") +@Path("/prices") public class PriceResource { + + @GET + public String ok() { + return "ok"; + } + // private final Publisher processedPrices; // // public PriceResource(@Channel("processed-prices") Publisher processedPrices) { diff --git a/extensions/smallrye-reactive-messaging-kafka/deployment/src/test/java/io/quarkus/smallrye/reactivemessaging/kafka/deployment/testing/PriceResourceET.java b/extensions/smallrye-reactive-messaging-kafka/deployment/src/test/java/io/quarkus/smallrye/reactivemessaging/kafka/deployment/testing/PriceResourceET.java index 26e2f80a480a8..5dce321de54b9 100644 --- a/extensions/smallrye-reactive-messaging-kafka/deployment/src/test/java/io/quarkus/smallrye/reactivemessaging/kafka/deployment/testing/PriceResourceET.java +++ b/extensions/smallrye-reactive-messaging-kafka/deployment/src/test/java/io/quarkus/smallrye/reactivemessaging/kafka/deployment/testing/PriceResourceET.java @@ -1,6 +1,5 @@ package io.quarkus.smallrye.reactivemessaging.kafka.deployment.testing; -import java.net.URI; import java.time.Duration; import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; @@ -14,20 +13,20 @@ import org.awaitility.Awaitility; import org.junit.jupiter.api.Test; -import io.quarkus.test.common.http.TestHTTPEndpoint; -import io.quarkus.test.common.http.TestHTTPResource; import io.quarkus.test.junit.QuarkusTest; +import io.restassured.RestAssured; @QuarkusTest class PriceResourceET { - @TestHTTPEndpoint(PriceResource.class) - @TestHTTPResource("/stream") - URI uri; @Test public void sseStream() { + Awaitility.await().untilAsserted(() -> { + RestAssured.get("http://localhost:8081/prices").then().statusCode(200); + }); + Client client = ClientBuilder.newClient(); - WebTarget target = client.target(this.uri); + WebTarget target = client.target("http://localhost:8081/prices/stream"); List received = new CopyOnWriteArrayList<>();