forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support sending Multi<io.vertx.mutiny.core.buffer.Buffer> in REST Client
Closes: quarkusio#20024
- Loading branch information
Showing
5 changed files
with
94 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
...eactive/deployment/src/test/java/io/quarkus/rest/client/reactive/SendMultiBufferTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package io.quarkus.rest.client.reactive; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import java.io.FileNotFoundException; | ||
import java.net.URI; | ||
|
||
import jakarta.ws.rs.POST; | ||
import jakarta.ws.rs.Path; | ||
|
||
import org.eclipse.microprofile.rest.client.RestClientBuilder; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
import io.quarkus.test.common.http.TestHTTPResource; | ||
import io.smallrye.mutiny.Multi; | ||
import io.vertx.mutiny.core.buffer.Buffer; | ||
|
||
public class SendMultiBufferTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest TEST = new QuarkusUnitTest(); | ||
|
||
@TestHTTPResource | ||
URI uri; | ||
|
||
@Test | ||
public void test() throws FileNotFoundException { | ||
Multi<io.vertx.mutiny.core.buffer.Buffer> multi = Multi.createFrom().emitter(e -> { | ||
for (int i = 0; i < 1000; i++) { | ||
e.emit(Buffer.buffer(String.format("%03d", i))); | ||
} | ||
e.complete(); | ||
}); | ||
Client client = RestClientBuilder.newBuilder().baseUri(uri).build(Client.class); | ||
|
||
long result = client.count(multi); | ||
|
||
assertEquals(3000, result); | ||
} | ||
|
||
@Path("test") | ||
public interface Client { | ||
|
||
@POST | ||
@Path("count") | ||
long count(Multi<io.vertx.mutiny.core.buffer.Buffer> multi); | ||
} | ||
|
||
@Path("test") | ||
public static class Resource { | ||
|
||
@POST | ||
@Path("count") | ||
public long count(String input) { | ||
return input.length(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters