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.
Register the client response builder
Fixes quarkusio#19557
- Loading branch information
1 parent
8445d00
commit 72f4bf7
Showing
2 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
78 changes: 78 additions & 0 deletions
78
...yment/src/test/java/io/quarkus/jaxrs/client/reactive/deployment/test/FailureTestCase.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,78 @@ | ||
package io.quarkus.jaxrs.client.reactive.deployment.test; | ||
|
||
import java.net.URL; | ||
|
||
import javax.enterprise.event.Observes; | ||
import javax.ws.rs.WebApplicationException; | ||
import javax.ws.rs.client.Client; | ||
import javax.ws.rs.client.ClientBuilder; | ||
import javax.ws.rs.client.ClientResponseContext; | ||
import javax.ws.rs.core.Response; | ||
import javax.ws.rs.ext.Provider; | ||
|
||
import org.jboss.resteasy.reactive.client.spi.ResteasyReactiveClientRequestContext; | ||
import org.jboss.resteasy.reactive.client.spi.ResteasyReactiveClientResponseFilter; | ||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
import io.quarkus.test.common.http.TestHTTPResource; | ||
import io.vertx.core.Handler; | ||
import io.vertx.ext.web.Router; | ||
import io.vertx.ext.web.RoutingContext; | ||
|
||
public class FailureTestCase { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest config = new QuarkusUnitTest() | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) | ||
.addClasses(Endpoint.class)); | ||
|
||
@TestHTTPResource | ||
URL url; | ||
|
||
private Client client; | ||
|
||
@BeforeEach | ||
public void before() { | ||
client = ClientBuilder.newClient().register(TestClientResponseFilter.class); | ||
} | ||
|
||
@AfterEach | ||
public void after() { | ||
client.close(); | ||
} | ||
|
||
@Test | ||
public void test() { | ||
Assertions.assertThrows(WebApplicationException.class, | ||
() -> client.target(url.toExternalForm() + "/hello").request().get()); | ||
} | ||
|
||
public static class Endpoint { | ||
|
||
public void setup(@Observes Router router) { | ||
router.route("/hello").handler(new Handler<RoutingContext>() { | ||
@Override | ||
public void handle(RoutingContext event) { | ||
event.response().end(); | ||
} | ||
}); | ||
} | ||
} | ||
|
||
@Provider | ||
public static class TestClientResponseFilter implements ResteasyReactiveClientResponseFilter { | ||
|
||
@Override | ||
public void filter(ResteasyReactiveClientRequestContext requestContext, ClientResponseContext responseContext) { | ||
//make sure the response builder works with no server components installed | ||
throw new WebApplicationException(Response.status(500).build()); | ||
} | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...esources/META-INF/services/org.jboss.resteasy.reactive.common.core.ResponseBuilderFactory
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 @@ | ||
io.quarkus.jaxrs.client.reactive.runtime.ClientResponseBuilderFactory |