From b3d8eaeef1c80ba01da4bebed9fdadbd26415728 Mon Sep 17 00:00:00 2001 From: Georgios Andrianakis Date: Fri, 2 Dec 2022 15:42:51 +0200 Subject: [PATCH] Move mongodb-panache ITs to RESTEasy Reactive --- .../mongodb-panache-kotlin/pom.xml | 25 +++---------------- .../book/ReactiveBookEntityResource.kt | 4 +-- .../book/ReactiveBookRepositoryResource.kt | 4 +-- .../ReactiveMongodbPanacheResourceTest.kt | 14 +++-------- integration-tests/mongodb-panache/pom.xml | 25 +++---------------- .../book/ReactiveBookEntityResource.java | 4 +-- .../book/ReactiveBookRepositoryResource.java | 4 +-- .../ReactiveMongodbPanacheResourceTest.java | 17 +++---------- 8 files changed, 22 insertions(+), 75 deletions(-) diff --git a/integration-tests/mongodb-panache-kotlin/pom.xml b/integration-tests/mongodb-panache-kotlin/pom.xml index 1cbd7f566e512..b1b0a6d6a3de6 100644 --- a/integration-tests/mongodb-panache-kotlin/pom.xml +++ b/integration-tests/mongodb-panache-kotlin/pom.xml @@ -17,11 +17,7 @@ io.quarkus - quarkus-resteasy-jackson - - - io.quarkus - quarkus-resteasy-mutiny + quarkus-resteasy-reactive-jackson io.quarkus @@ -29,7 +25,7 @@ io.quarkus - quarkus-rest-client + quarkus-rest-client-reactive @@ -112,20 +108,7 @@ io.quarkus - quarkus-rest-client-deployment - ${project.version} - pom - test - - - * - * - - - - - io.quarkus - quarkus-resteasy-jackson-deployment + quarkus-rest-client-reactive-deployment ${project.version} pom test @@ -138,7 +121,7 @@ io.quarkus - quarkus-resteasy-mutiny-deployment + quarkus-resteasy-reactive-jackson-deployment ${project.version} pom test diff --git a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/reactive/book/ReactiveBookEntityResource.kt b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/reactive/book/ReactiveBookEntityResource.kt index 03da7e84ed4ab..a381eb6f59342 100644 --- a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/reactive/book/ReactiveBookEntityResource.kt +++ b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/reactive/book/ReactiveBookEntityResource.kt @@ -5,7 +5,7 @@ import io.quarkus.panache.common.Sort import io.smallrye.mutiny.Uni import org.bson.types.ObjectId import org.jboss.logging.Logger -import org.jboss.resteasy.annotations.SseElementType +import org.jboss.resteasy.reactive.RestStreamElementType import org.reactivestreams.Publisher import java.net.URI import java.time.LocalDate.parse @@ -42,7 +42,7 @@ class ReactiveBookEntityResource { @GET @Path("/stream") @Produces(MediaType.SERVER_SENT_EVENTS) - @SseElementType(MediaType.APPLICATION_JSON) + @RestStreamElementType(MediaType.APPLICATION_JSON) fun streamBooks(@QueryParam("sort") sort: String?): Publisher { return if (sort != null) { ReactiveBookEntity.streamAll(Sort.ascending(sort)) diff --git a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/reactive/book/ReactiveBookRepositoryResource.kt b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/reactive/book/ReactiveBookRepositoryResource.kt index 6d7f95cf43df6..faa04231dde2a 100644 --- a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/reactive/book/ReactiveBookRepositoryResource.kt +++ b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/reactive/book/ReactiveBookRepositoryResource.kt @@ -6,7 +6,7 @@ import io.quarkus.panache.common.Sort import io.smallrye.mutiny.Uni import org.bson.types.ObjectId import org.jboss.logging.Logger -import org.jboss.resteasy.annotations.SseElementType +import org.jboss.resteasy.reactive.RestStreamElementType import org.reactivestreams.Publisher import java.net.URI import java.time.LocalDate @@ -47,7 +47,7 @@ class ReactiveBookRepositoryResource { @GET @Path("/stream") @Produces(MediaType.SERVER_SENT_EVENTS) - @SseElementType(MediaType.APPLICATION_JSON) + @RestStreamElementType(MediaType.APPLICATION_JSON) fun streamBooks(@QueryParam("sort") sort: String?): Publisher { return if (sort != null) { reactiveBookRepository.streamAll(Sort.ascending(sort)) diff --git a/integration-tests/mongodb-panache-kotlin/src/test/kotlin/io/quarkus/it/mongodb/panache/reactive/ReactiveMongodbPanacheResourceTest.kt b/integration-tests/mongodb-panache-kotlin/src/test/kotlin/io/quarkus/it/mongodb/panache/reactive/ReactiveMongodbPanacheResourceTest.kt index 9e49473b1cc56..7b5c7927528fa 100644 --- a/integration-tests/mongodb-panache-kotlin/src/test/kotlin/io/quarkus/it/mongodb/panache/reactive/ReactiveMongodbPanacheResourceTest.kt +++ b/integration-tests/mongodb-panache-kotlin/src/test/kotlin/io/quarkus/it/mongodb/panache/reactive/ReactiveMongodbPanacheResourceTest.kt @@ -29,6 +29,7 @@ import java.util.Calendar import java.util.Collections import java.util.Date import java.util.GregorianCalendar +import java.util.concurrent.atomic.LongAdder import javax.ws.rs.client.Client import javax.ws.rs.client.ClientBuilder import javax.ws.rs.client.WebTarget @@ -194,7 +195,7 @@ internal open class ReactiveMongodbPanacheResourceTest { val client: Client = ClientBuilder.newClient() val target: WebTarget = client.target("http://localhost:8081$endpoint/stream") SseEventSource.target(target).build().use { source -> - val nbEvent = IntegerAdder() + val nbEvent = LongAdder() source.register { inboundSseEvent -> try { val theBook: BookDTO = objectMapper.readValue(inboundSseEvent.readData(), BookDTO::class.java) @@ -205,7 +206,7 @@ internal open class ReactiveMongodbPanacheResourceTest { nbEvent.increment() } source.open() - await().atMost(Duration.ofSeconds(10)).until({ nbEvent.count() == 3 }) + await().atMost(Duration.ofSeconds(10)).until({ nbEvent.sum() == 3L }) } // delete all @@ -337,15 +338,6 @@ internal open class ReactiveMongodbPanacheResourceTest { return cal.getTime() } - private class IntegerAdder { - var cpt = 0 - fun increment() { - cpt++ - } - - fun count(): Int = cpt - } - @Test fun testMoreEntityFunctionalities() { get("/test/reactive/entity").then().statusCode(200) diff --git a/integration-tests/mongodb-panache/pom.xml b/integration-tests/mongodb-panache/pom.xml index 3812a0c5be62f..79913ecbe883b 100644 --- a/integration-tests/mongodb-panache/pom.xml +++ b/integration-tests/mongodb-panache/pom.xml @@ -17,11 +17,7 @@ io.quarkus - quarkus-resteasy-jackson - - - io.quarkus - quarkus-resteasy-mutiny + quarkus-resteasy-reactive-jackson io.quarkus @@ -29,7 +25,7 @@ io.quarkus - quarkus-rest-client + quarkus-rest-client-reactive io.quarkus @@ -95,20 +91,7 @@ io.quarkus - quarkus-rest-client-deployment - ${project.version} - pom - test - - - * - * - - - - - io.quarkus - quarkus-resteasy-jackson-deployment + quarkus-rest-client-reactive-deployment ${project.version} pom test @@ -121,7 +104,7 @@ io.quarkus - quarkus-resteasy-mutiny-deployment + quarkus-resteasy-reactive-jackson-deployment ${project.version} pom test diff --git a/integration-tests/mongodb-panache/src/main/java/io/quarkus/it/mongodb/panache/reactive/book/ReactiveBookEntityResource.java b/integration-tests/mongodb-panache/src/main/java/io/quarkus/it/mongodb/panache/reactive/book/ReactiveBookEntityResource.java index e703313956870..3ca75ea134912 100644 --- a/integration-tests/mongodb-panache/src/main/java/io/quarkus/it/mongodb/panache/reactive/book/ReactiveBookEntityResource.java +++ b/integration-tests/mongodb-panache/src/main/java/io/quarkus/it/mongodb/panache/reactive/book/ReactiveBookEntityResource.java @@ -11,7 +11,7 @@ import org.bson.types.ObjectId; import org.jboss.logging.Logger; -import org.jboss.resteasy.annotations.SseElementType; +import org.jboss.resteasy.reactive.RestStreamElementType; import org.reactivestreams.Publisher; import io.quarkus.panache.common.Parameters; @@ -40,7 +40,7 @@ public Uni> getBooks(@QueryParam("sort") String sort) { @GET @Path("/stream") @Produces(MediaType.SERVER_SENT_EVENTS) - @SseElementType(MediaType.APPLICATION_JSON) + @RestStreamElementType(MediaType.APPLICATION_JSON) public Publisher streamBooks(@QueryParam("sort") String sort) { if (sort != null) { return ReactiveBookEntity.streamAll(Sort.ascending(sort)); diff --git a/integration-tests/mongodb-panache/src/main/java/io/quarkus/it/mongodb/panache/reactive/book/ReactiveBookRepositoryResource.java b/integration-tests/mongodb-panache/src/main/java/io/quarkus/it/mongodb/panache/reactive/book/ReactiveBookRepositoryResource.java index ddc3b86e4322b..25e21f975d6d4 100644 --- a/integration-tests/mongodb-panache/src/main/java/io/quarkus/it/mongodb/panache/reactive/book/ReactiveBookRepositoryResource.java +++ b/integration-tests/mongodb-panache/src/main/java/io/quarkus/it/mongodb/panache/reactive/book/ReactiveBookRepositoryResource.java @@ -12,7 +12,7 @@ import org.bson.types.ObjectId; import org.jboss.logging.Logger; -import org.jboss.resteasy.annotations.SseElementType; +import org.jboss.resteasy.reactive.RestStreamElementType; import org.reactivestreams.Publisher; import io.quarkus.it.mongodb.panache.book.Book; @@ -44,7 +44,7 @@ public Uni> getBooks(@QueryParam("sort") String sort) { @GET @Path("/stream") @Produces(MediaType.SERVER_SENT_EVENTS) - @SseElementType(MediaType.APPLICATION_JSON) + @RestStreamElementType(MediaType.APPLICATION_JSON) public Publisher streamBooks(@QueryParam("sort") String sort) { if (sort != null) { return reactiveBookRepository.streamAll(Sort.ascending(sort)); diff --git a/integration-tests/mongodb-panache/src/test/java/io/quarkus/it/mongodb/panache/reactive/ReactiveMongodbPanacheResourceTest.java b/integration-tests/mongodb-panache/src/test/java/io/quarkus/it/mongodb/panache/reactive/ReactiveMongodbPanacheResourceTest.java index cdc80cc28089e..5aaa63a435579 100644 --- a/integration-tests/mongodb-panache/src/test/java/io/quarkus/it/mongodb/panache/reactive/ReactiveMongodbPanacheResourceTest.java +++ b/integration-tests/mongodb-panache/src/test/java/io/quarkus/it/mongodb/panache/reactive/ReactiveMongodbPanacheResourceTest.java @@ -14,6 +14,7 @@ import java.util.Date; import java.util.GregorianCalendar; import java.util.List; +import java.util.concurrent.atomic.LongAdder; import javax.ws.rs.client.Client; import javax.ws.rs.client.ClientBuilder; @@ -197,7 +198,7 @@ private void callReactiveBookEndpoint(String endpoint) throws InterruptedExcepti Client client = ClientBuilder.newClient(); WebTarget target = client.target("http://localhost:8081" + endpoint + "/stream"); try (SseEventSource source = SseEventSource.target(target).build()) { - final IntegerAdder nbEvent = new IntegerAdder(); + final LongAdder nbEvent = new LongAdder(); source.register((inboundSseEvent) -> { try { BookDTO theBook = objectMapper.readValue(inboundSseEvent.readData(), BookDTO.class); @@ -208,7 +209,7 @@ private void callReactiveBookEndpoint(String endpoint) throws InterruptedExcepti nbEvent.increment(); }); source.open(); - await().atMost(Duration.ofSeconds(10)).until(() -> nbEvent.count() == 3); + await().atMost(Duration.ofSeconds(10)).until(() -> nbEvent.sum() == 3); } //delete all @@ -343,18 +344,6 @@ private Date yearToDate(int year) { return cal.getTime(); } - private static class IntegerAdder { - int cpt = 0; - - public void increment() { - cpt++; - } - - public int count() { - return cpt; - } - } - @Test public void testMoreEntityFunctionalities() { get("/test/reactive/entity").then().statusCode(200);