Skip to content

Commit

Permalink
Move mongodb-panache IT to RESTEasy Reactive
Browse files Browse the repository at this point in the history
  • Loading branch information
geoand committed Dec 2, 2022
1 parent 71e0df3 commit f113510
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 39 deletions.
25 changes: 4 additions & 21 deletions integration-tests/mongodb-panache/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,15 @@
<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-jackson</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-mutiny</artifactId>
<artifactId>quarkus-resteasy-reactive-jackson</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-mongodb-panache</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-rest-client</artifactId>
<artifactId>quarkus-rest-client-reactive</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
Expand Down Expand Up @@ -95,20 +91,7 @@
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-rest-client-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-jackson-deployment</artifactId>
<artifactId>quarkus-rest-client-reactive-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
Expand All @@ -121,7 +104,7 @@
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-mutiny-deployment</artifactId>
<artifactId>quarkus-resteasy-reactive-jackson-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -40,7 +40,7 @@ public Uni<List<ReactiveBookEntity>> getBooks(@QueryParam("sort") String sort) {
@GET
@Path("/stream")
@Produces(MediaType.SERVER_SENT_EVENTS)
@SseElementType(MediaType.APPLICATION_JSON)
@RestStreamElementType(MediaType.APPLICATION_JSON)
public Publisher<ReactiveBookEntity> streamBooks(@QueryParam("sort") String sort) {
if (sort != null) {
return ReactiveBookEntity.streamAll(Sort.ascending(sort));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -44,7 +44,7 @@ public Uni<List<Book>> getBooks(@QueryParam("sort") String sort) {
@GET
@Path("/stream")
@Produces(MediaType.SERVER_SENT_EVENTS)
@SseElementType(MediaType.APPLICATION_JSON)
@RestStreamElementType(MediaType.APPLICATION_JSON)
public Publisher<Book> streamBooks(@QueryParam("sort") String sort) {
if (sort != null) {
return reactiveBookRepository.streamAll(Sort.ascending(sort));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit f113510

Please sign in to comment.