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.
Fix InputStream handling as Response entity in RESTEasy Classic
Fixes: quarkusio#21602
- Loading branch information
Showing
4 changed files
with
137 additions
and
3 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
.../test/java/io/quarkus/resteasy/test/InputStreamResponseLargePayloadWithRemainderTest.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,43 @@ | ||
package io.quarkus.resteasy.test; | ||
|
||
import static io.restassured.RestAssured.when; | ||
|
||
import java.io.ByteArrayInputStream; | ||
import java.nio.charset.StandardCharsets; | ||
|
||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.Produces; | ||
import javax.ws.rs.core.Response; | ||
|
||
import org.hamcrest.Matchers; | ||
import org.jboss.shrinkwrap.api.asset.StringAsset; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class InputStreamResponseLargePayloadWithRemainderTest { | ||
|
||
@RegisterExtension | ||
static QuarkusUnitTest runner = new QuarkusUnitTest() | ||
.withApplicationRoot((jar) -> jar | ||
.addClasses(RootResource.class) | ||
.addAsResource(new StringAsset("quarkus.resteasy.vertx.response-buffer-size=11\n"), | ||
"application.properties")); | ||
|
||
@Test | ||
public void test() { | ||
when().get("/test").then().body(Matchers.is("Hello World!")); | ||
} | ||
|
||
@Path("test") | ||
public static class TestResource { | ||
|
||
@Produces("text/plain") | ||
@GET | ||
public Response test() { | ||
return Response.ok(new ByteArrayInputStream("Hello World!".getBytes(StandardCharsets.UTF_8))).build(); | ||
} | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
...st/java/io/quarkus/resteasy/test/InputStreamResponseLargePayloadWithoutRemainderTest.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,43 @@ | ||
package io.quarkus.resteasy.test; | ||
|
||
import static io.restassured.RestAssured.when; | ||
|
||
import java.io.ByteArrayInputStream; | ||
import java.nio.charset.StandardCharsets; | ||
|
||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.Produces; | ||
import javax.ws.rs.core.Response; | ||
|
||
import org.hamcrest.Matchers; | ||
import org.jboss.shrinkwrap.api.asset.StringAsset; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class InputStreamResponseLargePayloadWithoutRemainderTest { | ||
|
||
@RegisterExtension | ||
static QuarkusUnitTest runner = new QuarkusUnitTest() | ||
.withApplicationRoot((jar) -> jar | ||
.addClasses(RootResource.class) | ||
.addAsResource(new StringAsset("quarkus.resteasy.vertx.response-buffer-size=3\n"), | ||
"application.properties")); | ||
|
||
@Test | ||
public void test() { | ||
when().get("/test").then().body(Matchers.is("Hello World!")); | ||
} | ||
|
||
@Path("test") | ||
public static class TestResource { | ||
|
||
@Produces("text/plain") | ||
@GET | ||
public Response test() { | ||
return Response.ok(new ByteArrayInputStream("Hello World!".getBytes(StandardCharsets.UTF_8))).build(); | ||
} | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
...c/resteasy/deployment/src/test/java/io/quarkus/resteasy/test/InputStreamResponseTest.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,40 @@ | ||
package io.quarkus.resteasy.test; | ||
|
||
import static io.restassured.RestAssured.when; | ||
|
||
import java.io.ByteArrayInputStream; | ||
import java.nio.charset.StandardCharsets; | ||
|
||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.Produces; | ||
import javax.ws.rs.core.Response; | ||
|
||
import org.hamcrest.Matchers; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class InputStreamResponseTest { | ||
|
||
@RegisterExtension | ||
static QuarkusUnitTest runner = new QuarkusUnitTest() | ||
.withApplicationRoot((jar) -> jar | ||
.addClasses(RootResource.class)); | ||
|
||
@Test | ||
public void test() { | ||
when().get("/test").then().body(Matchers.is("Hello World")); | ||
} | ||
|
||
@Path("test") | ||
public static class TestResource { | ||
|
||
@Produces("text/plain") | ||
@GET | ||
public Response test() { | ||
return Response.ok(new ByteArrayInputStream("Hello World".getBytes(StandardCharsets.UTF_8))).build(); | ||
} | ||
} | ||
} |
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