From 6d58ec6df8da39e62bee6454e0827d316615fac6 Mon Sep 17 00:00:00 2001 From: "Edward M. Kagan" Date: Wed, 3 Nov 2021 01:25:48 +0300 Subject: [PATCH] RESTeasy test suite --- modules/resteasy-jdk-http/pom.xml | 45 ++++++++++++++++ .../java/twopm/tech/bench/jaxrs/Bench.java | 23 ++++++++ .../twopm/tech/bench/jaxrs/TestResource.java | 32 ++++++++++++ modules/resteasy-netty/pom.xml | 45 ++++++++++++++++ .../java/twopm/tech/bench/jaxrs/Bench.java | 21 ++++++++ .../twopm/tech/bench/jaxrs/TestResource.java | 32 ++++++++++++ modules/resteasy-reactor-netty/pom.xml | 50 ++++++++++++++++++ .../java/twopm/tech/bench/jaxrs/Bench.java | 20 +++++++ .../twopm/tech/bench/jaxrs/TestResource.java | 32 ++++++++++++ modules/resteasy-undertow/pom.xml | 45 ++++++++++++++++ .../java/twopm/tech/bench/jaxrs/Bench.java | 19 +++++++ .../twopm/tech/bench/jaxrs/TestResource.java | 32 ++++++++++++ modules/resteasy-vertx/pom.xml | 52 +++++++++++++++++++ .../java/twopm/tech/bench/jaxrs/Bench.java | 18 +++++++ .../twopm/tech/bench/jaxrs/TestResource.java | 32 ++++++++++++ pom.xml | 6 +++ 16 files changed, 504 insertions(+) create mode 100644 modules/resteasy-jdk-http/pom.xml create mode 100644 modules/resteasy-jdk-http/src/main/java/twopm/tech/bench/jaxrs/Bench.java create mode 100644 modules/resteasy-jdk-http/src/main/java/twopm/tech/bench/jaxrs/TestResource.java create mode 100644 modules/resteasy-netty/pom.xml create mode 100644 modules/resteasy-netty/src/main/java/twopm/tech/bench/jaxrs/Bench.java create mode 100644 modules/resteasy-netty/src/main/java/twopm/tech/bench/jaxrs/TestResource.java create mode 100644 modules/resteasy-reactor-netty/pom.xml create mode 100644 modules/resteasy-reactor-netty/src/main/java/twopm/tech/bench/jaxrs/Bench.java create mode 100644 modules/resteasy-reactor-netty/src/main/java/twopm/tech/bench/jaxrs/TestResource.java create mode 100644 modules/resteasy-undertow/pom.xml create mode 100644 modules/resteasy-undertow/src/main/java/twopm/tech/bench/jaxrs/Bench.java create mode 100644 modules/resteasy-undertow/src/main/java/twopm/tech/bench/jaxrs/TestResource.java create mode 100644 modules/resteasy-vertx/pom.xml create mode 100644 modules/resteasy-vertx/src/main/java/twopm/tech/bench/jaxrs/Bench.java create mode 100644 modules/resteasy-vertx/src/main/java/twopm/tech/bench/jaxrs/TestResource.java diff --git a/modules/resteasy-jdk-http/pom.xml b/modules/resteasy-jdk-http/pom.xml new file mode 100644 index 0000000..2812206 --- /dev/null +++ b/modules/resteasy-jdk-http/pom.xml @@ -0,0 +1,45 @@ + + + 4.0.0 + + twopm.tech.jax-rs-bench + bom + 1.0-SNAPSHOT + ../../pom.xml + + resteasy-jdk-http + 1.0-SNAPSHOT + + + org.jboss.resteasy + resteasy-jdk-http + ${resteasy.version} + + + + + + org.apache.maven.plugins + maven-shade-plugin + ${maven.shade.plugin.version} + + + package + + shade + + + false + + + + ${app.main.class} + + + + + + + + + \ No newline at end of file diff --git a/modules/resteasy-jdk-http/src/main/java/twopm/tech/bench/jaxrs/Bench.java b/modules/resteasy-jdk-http/src/main/java/twopm/tech/bench/jaxrs/Bench.java new file mode 100644 index 0000000..49fe779 --- /dev/null +++ b/modules/resteasy-jdk-http/src/main/java/twopm/tech/bench/jaxrs/Bench.java @@ -0,0 +1,23 @@ +package twopm.tech.bench.jaxrs; + +import com.sun.net.httpserver.HttpContext; +import com.sun.net.httpserver.HttpServer; +import java.io.IOException; +import java.net.InetSocketAddress; +import org.jboss.resteasy.plugins.server.sun.http.HttpContextBuilder; + +public class Bench { + + public static void main(String[] args) throws IOException, InterruptedException { + HttpServer server = HttpServer.create(new InetSocketAddress(8080), 10); + HttpContextBuilder contextBuilder = new HttpContextBuilder(); + contextBuilder.getDeployment().getActualResourceClasses().add(TestResource.class); + HttpContext context = contextBuilder.bind(server); + server.start(); + + Runtime.getRuntime().addShutdownHook(new Thread(() -> { + contextBuilder.cleanup(); + server.stop(0); + })); + } +} diff --git a/modules/resteasy-jdk-http/src/main/java/twopm/tech/bench/jaxrs/TestResource.java b/modules/resteasy-jdk-http/src/main/java/twopm/tech/bench/jaxrs/TestResource.java new file mode 100644 index 0000000..8ee62a0 --- /dev/null +++ b/modules/resteasy-jdk-http/src/main/java/twopm/tech/bench/jaxrs/TestResource.java @@ -0,0 +1,32 @@ +package twopm.tech.bench.jaxrs; + +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; + +@Path("test") +public class TestResource { + + @GET + @Path("/") + @Produces("application/json") + public String index() { + return "{ \"status\" : \"OK\", \"method\" : \"GET\" }"; + } + + @GET + @Path("{id}") + @Produces("application/json") + public String get(@PathParam("id") Long id) { + return "{ \"status\" : \"OK\", \"method\" : \"GET\", \"test\" : " + String.valueOf(id) + " }"; + } + + @POST + @Path("{id}") + @Produces("application/json") + public String post(@PathParam("id") Long id) { + return "{ \"status\" : \"OK\", \"method\" : \"POST\", \"test\" : " + String.valueOf(id) + " }"; + } +} \ No newline at end of file diff --git a/modules/resteasy-netty/pom.xml b/modules/resteasy-netty/pom.xml new file mode 100644 index 0000000..7894bf9 --- /dev/null +++ b/modules/resteasy-netty/pom.xml @@ -0,0 +1,45 @@ + + + 4.0.0 + + twopm.tech.jax-rs-bench + bom + 1.0-SNAPSHOT + ../../pom.xml + + resteasy-netty + 1.0-SNAPSHOT + + + org.jboss.resteasy + resteasy-netty4 + ${resteasy.version} + + + + + + org.apache.maven.plugins + maven-shade-plugin + ${maven.shade.plugin.version} + + + package + + shade + + + false + + + + ${app.main.class} + + + + + + + + + \ No newline at end of file diff --git a/modules/resteasy-netty/src/main/java/twopm/tech/bench/jaxrs/Bench.java b/modules/resteasy-netty/src/main/java/twopm/tech/bench/jaxrs/Bench.java new file mode 100644 index 0000000..7345830 --- /dev/null +++ b/modules/resteasy-netty/src/main/java/twopm/tech/bench/jaxrs/Bench.java @@ -0,0 +1,21 @@ +package twopm.tech.bench.jaxrs; + +import java.io.IOException; +import org.jboss.resteasy.core.ResteasyDeploymentImpl; +import static org.jboss.resteasy.plugins.server.netty.NettyContainer.netty; +import org.jboss.resteasy.plugins.server.netty.NettyJaxrsServer; +import org.jboss.resteasy.spi.ResteasyDeployment; + +public class Bench { + + public static void main(String[] args) throws IOException, InterruptedException { + ResteasyDeployment deployment = new ResteasyDeploymentImpl(); + deployment.getActualResourceClasses().add(TestResource.class); + netty = new NettyJaxrsServer(); + netty.setDeployment(deployment); + netty.setPort(8080); + netty.setRootResourcePath(""); + netty.setSecurityDomain(null); + netty.start(); + } +} diff --git a/modules/resteasy-netty/src/main/java/twopm/tech/bench/jaxrs/TestResource.java b/modules/resteasy-netty/src/main/java/twopm/tech/bench/jaxrs/TestResource.java new file mode 100644 index 0000000..8ee62a0 --- /dev/null +++ b/modules/resteasy-netty/src/main/java/twopm/tech/bench/jaxrs/TestResource.java @@ -0,0 +1,32 @@ +package twopm.tech.bench.jaxrs; + +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; + +@Path("test") +public class TestResource { + + @GET + @Path("/") + @Produces("application/json") + public String index() { + return "{ \"status\" : \"OK\", \"method\" : \"GET\" }"; + } + + @GET + @Path("{id}") + @Produces("application/json") + public String get(@PathParam("id") Long id) { + return "{ \"status\" : \"OK\", \"method\" : \"GET\", \"test\" : " + String.valueOf(id) + " }"; + } + + @POST + @Path("{id}") + @Produces("application/json") + public String post(@PathParam("id") Long id) { + return "{ \"status\" : \"OK\", \"method\" : \"POST\", \"test\" : " + String.valueOf(id) + " }"; + } +} \ No newline at end of file diff --git a/modules/resteasy-reactor-netty/pom.xml b/modules/resteasy-reactor-netty/pom.xml new file mode 100644 index 0000000..1d271f8 --- /dev/null +++ b/modules/resteasy-reactor-netty/pom.xml @@ -0,0 +1,50 @@ + + + 4.0.0 + + twopm.tech.jax-rs-bench + bom + 1.0-SNAPSHOT + ../../pom.xml + + resteasy-reactor-netty + 1.0-SNAPSHOT + + + org.jboss.resteasy + resteasy-reactor-netty + ${resteasy.version} + + + org.eclipse.microprofile.config + microprofile-config-api + 2.0 + + + + + + org.apache.maven.plugins + maven-shade-plugin + ${maven.shade.plugin.version} + + + package + + shade + + + false + + + + ${app.main.class} + + + + + + + + + \ No newline at end of file diff --git a/modules/resteasy-reactor-netty/src/main/java/twopm/tech/bench/jaxrs/Bench.java b/modules/resteasy-reactor-netty/src/main/java/twopm/tech/bench/jaxrs/Bench.java new file mode 100644 index 0000000..1bbd3a3 --- /dev/null +++ b/modules/resteasy-reactor-netty/src/main/java/twopm/tech/bench/jaxrs/Bench.java @@ -0,0 +1,20 @@ +package twopm.tech.bench.jaxrs; + +import java.io.IOException; +import org.jboss.resteasy.core.ResteasyDeploymentImpl; +import org.jboss.resteasy.plugins.server.reactor.netty.ReactorNettyJaxrsServer; +import org.jboss.resteasy.spi.ResteasyDeployment; + +public class Bench { + + public static void main(String[] args) throws IOException, InterruptedException { + ResteasyDeployment deployment = new ResteasyDeploymentImpl(); + deployment.getActualResourceClasses().add(TestResource.class); + ReactorNettyJaxrsServer server = new ReactorNettyJaxrsServer(); + server.setDeployment(deployment); + server.setPort(8080); + server.setRootResourcePath(""); + server.setSecurityDomain(null); + server.startAndBlock(); + } +} diff --git a/modules/resteasy-reactor-netty/src/main/java/twopm/tech/bench/jaxrs/TestResource.java b/modules/resteasy-reactor-netty/src/main/java/twopm/tech/bench/jaxrs/TestResource.java new file mode 100644 index 0000000..8ee62a0 --- /dev/null +++ b/modules/resteasy-reactor-netty/src/main/java/twopm/tech/bench/jaxrs/TestResource.java @@ -0,0 +1,32 @@ +package twopm.tech.bench.jaxrs; + +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; + +@Path("test") +public class TestResource { + + @GET + @Path("/") + @Produces("application/json") + public String index() { + return "{ \"status\" : \"OK\", \"method\" : \"GET\" }"; + } + + @GET + @Path("{id}") + @Produces("application/json") + public String get(@PathParam("id") Long id) { + return "{ \"status\" : \"OK\", \"method\" : \"GET\", \"test\" : " + String.valueOf(id) + " }"; + } + + @POST + @Path("{id}") + @Produces("application/json") + public String post(@PathParam("id") Long id) { + return "{ \"status\" : \"OK\", \"method\" : \"POST\", \"test\" : " + String.valueOf(id) + " }"; + } +} \ No newline at end of file diff --git a/modules/resteasy-undertow/pom.xml b/modules/resteasy-undertow/pom.xml new file mode 100644 index 0000000..2663cf3 --- /dev/null +++ b/modules/resteasy-undertow/pom.xml @@ -0,0 +1,45 @@ + + + 4.0.0 + + twopm.tech.jax-rs-bench + bom + 1.0-SNAPSHOT + ../../pom.xml + + resteasy-undertow + 1.0-SNAPSHOT + + + org.jboss.resteasy + resteasy-undertow + ${resteasy.version} + + + + + + org.apache.maven.plugins + maven-shade-plugin + ${maven.shade.plugin.version} + + + package + + shade + + + false + + + + ${app.main.class} + + + + + + + + + diff --git a/modules/resteasy-undertow/src/main/java/twopm/tech/bench/jaxrs/Bench.java b/modules/resteasy-undertow/src/main/java/twopm/tech/bench/jaxrs/Bench.java new file mode 100644 index 0000000..996eb5a --- /dev/null +++ b/modules/resteasy-undertow/src/main/java/twopm/tech/bench/jaxrs/Bench.java @@ -0,0 +1,19 @@ +package twopm.tech.bench.jaxrs; + +import java.io.IOException; +import org.jboss.resteasy.core.ResteasyDeploymentImpl; +import org.jboss.resteasy.plugins.server.undertow.UndertowJaxrsServer; +import org.jboss.resteasy.spi.ResteasyDeployment; +public class Bench { + + public static void main(String[] args) throws IOException, InterruptedException { + ResteasyDeployment deployment = new ResteasyDeploymentImpl(); + deployment.getActualResourceClasses().add(TestResource.class); + UndertowJaxrsServer server = new UndertowJaxrsServer(); + server.deploy(deployment); + server.setPort(8080); + server.setRootResourcePath(""); + server.setSecurityDomain(null); + server.start(); + } +} diff --git a/modules/resteasy-undertow/src/main/java/twopm/tech/bench/jaxrs/TestResource.java b/modules/resteasy-undertow/src/main/java/twopm/tech/bench/jaxrs/TestResource.java new file mode 100644 index 0000000..afcec4a --- /dev/null +++ b/modules/resteasy-undertow/src/main/java/twopm/tech/bench/jaxrs/TestResource.java @@ -0,0 +1,32 @@ +package twopm.tech.bench.jaxrs; + +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; + +@Path("/test") +public class TestResource { + + @GET + @Path("/") + @Produces("application/json") + public String index() { + return "{ \"status\" : \"OK\", \"method\" : \"GET\" }"; + } + + @GET + @Path("{id}") + @Produces("application/json") + public String get(@PathParam("id") Long id) { + return "{ \"status\" : \"OK\", \"method\" : \"GET\", \"test\" : " + String.valueOf(id) + " }"; + } + + @POST + @Path("{id}") + @Produces("application/json") + public String post(@PathParam("id") Long id) { + return "{ \"status\" : \"OK\", \"method\" : \"POST\", \"test\" : " + String.valueOf(id) + " }"; + } +} \ No newline at end of file diff --git a/modules/resteasy-vertx/pom.xml b/modules/resteasy-vertx/pom.xml new file mode 100644 index 0000000..f0cff37 --- /dev/null +++ b/modules/resteasy-vertx/pom.xml @@ -0,0 +1,52 @@ + + + 4.0.0 + + twopm.tech.jax-rs-bench + bom + 1.0-SNAPSHOT + ../../pom.xml + + resteasy-vertx + 1.0-SNAPSHOT + + + org.jboss.resteasy + resteasy-vertx + ${resteasy.version} + + + + io.vertx + vertx-core + 4.2.0 + + + + + + + org.apache.maven.plugins + maven-shade-plugin + ${maven.shade.plugin.version} + + + package + + shade + + + false + + + + ${app.main.class} + + + + + + + + + \ No newline at end of file diff --git a/modules/resteasy-vertx/src/main/java/twopm/tech/bench/jaxrs/Bench.java b/modules/resteasy-vertx/src/main/java/twopm/tech/bench/jaxrs/Bench.java new file mode 100644 index 0000000..e2cb0e2 --- /dev/null +++ b/modules/resteasy-vertx/src/main/java/twopm/tech/bench/jaxrs/Bench.java @@ -0,0 +1,18 @@ +package twopm.tech.bench.jaxrs; + +import java.io.IOException; +import org.jboss.resteasy.plugins.server.vertx.VertxJaxrsServer; +import org.jboss.resteasy.plugins.server.vertx.VertxResteasyDeployment; +public class Bench { + + public static void main(String[] args) throws IOException, InterruptedException { + VertxResteasyDeployment deployment = new VertxResteasyDeployment(); + deployment.getActualResourceClasses().add(TestResource.class); + VertxJaxrsServer server = new VertxJaxrsServer(); + server.setDeployment(deployment); + server.setPort(8080); + server.setRootResourcePath(""); + server.setSecurityDomain(null); + server.start(); + } +} diff --git a/modules/resteasy-vertx/src/main/java/twopm/tech/bench/jaxrs/TestResource.java b/modules/resteasy-vertx/src/main/java/twopm/tech/bench/jaxrs/TestResource.java new file mode 100644 index 0000000..8ee62a0 --- /dev/null +++ b/modules/resteasy-vertx/src/main/java/twopm/tech/bench/jaxrs/TestResource.java @@ -0,0 +1,32 @@ +package twopm.tech.bench.jaxrs; + +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; + +@Path("test") +public class TestResource { + + @GET + @Path("/") + @Produces("application/json") + public String index() { + return "{ \"status\" : \"OK\", \"method\" : \"GET\" }"; + } + + @GET + @Path("{id}") + @Produces("application/json") + public String get(@PathParam("id") Long id) { + return "{ \"status\" : \"OK\", \"method\" : \"GET\", \"test\" : " + String.valueOf(id) + " }"; + } + + @POST + @Path("{id}") + @Produces("application/json") + public String post(@PathParam("id") Long id) { + return "{ \"status\" : \"OK\", \"method\" : \"POST\", \"test\" : " + String.valueOf(id) + " }"; + } +} \ No newline at end of file diff --git a/pom.xml b/pom.xml index cecbfd6..8e4e1cf 100644 --- a/pom.xml +++ b/pom.xml @@ -17,6 +17,11 @@ modules/jooby-undertow modules/quarkus-resteasy-jackson modules/quarkus-resteasy-jsonb + modules/resteasy-jdk-http + modules/resteasy-netty + modules/resteasy-reactor-netty + modules/resteasy-vertx + modules/resteasy-undertow twopm.tech.bench.jaxrs.Bench @@ -35,5 +40,6 @@ quarkus-bom io.quarkus.platform 2.4.0.Final + 4.7.2.Final \ No newline at end of file