-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support media type suffixes in reactive rest client
- Loading branch information
Showing
4 changed files
with
75 additions
and
1 deletion.
There are no files selected for viewing
69 changes: 69 additions & 0 deletions
69
...eactive/deployment/src/test/java/io/quarkus/rest/client/reactive/MediaTypeSuffixTest.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,69 @@ | ||
package io.quarkus.rest.client.reactive; | ||
|
||
import static io.restassured.RestAssured.when; | ||
import static org.hamcrest.Matchers.is; | ||
|
||
import java.util.Map; | ||
|
||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.Produces; | ||
|
||
import org.eclipse.microprofile.rest.client.inject.RegisterRestClient; | ||
import org.eclipse.microprofile.rest.client.inject.RestClient; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class MediaTypeSuffixTest { | ||
|
||
private static final String CUSTOM_JSON_MEDIA_TYPE = "application/vnd.search.v1+json"; | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest TEST = new QuarkusUnitTest() | ||
.withApplicationRoot((jar) -> jar | ||
.addClasses(HelloResource.class, Client.class)) | ||
.withConfigurationResource("media-type-suffix-application.properties"); | ||
|
||
@Test | ||
public void test() { | ||
when() | ||
.get("/hello") | ||
.then() | ||
.statusCode(200) | ||
.body("foo", is("bar")); | ||
} | ||
|
||
@RegisterRestClient(configKey = "test") | ||
@Path("/hello") | ||
public interface Client { | ||
|
||
@GET | ||
@Path("/custom") | ||
@Produces(CUSTOM_JSON_MEDIA_TYPE) | ||
Map<String, Object> test(); | ||
} | ||
|
||
@Path("/hello") | ||
public static class HelloResource { | ||
|
||
private final Client client; | ||
|
||
public HelloResource(@RestClient Client client) { | ||
this.client = client; | ||
} | ||
|
||
@GET | ||
@Path("/custom") | ||
@Produces(CUSTOM_JSON_MEDIA_TYPE) | ||
public Map<String, Object> hello() { | ||
return Map.of("foo", "bar"); | ||
} | ||
|
||
@GET | ||
public Map<String, Object> test() { | ||
return client.test(); | ||
} | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...st-client-reactive/deployment/src/test/resources/media-type-suffix-application.properties
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 @@ | ||
quarkus.rest-client.test.url=http://localhost:${quarkus.http.test-port:8081} |
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
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