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.
Take multiple Accept headers case into account in RESTEasy Reactive
Fixes: quarkusio#21559 (cherry picked from commit 3f1a599)
- Loading branch information
Showing
5 changed files
with
161 additions
and
71 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
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
59 changes: 59 additions & 0 deletions
59
.../java/org/jboss/resteasy/reactive/server/vertx/test/simple/MultipleAcceptHeadersTest.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,59 @@ | ||
package org.jboss.resteasy.reactive.server.vertx.test.simple; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import io.vertx.core.Vertx; | ||
import io.vertx.ext.web.client.WebClient; | ||
import java.util.List; | ||
import java.util.concurrent.TimeUnit; | ||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.Produces; | ||
import org.jboss.resteasy.reactive.server.vertx.test.framework.ResteasyReactiveUnitTest; | ||
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; | ||
|
||
public class MultipleAcceptHeadersTest { | ||
|
||
private static final String BODY = "{\"message\": \"hello world\"}"; | ||
|
||
@RegisterExtension | ||
static ResteasyReactiveUnitTest test = new ResteasyReactiveUnitTest() | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) | ||
.addClasses(HelloResource.class)); | ||
|
||
@Test | ||
public void matchingHeaderIsFirst() throws Exception { | ||
// the WebClient is used because RestAssured can't seem to send the 'Accept' header multiple times... | ||
WebClient client = WebClient.create(Vertx.vertx()); | ||
|
||
var response = client.get(ResteasyReactiveUnitTest.SERVER_PORT, "localhost", "/hello") | ||
.putHeader("Accept", List.of("application/xml", "application/json")).send().toCompletionStage() | ||
.toCompletableFuture().get(10, TimeUnit.SECONDS); | ||
assertThat(response.statusCode()).isEqualTo(200); | ||
assertThat(response.bodyAsString()).isEqualTo(BODY); | ||
} | ||
|
||
@Test | ||
public void matchingHeaderIsLast() throws Exception { | ||
WebClient client = WebClient.create(Vertx.vertx()); | ||
|
||
var response = client.get(ResteasyReactiveUnitTest.SERVER_PORT, "localhost", "/hello") | ||
.putHeader("Accept", List.of("application/json", "application/xml")).send().toCompletionStage() | ||
.toCompletableFuture().get(10, TimeUnit.SECONDS); | ||
assertThat(response.statusCode()).isEqualTo(200); | ||
assertThat(response.bodyAsString()).isEqualTo(BODY); | ||
} | ||
|
||
@Path("/hello") | ||
public static class HelloResource { | ||
|
||
@GET | ||
@Produces("application/json") | ||
public String hello() { | ||
return BODY; | ||
} | ||
} | ||
} |