Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow QuarkusTest to override base URL of REST client #10126

Closed
knutwannheden opened this issue Jun 19, 2020 · 6 comments
Closed

Allow QuarkusTest to override base URL of REST client #10126

knutwannheden opened this issue Jun 19, 2020 · 6 comments
Assignees
Labels
Milestone

Comments

@knutwannheden
Copy link
Contributor

knutwannheden commented Jun 19, 2020

As discussed on Zulip it could be useful if a test could override the base URL of a given REST client.

One use case (as discussed on Zulip) would be for a PACT consumer test, where the test invokes some method on a REST client (directly or indirectly through some service in the application under test), which in turn should direct its request to some PACT mock server, which records the request and returns a canned response.

As a workaround the test currently has to create a REST client manually using RestClientBuilder.

@knutwannheden knutwannheden added the kind/enhancement New feature or request label Jun 19, 2020
@geoand
Copy link
Contributor

geoand commented Jun 22, 2020

I have a technical way to do this (using a lot of reflection), but the best way for a user to use this isn't clear to me.

Would you like to open start a quarkus-dev mailing thread discussion where you will present this use case to folks and ask what they think the best API is?

Thanks

@geoand
Copy link
Contributor

geoand commented Jun 22, 2020

The simplest thing I can think of is to expose a class like RestClientTest that would have a useBaseUrl method where the user (or in the future a test extension) would set a base URL given a rest-client class (very similar to what QuarkusMock does).

WDYT?

@geoand geoand self-assigned this Jun 22, 2020
@knutwannheden
Copy link
Contributor Author

The simplest thing I can think of is to expose a class like RestClientTest that would have a useBaseUrl method where the user (or in the future a test extension) would set a base URL given a rest-client class (very similar to what QuarkusMock does).

Yes, something like that sounds good to me. I can't really say if it should be setBaseUrl() or setBaseUri(). And possibly the Test suffix in RestClientTest is a bit confusing. Maybe something like RestClientSupport?

@geoand
Copy link
Contributor

geoand commented Jun 22, 2020

Maybe something like RestClientSupport?

Yeah, makes sense

@geoand
Copy link
Contributor

geoand commented Jul 8, 2020

I'll go ahead and close this as #9933 has been merged and is part of 1.6

@geoand geoand closed this as completed Jul 8, 2020
@geoand geoand added this to the 1.6.0.Final milestone Jul 8, 2020
@stephan-strate
Copy link
Contributor

@knutwannheden How did you ultimately solve this problem? The TestProfiles need the config properties at build time, right? But the Pact mockserver url is only available at runtime. Thats why I would love to see the RestClientTestSupport implementation: geoand@888a36f#diff-a1f19a532def9abaf3e8cfbc57a80b5bf20309dc4c584db1d1b2bd3fef15415c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants