Skip to content

Commit

Permalink
Reactive routes - register return/body types for reflection if needed
Browse files Browse the repository at this point in the history
- resolves quarkusio#10893
  • Loading branch information
mkouba committed Jul 28, 2020
1 parent 517024c commit ce5272e
Show file tree
Hide file tree
Showing 7 changed files with 273 additions and 34 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/ci-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -511,12 +511,13 @@ jobs:
infinispan-client
cache
- category: HTTP
timeout: 55
timeout: 60
test-modules: >
resteasy-jackson
resteasy-mutiny
vertx
vertx-http
vertx-web
vertx-graphql
virtual-http
rest-client
Expand Down

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion integration-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
<module>hibernate-tenancy</module>
<module>hibernate-orm-envers</module>
<module>vertx-http</module>
<module>vertx-web</module>
<module>vertx</module>
<module>spring-di</module>
<module>spring-web</module>
Expand Down Expand Up @@ -129,7 +130,7 @@
<module>ide-launcher</module>
<module>elasticsearch-rest-client</module>
<module>elasticsearch-rest-high-level-client</module>

<!-- gRPC tests -->
<module>grpc-plain-text</module>
<module>grpc-tls</module>
Expand Down
91 changes: 91 additions & 0 deletions integration-tests/vertx-web/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<artifactId>quarkus-integration-tests-parent</artifactId>
<groupId>io.quarkus</groupId>
<version>999-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>

<artifactId>quarkus-integration-test-vertx-web</artifactId>
<name>Quarkus - Integration Tests - Vert.x Web</name>

<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-vertx-web</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>native-image</id>
<activation>
<property>
<name>native</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>${native.surefire.skip}</skipTests>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<systemPropertyVariables>
<native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path>
</systemPropertyVariables>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<properties>
<quarkus.package.type>native</quarkus.package.type>
</properties>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package io.quarkus.it.vertx;

import static io.vertx.core.http.HttpMethod.GET;
import static io.vertx.core.http.HttpMethod.POST;

import io.quarkus.vertx.web.Body;
import io.quarkus.vertx.web.Route;
import io.quarkus.vertx.web.RouteBase;
import io.smallrye.mutiny.Uni;
import io.vertx.core.buffer.Buffer;
import io.vertx.core.json.JsonObject;

@RouteBase(path = "/simple")
public class SimpleEndpoint {

@Route(path = "person", methods = GET)
public Person getPerson() {
Person person = new Person();
person.setName("Jan");
return person;
}

@Route(path = "pet", methods = GET)
public Uni<Pet> getPet() {
Pet pet = new Pet();
pet.setName("Jack");
return Uni.createFrom().item(pet);
}

@Route(path = "pong", methods = GET)
public JsonObject getPong() {
return new JsonObject().put("name", "ping");
}

@Route(path = "data", methods = POST, produces = "application/json")
public Buffer createData(@Body Data data) {
data.setName(data.getName() + data.getName());
return JsonObject.mapFrom(data).toBuffer();
}

public static class Person {

private String name;

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

}

public static class Pet {

private String name;

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

}

public static class Data {

private String name;

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package io.quarkus.it.vertx;

import io.quarkus.test.junit.NativeImageTest;

@NativeImageTest
public class SimpleEndpointIT extends SimpleEndpointTestCase {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package io.quarkus.it.vertx;

import static io.restassured.RestAssured.given;
import static io.restassured.RestAssured.when;
import static org.hamcrest.Matchers.is;

import org.junit.jupiter.api.Test;

import io.quarkus.test.junit.QuarkusTest;

@QuarkusTest
public class SimpleEndpointTestCase {

@Test
public void testEndpoint() throws Exception {
when().get("/simple/person").then().statusCode(200)
.body("name", is("Jan"))
.header("content-type", "application/json");
when().get("/simple/pet").then().statusCode(200)
.body("name", is("Jack"))
.header("content-type", "application/json");
when().get("/simple/pong").then().statusCode(200)
.body("name", is("ping"))
.header("content-type", "application/json");
given().body("{\"name\":\"pi\"}").post("/simple/data").then().statusCode(200)
.body("name", is("pipi"))
.header("content-type", "application/json");
}

}

0 comments on commit ce5272e

Please sign in to comment.