forked from quarkus-qe/quarkus-test-suite
-
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 quarkus-qe#459 from pjgg/backport_1e7c244
[2.2] Add reactive counterpart of http/rest-client module
- Loading branch information
Showing
9 changed files
with
141 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>io.quarkus.ts.qe</groupId> | ||
<artifactId>parent</artifactId> | ||
<version>1.0.0-SNAPSHOT</version> | ||
<relativePath>../..</relativePath> | ||
</parent> | ||
<artifactId>http-rest-client-reactive</artifactId> | ||
<packaging>jar</packaging> | ||
<name>Quarkus QE TS: HTTP: Rest Client Reactive</name> | ||
<dependencies> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-resteasy-reactive-jackson</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-rest-client-reactive-jackson</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-jaxb</artifactId> | ||
</dependency> | ||
</dependencies> | ||
</project> |
27 changes: 27 additions & 0 deletions
27
...tive/src/main/java/io/quarkus/ts/http/restclient/reactive/ReactiveClientBookResource.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,27 @@ | ||
package io.quarkus.ts.http.restclient.reactive; | ||
|
||
import javax.inject.Inject; | ||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.Produces; | ||
import javax.ws.rs.core.MediaType; | ||
|
||
import org.eclipse.microprofile.rest.client.inject.RestClient; | ||
|
||
import io.quarkus.ts.http.restclient.reactive.json.Book; | ||
import io.smallrye.mutiny.Uni; | ||
|
||
@Path("/client/book") | ||
public class ReactiveClientBookResource { | ||
|
||
@Inject | ||
@RestClient | ||
ReactiveRestInterface restInterface; | ||
|
||
@GET | ||
@Path("/json") | ||
@Produces(MediaType.APPLICATION_JSON) | ||
public Uni<Book> getAsJson() { | ||
return restInterface.getAsJson(); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...-reactive/src/main/java/io/quarkus/ts/http/restclient/reactive/ReactiveRestInterface.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,23 @@ | ||
package io.quarkus.ts.http.restclient.reactive; | ||
|
||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.Produces; | ||
import javax.ws.rs.core.MediaType; | ||
|
||
import org.eclipse.microprofile.rest.client.annotation.RegisterClientHeaders; | ||
import org.eclipse.microprofile.rest.client.inject.RegisterRestClient; | ||
|
||
import io.quarkus.ts.http.restclient.reactive.json.Book; | ||
import io.smallrye.mutiny.Uni; | ||
|
||
@RegisterRestClient | ||
@Path("/book") | ||
@RegisterClientHeaders | ||
public interface ReactiveRestInterface { | ||
|
||
@GET | ||
@Path("/json") | ||
@Produces(MediaType.APPLICATION_JSON) | ||
Uni<Book> getAsJson(); | ||
} |
21 changes: 21 additions & 0 deletions
21
.../rest-client-reactive/src/main/java/io/quarkus/ts/http/restclient/reactive/json/Book.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,21 @@ | ||
package io.quarkus.ts.http.restclient.reactive.json; | ||
|
||
public class Book { | ||
|
||
private String title; | ||
|
||
public Book() { | ||
} | ||
|
||
public Book(String title) { | ||
this.title = title; | ||
} | ||
|
||
public String getTitle() { | ||
return title; | ||
} | ||
|
||
public void setTitle(String title) { | ||
this.title = title; | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...eactive/src/main/java/io/quarkus/ts/http/restclient/reactive/json/BookAsJsonResource.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,18 @@ | ||
package io.quarkus.ts.http.restclient.reactive.json; | ||
|
||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.Produces; | ||
import javax.ws.rs.core.MediaType; | ||
|
||
import io.smallrye.mutiny.Uni; | ||
|
||
@Produces(MediaType.APPLICATION_JSON) | ||
@Path("/book/json") | ||
public class BookAsJsonResource { | ||
|
||
@GET | ||
public Uni<String> get() { | ||
return Uni.createFrom().item("{\"title\":\"Title in Json\"}"); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
http/rest-client-reactive/src/main/resources/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 @@ | ||
io.quarkus.ts.http.restclient.reactive.ReactiveRestInterface/mp-rest/url=http://localhost:${quarkus.http.port} |
19 changes: 19 additions & 0 deletions
19
...t-reactive/src/test/java/io/quarkus/ts/http/restclient/reactive/ClientBookResourceIT.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,19 @@ | ||
package io.quarkus.ts.http.restclient.reactive; | ||
|
||
import static io.restassured.RestAssured.given; | ||
import static org.hamcrest.CoreMatchers.is; | ||
|
||
import org.apache.http.HttpStatus; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import io.quarkus.test.scenarios.QuarkusScenario; | ||
|
||
@QuarkusScenario | ||
public class ClientBookResourceIT { | ||
|
||
@Test | ||
public void shouldGetBookFromRestClientJson() { | ||
given().get("/client/book/json").then().statusCode(HttpStatus.SC_OK) | ||
.body(is("{\"title\":\"Title in Json\"}")); | ||
} | ||
} |
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