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.
Prevent duplicate HTTP headers when WriterInterceptor is used
Fixes: quarkusio#27325
- Loading branch information
1 parent
cc9e7e2
commit 1cca273
Showing
2 changed files
with
63 additions
and
0 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
61 changes: 61 additions & 0 deletions
61
...s/resteasy/reactive/server/vertx/test/response/CustomHeadersAndWriterInterceptorTest.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,61 @@ | ||
package org.jboss.resteasy.reactive.server.vertx.test.response; | ||
|
||
import static io.restassured.RestAssured.when; | ||
import static org.assertj.core.api.Assertions.*; | ||
import static org.hamcrest.Matchers.is; | ||
|
||
import io.restassured.http.Headers; | ||
import java.io.IOException; | ||
import java.util.Date; | ||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.Produces; | ||
import javax.ws.rs.WebApplicationException; | ||
import javax.ws.rs.core.MediaType; | ||
import javax.ws.rs.core.Response; | ||
import javax.ws.rs.ext.Provider; | ||
import javax.ws.rs.ext.WriterInterceptor; | ||
import javax.ws.rs.ext.WriterInterceptorContext; | ||
import org.jboss.resteasy.reactive.server.vertx.test.framework.ResteasyReactiveUnitTest; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
public class CustomHeadersAndWriterInterceptorTest { | ||
|
||
@RegisterExtension | ||
static ResteasyReactiveUnitTest runner = new ResteasyReactiveUnitTest() | ||
.withApplicationRoot((jar) -> jar | ||
.addClasses(TestResource.class, DummyWriterInterceptor.class)); | ||
|
||
@Test | ||
void testResponseHeaders() { | ||
Headers headers = when() | ||
.get("/test") | ||
.then() | ||
.statusCode(200) | ||
.header("etag", is("0")) | ||
.extract().headers(); | ||
assertThat(headers.getList("etag")).hasSize(1); | ||
assertThat(headers.getList("Last-Modified")).hasSize(1); | ||
} | ||
|
||
@Path("/test") | ||
public static class TestResource { | ||
|
||
@GET | ||
@Produces(MediaType.TEXT_PLAIN) | ||
public Response hello() { | ||
return Response.ok("123").lastModified(new Date()).header("etag", 0).build(); | ||
} | ||
} | ||
|
||
@Provider | ||
public static class DummyWriterInterceptor implements WriterInterceptor { | ||
|
||
@Override | ||
public void aroundWriteTo(WriterInterceptorContext context) throws IOException, WebApplicationException { | ||
context.proceed(); | ||
} | ||
} | ||
|
||
} |