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.
Merge pull request quarkusio#44816 from geoand/quarkusio#44813
Introduce property to disable default mapper per REST Client
- Loading branch information
Showing
8 changed files
with
233 additions
and
9 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
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
68 changes: 68 additions & 0 deletions
68
...rc/test/java/io/quarkus/rest/client/reactive/error/GlobalExceptionMapperDisabledTest.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,68 @@ | ||
package io.quarkus.rest.client.reactive.error; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import java.net.URI; | ||
|
||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.Path; | ||
import jakarta.ws.rs.core.Response; | ||
|
||
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.rest.client.reactive.QuarkusRestClientBuilder; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
import io.quarkus.test.common.http.TestHTTPResource; | ||
|
||
public class GlobalExceptionMapperDisabledTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest TEST = new QuarkusUnitTest() | ||
.withApplicationRoot((jar) -> jar | ||
.addClasses(Client.class, Resource.class)) | ||
.overrideRuntimeConfigKey("quarkus.rest-client.test.url", "${test.url}") | ||
.overrideRuntimeConfigKey("microprofile.rest.client.disable.default.mapper", "true"); | ||
|
||
@RestClient | ||
Client client; | ||
|
||
@TestHTTPResource | ||
URI baseUri; | ||
|
||
@Test | ||
void testDeclarativeClient() { | ||
Response response = client.get(); | ||
assertThat(response.getStatus()).isEqualTo(404); | ||
} | ||
|
||
@Test | ||
void testProgrammaticClient() { | ||
OtherClient otherClient = QuarkusRestClientBuilder.newBuilder().baseUri(baseUri).build(OtherClient.class); | ||
Response response = otherClient.get(); | ||
assertThat(response.getStatus()).isEqualTo(404); | ||
} | ||
|
||
@Path("/error") | ||
public static class Resource { | ||
@GET | ||
public Response returnError() { | ||
return Response.status(404).build(); | ||
} | ||
} | ||
|
||
@Path("/error") | ||
@RegisterRestClient(configKey = "test") | ||
public interface Client { | ||
@GET | ||
Response get(); | ||
} | ||
|
||
@Path("/error") | ||
public interface OtherClient { | ||
@GET | ||
Response get(); | ||
} | ||
} |
87 changes: 87 additions & 0 deletions
87
...test/java/io/quarkus/rest/client/reactive/error/PerClientExceptionMapperDisabledTest.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,87 @@ | ||
package io.quarkus.rest.client.reactive.error; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.assertj.core.api.Assertions.assertThatThrownBy; | ||
|
||
import java.net.URI; | ||
|
||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.Path; | ||
import jakarta.ws.rs.WebApplicationException; | ||
import jakarta.ws.rs.core.Response; | ||
|
||
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.rest.client.reactive.QuarkusRestClientBuilder; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
import io.quarkus.test.common.http.TestHTTPResource; | ||
|
||
public class PerClientExceptionMapperDisabledTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest TEST = new QuarkusUnitTest() | ||
.withApplicationRoot((jar) -> jar | ||
.addClasses(Client.class, Resource.class)) | ||
.overrideRuntimeConfigKey("quarkus.rest-client.test.url", "${test.url}") | ||
.overrideRuntimeConfigKey("quarkus.rest-client.test.disable-default-mapper", "true") | ||
.overrideRuntimeConfigKey("quarkus.rest-client.test2.url", "${test.url}"); | ||
|
||
@RestClient | ||
Client client; | ||
|
||
@RestClient | ||
Client2 client2; | ||
|
||
@TestHTTPResource | ||
URI baseUri; | ||
|
||
@Test | ||
void testDeclarativeClient() { | ||
Response response = client.get(); | ||
assertThat(response.getStatus()).isEqualTo(404); | ||
|
||
assertThatThrownBy(() -> client2.get()).isInstanceOf(WebApplicationException.class); | ||
} | ||
|
||
@Test | ||
void testProgrammaticClient() { | ||
OtherClient otherClient = QuarkusRestClientBuilder.newBuilder().baseUri(baseUri).disableDefaultMapper(true) | ||
.build(OtherClient.class); | ||
Response response = otherClient.get(); | ||
assertThat(response.getStatus()).isEqualTo(404); | ||
|
||
OtherClient otherClient2 = QuarkusRestClientBuilder.newBuilder().baseUri(baseUri).build(OtherClient.class); | ||
assertThatThrownBy(otherClient2::get).isInstanceOf(WebApplicationException.class); | ||
} | ||
|
||
@Path("/error") | ||
public static class Resource { | ||
@GET | ||
public Response returnError() { | ||
return Response.status(404).build(); | ||
} | ||
} | ||
|
||
@Path("/error") | ||
@RegisterRestClient(configKey = "test") | ||
public interface Client { | ||
@GET | ||
Response get(); | ||
} | ||
|
||
@Path("/error") | ||
@RegisterRestClient(configKey = "test2") | ||
public interface Client2 { | ||
@GET | ||
Response get(); | ||
} | ||
|
||
@Path("/error") | ||
public interface OtherClient { | ||
@GET | ||
Response get(); | ||
} | ||
} |
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
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