-
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.
Merge pull request #45492 from geoand/rest-client-global-redirect
Take follow-redirects config into account for programmatic client created
- Loading branch information
Showing
2 changed files
with
46 additions
and
2 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
.../rest/client/reactive/redirect/RedirectTestForProgrammaticClientWithGlobalConfigTest.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,44 @@ | ||
package io.quarkus.rest.client.reactive.redirect; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import java.net.URI; | ||
|
||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.Path; | ||
import jakarta.ws.rs.QueryParam; | ||
import jakarta.ws.rs.core.Response; | ||
|
||
import org.eclipse.microprofile.rest.client.RestClientBuilder; | ||
import org.eclipse.microprofile.rest.client.inject.RegisterRestClient; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
import io.quarkus.test.common.http.TestHTTPResource; | ||
|
||
public class RedirectTestForProgrammaticClientWithGlobalConfigTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest TEST = new QuarkusUnitTest() | ||
.withApplicationRoot((jar) -> jar | ||
.addClasses(Client.class, RedirectingResource.class)) | ||
.overrideRuntimeConfigKey("quarkus.rest-client.follow-redirects", "true"); | ||
|
||
@TestHTTPResource | ||
URI uri; | ||
|
||
@Test | ||
void shouldRedirect() { | ||
Client client = RestClientBuilder.newBuilder().baseUri(uri).build(Client.class); | ||
Response call = client.call(3); | ||
assertThat(call.getStatus()).isEqualTo(200); | ||
} | ||
|
||
@RegisterRestClient(configKey = "cl") | ||
@Path("/redirect/302") | ||
public interface Client { | ||
@GET | ||
Response call(@QueryParam("redirects") Integer redirects); | ||
} | ||
} |
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