-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1622 from mocenas/rest_client_test
Add test coverage for issue in PR 37268.
- Loading branch information
Showing
5 changed files
with
101 additions
and
0 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
...st-client-reactive/src/main/java/io/quarkus/ts/http/restclient/reactive/HeaderClient.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,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(); | ||
} |
31 changes: 31 additions & 0 deletions
31
...tive/src/main/java/io/quarkus/ts/http/restclient/reactive/filter/VersionHeaderFilter.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,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"); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...main/java/io/quarkus/ts/http/restclient/reactive/resources/HeadersReflectionResource.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,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; | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
...ctive/src/main/java/io/quarkus/ts/http/restclient/reactive/resources/HeadersResource.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,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(); | ||
} | ||
} |
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