Skip to content

Commit

Permalink
Add test coverage for issue in PR 37268.
Browse files Browse the repository at this point in the history
  • Loading branch information
mocenas committed Jan 19, 2024
1 parent 09243b3 commit de44f1e
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package io.quarkus.ts.http.restclient.reactive;

import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;

import org.eclipse.microprofile.rest.client.inject.RegisterRestClient;

@RegisterRestClient
@Path("/headersReflection")
public interface HeaderClient {

@GET
@Path("/client")
String getClientHeader();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package io.quarkus.ts.http.restclient.reactive.filter;

import java.io.IOException;

import jakarta.ws.rs.client.ClientRequestContext;
import jakarta.ws.rs.client.ClientRequestFilter;
import jakarta.ws.rs.container.ContainerRequestContext;
import jakarta.ws.rs.container.ContainerResponseContext;
import jakarta.ws.rs.container.ContainerResponseFilter;
import jakarta.ws.rs.ext.Provider;

/**
* Used to reproduce issue in https://github.com/quarkusio/quarkus/pull/37268
* Needs to implement both ContainerResponseFilter and ClientRequestFilter to reproduce the issue,
* although ContainerResponseFilter is ignored
*/
@Provider
public class VersionHeaderFilter implements ContainerResponseFilter, ClientRequestFilter {
public VersionHeaderFilter() {
}

@Override
public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext) {
// do nothing. implements this method just because ContainerResponseFilter requires it
}

@Override
public void filter(ClientRequestContext requestContext) throws IOException {
requestContext.getHeaders().add("clientFilter", "clientFilterInvoked");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package io.quarkus.ts.http.restclient.reactive.resources;

import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;

import org.jboss.resteasy.reactive.RestHeader;

@Path("/headersReflection")
public class HeadersReflectionResource {
@GET
@Path("/client")
public String returnHeaders(@RestHeader("clientFilter") String header) {
return header;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package io.quarkus.ts.http.restclient.reactive.resources;

import java.net.URI;

import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;

import org.eclipse.microprofile.config.inject.ConfigProperty;
import org.eclipse.microprofile.rest.client.RestClientBuilder;

import io.quarkus.ts.http.restclient.reactive.HeaderClient;

@Path("/headers")
public class HeadersResource {

private final URI baseUri;

public HeadersResource(@ConfigProperty(name = "quarkus.http.port") int httpPort) {
this.baseUri = URI.create("http://localhost:" + httpPort);
}

@GET
@Path("/")
public String getClientHeader() {
HeaderClient client = RestClientBuilder
.newBuilder()
.baseUri(baseUri)
.build(HeaderClient.class);

return client.getClientHeader();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,14 @@ public void sseIndexMethodOnNativeTest() {
.body(containsString("random SSE data"));
}

@Test
@Tag("https://github.com/quarkusio/quarkus/pull/37268")
public void clientHeaderInjectionTest() {
app.given().get("/headers")
.then()
.body(containsString("clientFilterInvoked"));
}

@AfterAll
static void afterAll() {
mockServer.stop();
Expand Down

0 comments on commit de44f1e

Please sign in to comment.