diff --git a/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/test/java/io/quarkus/resteasy/reactive/server/test/StringTestHTTPResourceWithPathParamsTest.java b/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/test/java/io/quarkus/resteasy/reactive/server/test/StringTestHTTPResourceWithPathParamsTest.java new file mode 100644 index 0000000000000..126882c3d1872 --- /dev/null +++ b/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/test/java/io/quarkus/resteasy/reactive/server/test/StringTestHTTPResourceWithPathParamsTest.java @@ -0,0 +1,45 @@ +package io.quarkus.resteasy.reactive.server.test; + +import static io.restassured.RestAssured.given; +import static org.hamcrest.Matchers.equalTo; + +import jakarta.ws.rs.GET; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.PathParam; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.core.MediaType; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; + +import io.quarkus.test.QuarkusUnitTest; +import io.quarkus.test.common.http.TestHTTPEndpoint; +import io.quarkus.test.common.http.TestHTTPResource; + +public class StringTestHTTPResourceWithPathParamsTest { + + @RegisterExtension + static final QuarkusUnitTest test = new QuarkusUnitTest().withApplicationRoot((jar) -> jar.addClass(UserResource.class)); + + @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).body(equalTo(String.format("Order (%d) of user (%d)", userId, orderId))); + } + + @Path("/user") + public static class UserResource { + @Path("{userId}/order/{orderId}") + @GET + @Produces(MediaType.TEXT_PLAIN) + public String getUserOrder(@PathParam("userId") int userId, @PathParam("orderId") int orderId) { + return String.format("Order (%d) of user (%d)", userId, orderId); + } + } +} diff --git a/test-framework/common/src/main/java/io/quarkus/test/common/http/StringTestHTTPResourceProvider.java b/test-framework/common/src/main/java/io/quarkus/test/common/http/StringTestHTTPResourceProvider.java index 70ad7c5b06774..3f6e05cd1b37b 100644 --- a/test-framework/common/src/main/java/io/quarkus/test/common/http/StringTestHTTPResourceProvider.java +++ b/test-framework/common/src/main/java/io/quarkus/test/common/http/StringTestHTTPResourceProvider.java @@ -1,7 +1,6 @@ package io.quarkus.test.common.http; import java.lang.reflect.Field; -import java.net.URI; public class StringTestHTTPResourceProvider implements TestHTTPResourceProvider { @Override @@ -10,7 +9,7 @@ public Class getProvidedType() { } @Override - public String provide(URI testUri, Field field) { - return testUri.toASCIIString(); + public String provide(String testUri, Field field) { + return testUri; } } diff --git a/test-framework/common/src/main/java/io/quarkus/test/common/http/TestHTTPResourceManager.java b/test-framework/common/src/main/java/io/quarkus/test/common/http/TestHTTPResourceManager.java index 7b9d36d30c2bc..8e177e77ce235 100644 --- a/test-framework/common/src/main/java/io/quarkus/test/common/http/TestHTTPResourceManager.java +++ b/test-framework/common/src/main/java/io/quarkus/test/common/http/TestHTTPResourceManager.java @@ -1,7 +1,6 @@ package io.quarkus.test.common.http; import java.lang.reflect.Field; -import java.net.URI; import java.util.Collections; import java.util.HashMap; import java.util.List; @@ -102,7 +101,7 @@ public static void inject(Object testCase, List, String>> endp } f.setAccessible(true); try { - f.set(testCase, provider.provide(new URI(val), f)); + f.set(testCase, provider.provide(val, f)); } catch (Exception e) { throw new RuntimeException(e); } diff --git a/test-framework/common/src/main/java/io/quarkus/test/common/http/TestHTTPResourceProvider.java b/test-framework/common/src/main/java/io/quarkus/test/common/http/TestHTTPResourceProvider.java index 1f73b50332566..4f5457ef51604 100644 --- a/test-framework/common/src/main/java/io/quarkus/test/common/http/TestHTTPResourceProvider.java +++ b/test-framework/common/src/main/java/io/quarkus/test/common/http/TestHTTPResourceProvider.java @@ -1,7 +1,6 @@ package io.quarkus.test.common.http; import java.lang.reflect.Field; -import java.net.URI; public interface TestHTTPResourceProvider { @@ -13,6 +12,6 @@ public interface TestHTTPResourceProvider { * Note that there is no need to directly call set() on the field, it is only provided * to allow you to examine the generic type and any additional annotations. */ - T provide(URI testUri, Field field); + T provide(String testUri, Field field); } diff --git a/test-framework/common/src/main/java/io/quarkus/test/common/http/URITestHTTPResourceProvider.java b/test-framework/common/src/main/java/io/quarkus/test/common/http/URITestHTTPResourceProvider.java index 6125458e06800..6032d83b735d4 100644 --- a/test-framework/common/src/main/java/io/quarkus/test/common/http/URITestHTTPResourceProvider.java +++ b/test-framework/common/src/main/java/io/quarkus/test/common/http/URITestHTTPResourceProvider.java @@ -2,6 +2,7 @@ import java.lang.reflect.Field; import java.net.URI; +import java.net.URISyntaxException; public class URITestHTTPResourceProvider implements TestHTTPResourceProvider { @Override @@ -10,7 +11,11 @@ public Class getProvidedType() { } @Override - public URI provide(URI testUri, Field field) { - return testUri; + public URI provide(String testUri, Field field) { + try { + return new URI(testUri); + } catch (URISyntaxException e) { + throw new RuntimeException(e); + } } } diff --git a/test-framework/common/src/main/java/io/quarkus/test/common/http/URLTestHTTPResourceProvider.java b/test-framework/common/src/main/java/io/quarkus/test/common/http/URLTestHTTPResourceProvider.java index 113ed4e231f1c..d57b8e1f2a9dc 100644 --- a/test-framework/common/src/main/java/io/quarkus/test/common/http/URLTestHTTPResourceProvider.java +++ b/test-framework/common/src/main/java/io/quarkus/test/common/http/URLTestHTTPResourceProvider.java @@ -3,6 +3,7 @@ import java.lang.reflect.Field; import java.net.MalformedURLException; import java.net.URI; +import java.net.URISyntaxException; import java.net.URL; public class URLTestHTTPResourceProvider implements TestHTTPResourceProvider { @@ -12,10 +13,10 @@ public Class getProvidedType() { } @Override - public URL provide(URI testUri, Field field) { + public URL provide(String testUri, Field field) { try { - return testUri.toURL(); - } catch (MalformedURLException e) { + return new URI(testUri).toURL(); + } catch (MalformedURLException | URISyntaxException e) { throw new RuntimeException(e); } }