Skip to content

Commit

Permalink
Add empty path test to rest-client-reactive
Browse files Browse the repository at this point in the history
  • Loading branch information
kahowell committed Jun 20, 2023
1 parent 73db38a commit d0f6637
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
@@ -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);

}
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d0f6637

Please sign in to comment.