forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support
@Encoded
annotation on REST Client Reactive
These changes add support for the `@Encoded` annotation for PATH and QUERY params. As stated in the Encoded annotation javadocs, we can use this annotation at class and method level too, so we can use it in REST Client reactive like this. Fix quarkusio#23961
- Loading branch information
Showing
13 changed files
with
417 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
.../test/java/io/quarkus/rest/client/reactive/encoded/ClientWithFormParamAndEncodedTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package io.quarkus.rest.client.reactive.encoded; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import java.net.URI; | ||
|
||
import org.eclipse.microprofile.rest.client.RestClientBuilder; | ||
import org.jboss.resteasy.reactive.server.core.ResteasyReactiveRequestContext; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.rest.client.reactive.beanparam.BeanFormParamTest; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
import io.quarkus.test.common.http.TestHTTPResource; | ||
import jakarta.ws.rs.BeanParam; | ||
import jakarta.ws.rs.Consumes; | ||
import jakarta.ws.rs.Encoded; | ||
import jakarta.ws.rs.FormParam; | ||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.POST; | ||
import jakarta.ws.rs.Path; | ||
import jakarta.ws.rs.QueryParam; | ||
import jakarta.ws.rs.core.Context; | ||
import jakarta.ws.rs.core.MediaType; | ||
import jakarta.ws.rs.core.UriInfo; | ||
|
||
public class ClientWithFormParamAndEncodedTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest TEST = new QuarkusUnitTest(); | ||
|
||
@TestHTTPResource | ||
URI baseUri; | ||
|
||
@Test | ||
public void testClientWithoutEncoded() { | ||
ClientWithoutEncoded client = RestClientBuilder.newBuilder() | ||
.baseUri(baseUri) | ||
.build(ClientWithoutEncoded.class); | ||
assertEquals("received %24value-%24value", client.call(new BeanWithFormParams("%24value"))); | ||
} | ||
|
||
public static class BeanWithFormParams { | ||
private final String value; | ||
|
||
public BeanWithFormParams(String value) { | ||
this.value = value; | ||
} | ||
|
||
@FormParam("param1") | ||
public String getWithoutEncoded() { | ||
return value; | ||
} | ||
|
||
@Encoded | ||
@FormParam("param2") | ||
public String getWithEncoded() { | ||
return value; | ||
} | ||
} | ||
|
||
@Path("/server") | ||
public interface ClientWithoutEncoded { | ||
@POST | ||
@Consumes(MediaType.APPLICATION_FORM_URLENCODED) | ||
String call(@BeanParam BeanWithFormParams beanParam); | ||
} | ||
|
||
@Path("/server") | ||
static class Resource { | ||
@POST | ||
public String post(@FormParam("param1") String param1, @FormParam("param2") String param2, | ||
@Context ResteasyReactiveRequestContext context) { | ||
return String.format("received %s-%s", param1, param2); | ||
} | ||
} | ||
} |
Oops, something went wrong.