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

Support @TestHTTPResource with path params #34939

Closed
Eng-Fouad opened this issue Jul 23, 2023 · 3 comments · Fixed by #34968
Closed

Support @TestHTTPResource with path params #34939

Eng-Fouad opened this issue Jul 23, 2023 · 3 comments · Fixed by #34968
Labels
area/testing kind/enhancement New feature or request
Milestone

Comments

@Eng-Fouad
Copy link
Contributor

Eng-Fouad commented Jul 23, 2023

Description

It would be nice if @TestHTTPResource (as String) supports path params, as RESTassured already supports it.
Currently, the following test throws an exception:

@QuarkusTest
public class UserTests {
    
    @TestHTTPEndpoint(UserResource.class)
    @TestHTTPResource("{userId}/order/{orderId}")
    String getUserOrderUrl;
    
    @Test
    void testGettingUserOrder() {
        int userId = 123;
        int orderId = 456;
        given().when().get(getUserOrderUrl, userId, orderId)
               .then().statusCode(200);
    }
}
Caused by:
    java.net.URISyntaxException: Illegal character in path at index 30: http://localhost:8081/user/v1/{userId}/order/{orderId}
    at java.base/java.net.URI$Parser.fail(URI.java:2963)
    at java.base/java.net.URI$Parser.checkChars(URI.java:3134)
    at java.base/java.net.URI$Parser.parseHierarchical(URI.java:3216)
    at java.base/java.net.URI$Parser.parse(URI.java:3164)
    at java.base/java.net.URI.<init>(URI.java:628)
    at io.quarkus.test.common.http.TestHTTPResourceManager.inject(TestHTTPResourceManager.java:105)
    ... 83 more

Implementation ideas

No response

@quarkus-bot
Copy link

quarkus-bot bot commented Jul 23, 2023

/cc @geoand (testing)

@geoand
Copy link
Contributor

geoand commented Jul 24, 2023

I suppose we could have something like this.

Would you be interested in contributing this feature?

@Eng-Fouad
Copy link
Contributor Author

I suppose we could have something like this.

Would you be interested in contributing this feature?

Added the PR.

geoand added a commit that referenced this issue Jul 25, 2023
Remove URI validation when `@TestHTTPResource` is injected as String
@quarkus-bot quarkus-bot bot added this to the 3.3 - main milestone Jul 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/testing kind/enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants