From d0f6637dd7d0260dfc715792f9a032153048e44a Mon Sep 17 00:00:00 2001 From: Kevin Howell Date: Tue, 20 Jun 2023 10:08:55 -0400 Subject: [PATCH] Add empty path test to rest-client-reactive --- .../client/reactive/ConfigurationTest.java | 11 ++++++++- .../reactive/EchoClientWithEmptyPath.java | 24 +++++++++++++++++++ .../reactive/configuration/EchoResource.java | 7 ++++++ .../configuration-test-application.properties | 1 + 4 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 extensions/resteasy-reactive/rest-client-reactive/deployment/src/test/java/io/quarkus/rest/client/reactive/EchoClientWithEmptyPath.java diff --git a/extensions/resteasy-reactive/rest-client-reactive/deployment/src/test/java/io/quarkus/rest/client/reactive/ConfigurationTest.java b/extensions/resteasy-reactive/rest-client-reactive/deployment/src/test/java/io/quarkus/rest/client/reactive/ConfigurationTest.java index 91a59964f0a99a..35c8f6e0f8c23d 100644 --- a/extensions/resteasy-reactive/rest-client-reactive/deployment/src/test/java/io/quarkus/rest/client/reactive/ConfigurationTest.java +++ b/extensions/resteasy-reactive/rest-client-reactive/deployment/src/test/java/io/quarkus/rest/client/reactive/ConfigurationTest.java @@ -23,12 +23,16 @@ public class ConfigurationTest { @RegisterExtension static final QuarkusUnitTest TEST = new QuarkusUnitTest() - .withApplicationRoot(jar -> jar.addClasses(HelloClientWithBaseUri.class, EchoResource.class)) + .withApplicationRoot( + jar -> jar.addClasses(HelloClientWithBaseUri.class, EchoResource.class, EchoClientWithEmptyPath.class)) .withConfigurationResource("configuration-test-application.properties"); @RestClient HelloClientWithBaseUri client; + @RestClient + EchoClientWithEmptyPath echoClientWithEmptyPath; + @Test void shouldHaveSingletonScope() { BeanManager beanManager = Arc.container().beanManager(); @@ -62,6 +66,11 @@ void checkClientSpecificConfigs() { verifyClientConfig(clientConfig, false); } + @Test + void emptyPathAnnotationShouldWork() { + assertThat(echoClientWithEmptyPath.echo("hello", "hello world")).isEqualTo("hello world"); + } + private void verifyClientConfig(RestClientConfig clientConfig, boolean checkExtraProperties) { assertThat(clientConfig.url).isPresent(); assertThat(clientConfig.url.get()).endsWith("/hello"); diff --git a/extensions/resteasy-reactive/rest-client-reactive/deployment/src/test/java/io/quarkus/rest/client/reactive/EchoClientWithEmptyPath.java b/extensions/resteasy-reactive/rest-client-reactive/deployment/src/test/java/io/quarkus/rest/client/reactive/EchoClientWithEmptyPath.java new file mode 100644 index 00000000000000..97cdc1f1d77e82 --- /dev/null +++ b/extensions/resteasy-reactive/rest-client-reactive/deployment/src/test/java/io/quarkus/rest/client/reactive/EchoClientWithEmptyPath.java @@ -0,0 +1,24 @@ +package io.quarkus.rest.client.reactive; + +import jakarta.ws.rs.Consumes; +import jakarta.ws.rs.GET; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.PathParam; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.QueryParam; +import jakarta.ws.rs.client.ClientRequestContext; +import jakarta.ws.rs.client.ClientResponseContext; +import jakarta.ws.rs.client.ClientResponseFilter; +import jakarta.ws.rs.core.MediaType; +import org.eclipse.microprofile.rest.client.inject.RegisterRestClient; + +@Path("") +@RegisterRestClient +public interface EchoClientWithEmptyPath { + @GET + @Produces(MediaType.TEXT_PLAIN) + @Consumes(MediaType.TEXT_PLAIN) + @Path("/{id}") + String echo(@PathParam("id") String id, @QueryParam("message") String message); + +} diff --git a/extensions/resteasy-reactive/rest-client-reactive/deployment/src/test/java/io/quarkus/rest/client/reactive/configuration/EchoResource.java b/extensions/resteasy-reactive/rest-client-reactive/deployment/src/test/java/io/quarkus/rest/client/reactive/configuration/EchoResource.java index 5cf4bf863e95f7..6f9acf7db2b871 100644 --- a/extensions/resteasy-reactive/rest-client-reactive/deployment/src/test/java/io/quarkus/rest/client/reactive/configuration/EchoResource.java +++ b/extensions/resteasy-reactive/rest-client-reactive/deployment/src/test/java/io/quarkus/rest/client/reactive/configuration/EchoResource.java @@ -1,9 +1,11 @@ package io.quarkus.rest.client.reactive.configuration; import jakarta.ws.rs.Consumes; +import jakarta.ws.rs.GET; import jakarta.ws.rs.POST; import jakarta.ws.rs.Path; import jakarta.ws.rs.Produces; +import jakarta.ws.rs.QueryParam; import jakarta.ws.rs.core.Context; import jakarta.ws.rs.core.HttpHeaders; import jakarta.ws.rs.core.MediaType; @@ -21,4 +23,9 @@ public String echo(String name, @Context Request request, @Context HttpHeaders h return (message != null ? message : "hello") + (comma != null ? comma : "_") + " " + name + (suffix != null ? suffix : ""); } + + @GET + public String echoQueryParam(@QueryParam("message") String message) { + return message; + } } diff --git a/extensions/resteasy-reactive/rest-client-reactive/deployment/src/test/resources/configuration-test-application.properties b/extensions/resteasy-reactive/rest-client-reactive/deployment/src/test/resources/configuration-test-application.properties index 5d886106d9c306..3a63d5e4143817 100644 --- a/extensions/resteasy-reactive/rest-client-reactive/deployment/src/test/resources/configuration-test-application.properties +++ b/extensions/resteasy-reactive/rest-client-reactive/deployment/src/test/resources/configuration-test-application.properties @@ -18,6 +18,7 @@ quarkus.rest-client."io.quarkus.rest.client.reactive.HelloClientWithBaseUri".kee quarkus.rest-client."io.quarkus.rest.client.reactive.HelloClientWithBaseUri".max-redirects=5 quarkus.rest-client."io.quarkus.rest.client.reactive.HelloClientWithBaseUri".headers.message=hi quarkus.rest-client."io.quarkus.rest.client.reactive.HelloClientWithBaseUri".headers.suffix=! +quarkus.rest-client."io.quarkus.rest.client.reactive.EchoClientWithEmptyPath".url=http://localhost:${quarkus.http.test-port:8081}/ # client identified by a configKey quarkus.rest-client.client-prefix.url=http://localhost:${quarkus.http.test-port:8081}/hello