-
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.
Add test for adding a custom response header for SSE resource method
- Loading branch information
Showing
1 changed file
with
64 additions
and
0 deletions.
There are no files selected for viewing
64 changes: 64 additions & 0 deletions
64
...va/io/quarkus/resteasy/reactive/server/test/customproviders/MultiResponseHeadersTest.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,64 @@ | ||
package io.quarkus.resteasy.reactive.server.test.customproviders; | ||
|
||
import static io.restassured.RestAssured.when; | ||
import static org.hamcrest.Matchers.equalTo; | ||
import static org.hamcrest.Matchers.stringContainsInOrder; | ||
|
||
import jakarta.ws.rs.POST; | ||
import jakarta.ws.rs.Path; | ||
import jakarta.ws.rs.Produces; | ||
import jakarta.ws.rs.core.MediaType; | ||
|
||
import org.jboss.resteasy.reactive.RestMulti; | ||
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 MultiResponseHeadersTest { | ||
|
||
@RegisterExtension | ||
static QuarkusUnitTest test = new QuarkusUnitTest() | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class).addClasses(Resource.class)); | ||
|
||
@Test | ||
public void headerAddedOnMulti() { | ||
when() | ||
.post("/multi") | ||
.then() | ||
.statusCode(200) | ||
.header("Foo", equalTo("Bar")) | ||
.body(stringContainsInOrder("hello", "world")); | ||
|
||
} | ||
|
||
@Test | ||
public void headerAddedOnSseMulti() { | ||
when() | ||
.post("/sse-multi") | ||
.then() | ||
.statusCode(200) | ||
.header("Foo", equalTo("Bar")) | ||
.body(stringContainsInOrder("hello", "world")); | ||
|
||
} | ||
|
||
@Path("") | ||
public static class Resource { | ||
@POST | ||
@Path("multi") | ||
public Multi<String> multi() { | ||
return RestMulti.fromMultiData(Multi.createFrom().items("hello", "world")).header("Foo", "Bar").build(); | ||
} | ||
|
||
@POST | ||
@Path("sse-multi") | ||
@Produces(MediaType.SERVER_SENT_EVENTS) | ||
public Multi<String> sseMulti() { | ||
return RestMulti.fromMultiData(Multi.createFrom().items("hello", "world")).header("Foo", "Bar").build(); | ||
} | ||
} | ||
} |