-
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.
Browse files
Browse the repository at this point in the history
Fix issue where RESTEasy Reactive kept incorrect media type state
- Loading branch information
Showing
2 changed files
with
69 additions
and
6 deletions.
There are no files selected for viewing
63 changes: 63 additions & 0 deletions
63
...src/test/java/io/quarkus/resteasy/reactive/server/test/mediatype/ContentTypeCaseTest.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,63 @@ | ||
package io.quarkus.resteasy.reactive.server.test.mediatype; | ||
|
||
import static io.restassured.RestAssured.given; | ||
import static org.hamcrest.Matchers.is; | ||
|
||
import java.util.function.Supplier; | ||
|
||
import javax.ws.rs.GET; | ||
import javax.ws.rs.HeaderParam; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.core.MediaType; | ||
import javax.ws.rs.core.Response; | ||
|
||
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; | ||
|
||
public class ContentTypeCaseTest { | ||
|
||
@RegisterExtension | ||
static QuarkusUnitTest test = new QuarkusUnitTest() | ||
.setArchiveProducer(new Supplier<>() { | ||
@Override | ||
public JavaArchive get() { | ||
return ShrinkWrap.create(JavaArchive.class) | ||
.addClasses(HelloResource.class); | ||
} | ||
}); | ||
|
||
@Test | ||
public void test() { | ||
given().header("test", "TeXt/Plain").get("/hello") | ||
.then() | ||
.statusCode(200) | ||
.contentType("text/plain") | ||
.body(is("text/plain")); | ||
|
||
given().header("test", "text/plain").get("/hello") | ||
.then() | ||
.statusCode(200) | ||
.contentType("text/plain") | ||
.body(is("text/plain")); | ||
|
||
given().header("test", "TEXT/PLAIN").get("/hello") | ||
.then() | ||
.statusCode(200) | ||
.contentType("text/plain") | ||
.body(is("text/plain")); | ||
} | ||
|
||
@Path("hello") | ||
public static class HelloResource { | ||
|
||
@GET | ||
public Response hello(@HeaderParam("test") String contentType) { | ||
MediaType mediaType = MediaType.valueOf(contentType); | ||
return Response.ok(mediaType.toString()).header("content-type", mediaType).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