forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Execute ClientResponseFilter as part of the abort chain in JAX-RS Client
This doesn't seem to be specified by the spec or properly tested in the TCK (I actually had to disable a single test that threw a NPE), but it does seem to be what RESTEasy does Relates to: quarkusio#16702
- Loading branch information
Showing
7 changed files
with
104 additions
and
28 deletions.
There are no files selected for viewing
77 changes: 77 additions & 0 deletions
77
...t/java/io/quarkus/jaxrs/client/reactive/deployment/test/ClientResponseFilterTestCase.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.jaxrs.client.reactive.deployment.test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import java.net.URL; | ||
|
||
import javax.enterprise.event.Observes; | ||
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.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 ClientResponseFilterTestCase { | ||
|
||
@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() { | ||
Response response = client.target(url.toExternalForm() + "/hello").request().get(); | ||
assertEquals(200, response.getStatus()); | ||
} | ||
|
||
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().setStatusCode(500).end(); | ||
} | ||
}); | ||
} | ||
} | ||
|
||
@Provider | ||
public static class TestClientResponseFilter implements ResteasyReactiveClientResponseFilter { | ||
|
||
@Override | ||
public void filter(ResteasyReactiveClientRequestContext requestContext, ClientResponseContext responseContext) { | ||
responseContext.setStatus(200); | ||
} | ||
} | ||
} |
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
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