forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix streaming of json strings in RESTEasy Reactive
Fixes: quarkusio#18043
- Loading branch information
1 parent
93cd6a8
commit a82a205
Showing
8 changed files
with
110 additions
and
6 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
...ent/src/test/java/io/quarkus/resteasy/reactive/jackson/deployment/test/StreamingTest.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,45 @@ | ||
package io.quarkus.resteasy.reactive.jackson.deployment.test; | ||
|
||
import static io.restassured.RestAssured.when; | ||
|
||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.Produces; | ||
import javax.ws.rs.core.MediaType; | ||
|
||
import org.hamcrest.CoreMatchers; | ||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
import io.smallrye.mutiny.Multi; | ||
|
||
public class StreamingTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest config = new QuarkusUnitTest() | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) | ||
.addClasses(StreamingResource.class)); | ||
|
||
@Test | ||
public void testSseMultiJsonString() { | ||
when().get("/test/multi") | ||
.then() | ||
.statusCode(200) | ||
.body(CoreMatchers.is("[\"Hello\",\"Hola\"]")); | ||
} | ||
|
||
@Path("/test") | ||
public static class StreamingResource { | ||
|
||
@GET | ||
@Path("multi") | ||
@Produces(MediaType.APPLICATION_JSON) | ||
public Multi<String> multi() { | ||
return Multi.createFrom().items("Hello", "Hola"); | ||
} | ||
} | ||
|
||
} |
45 changes: 45 additions & 0 deletions
45
...yment/src/test/java/io/quarkus/resteasy/reactive/jsonb/deployment/test/StreamingTest.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,45 @@ | ||
package io.quarkus.resteasy.reactive.jsonb.deployment.test; | ||
|
||
import static io.restassured.RestAssured.when; | ||
|
||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.Produces; | ||
import javax.ws.rs.core.MediaType; | ||
|
||
import org.hamcrest.CoreMatchers; | ||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
import io.smallrye.mutiny.Multi; | ||
|
||
public class StreamingTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest config = new QuarkusUnitTest() | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) | ||
.addClasses(StreamingResource.class)); | ||
|
||
@Test | ||
public void testSseMultiJsonString() { | ||
when().get("/test/multi") | ||
.then() | ||
.statusCode(200) | ||
.body(CoreMatchers.is("[\"Hello\",\"Hola\"]")); | ||
} | ||
|
||
@Path("/test") | ||
public static class StreamingResource { | ||
|
||
@GET | ||
@Path("multi") | ||
@Produces(MediaType.APPLICATION_JSON) | ||
public Multi<String> multi() { | ||
return Multi.createFrom().items("Hello", "Hola"); | ||
} | ||
} | ||
|
||
} |
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
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
10 changes: 10 additions & 0 deletions
10
...erver/runtime/src/main/java/org/jboss/resteasy/reactive/server/StreamingOutputStream.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,10 @@ | ||
package org.jboss.resteasy.reactive.server; | ||
|
||
import java.io.ByteArrayOutputStream; | ||
|
||
/** | ||
* The only reason we use this is to give MessageBodyWriter classes the ability to tell | ||
* if they are being called in a streaming context | ||
*/ | ||
public class StreamingOutputStream extends ByteArrayOutputStream { | ||
} |
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