-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Return a null InputStream from REST Client when response is 204
This is similar to what RESTEasy Classic does Fixes: #31231
- Loading branch information
Showing
2 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
65 changes: 65 additions & 0 deletions
65
...ctive/deployment/src/test/java/io/quarkus/rest/client/reactive/NoContentResponseTest.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,65 @@ | ||
package io.quarkus.rest.client.reactive; | ||
|
||
import static io.quarkus.rest.client.reactive.RestClientTestUtil.setUrlForClass; | ||
import static org.junit.jupiter.api.Assertions.assertFalse; | ||
import static org.junit.jupiter.api.Assertions.assertNull; | ||
|
||
import java.io.InputStream; | ||
|
||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.Path; | ||
import jakarta.ws.rs.Produces; | ||
import jakarta.ws.rs.core.MediaType; | ||
import jakarta.ws.rs.core.Response; | ||
|
||
import org.eclipse.microprofile.rest.client.inject.RegisterRestClient; | ||
import org.eclipse.microprofile.rest.client.inject.RestClient; | ||
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 NoContentResponseTest { | ||
@RegisterExtension | ||
static final QuarkusUnitTest config = new QuarkusUnitTest() | ||
.withApplicationRoot((jar) -> jar | ||
.addClasses(Client.class, Resource.class) | ||
.addAsResource( | ||
new StringAsset(setUrlForClass(Client.class)), | ||
"application.properties")); | ||
|
||
@RestClient | ||
Client client; | ||
|
||
@Test | ||
public void testGetStreamNoContent() { | ||
assertNull(client.getStream()); | ||
} | ||
|
||
@Test | ||
public void testGetResponseNoContent() { | ||
Response response = client.getResponse(); | ||
assertFalse(response.hasEntity()); | ||
assertNull(response.getEntity()); | ||
} | ||
|
||
@Path("/test") | ||
@RegisterRestClient | ||
@Produces(MediaType.TEXT_PLAIN) | ||
interface Client { | ||
@GET | ||
InputStream getStream(); | ||
|
||
@GET | ||
Response getResponse(); | ||
} | ||
|
||
@Path("/test") | ||
static class Resource { | ||
@GET | ||
public Response get() { | ||
return Response.noContent().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