diff --git a/extensions/resteasy/runtime/src/main/java/io/quarkus/resteasy/runtime/standalone/VertxInputStream.java b/extensions/resteasy/runtime/src/main/java/io/quarkus/resteasy/runtime/standalone/VertxInputStream.java index e84bd9bf1794b..9c97bc82489f9 100644 --- a/extensions/resteasy/runtime/src/main/java/io/quarkus/resteasy/runtime/standalone/VertxInputStream.java +++ b/extensions/resteasy/runtime/src/main/java/io/quarkus/resteasy/runtime/standalone/VertxInputStream.java @@ -109,7 +109,7 @@ public void close() throws IOException { } } - public class VertxBlockingInput implements Handler { + public static class VertxBlockingInput implements Handler { protected final HttpServerRequest request; protected Buffer input1; protected Deque inputOverflow; @@ -137,7 +137,7 @@ public void handle(Void event) { }); request.fetch(1); } else { - throw new IOException("Request was ended before Resteasy could process it."); + eof = true; } } diff --git a/integration-tests/maven/src/test/java/io/quarkus/maven/it/DevMojoIT.java b/integration-tests/maven/src/test/java/io/quarkus/maven/it/DevMojoIT.java index 200344462c5e8..b60e2a5980cf6 100644 --- a/integration-tests/maven/src/test/java/io/quarkus/maven/it/DevMojoIT.java +++ b/integration-tests/maven/src/test/java/io/quarkus/maven/it/DevMojoIT.java @@ -11,6 +11,7 @@ import java.util.UUID; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicReference; +import java.util.stream.IntStream; import org.apache.commons.io.FileUtils; import org.apache.maven.shared.invoker.MavenInvocationException; @@ -43,6 +44,17 @@ public void testThatClassAppCanRun() throws MavenInvocationException, IOExceptio assertThatOutputWorksCorrectly(running.log()); } + @Test + public void testThatResteasyWithoutUndertowCanRun() throws MavenInvocationException, IOException { + testDir = initProject("projects/classic-no-undertow", "projects/project-classic-no-undertow-run"); + run(); + + //make sure that a simple HTTP GET request always works + IntStream.range(0, 10).forEach(i -> { + assertThat(getStrictHttpResponse("/hello", 200)).isTrue(); + }); + } + @Test public void testThatTheApplicationIsReloadedOnJavaChange() throws MavenInvocationException, IOException { testDir = initProject("projects/classic", "projects/project-classic-run-java-change"); diff --git a/integration-tests/maven/src/test/resources/projects/classic-no-undertow/pom.xml b/integration-tests/maven/src/test/resources/projects/classic-no-undertow/pom.xml new file mode 100644 index 0000000000000..297a3fbf0e382 --- /dev/null +++ b/integration-tests/maven/src/test/resources/projects/classic-no-undertow/pom.xml @@ -0,0 +1,73 @@ + + + 4.0.0 + org.acme + acme + 1.0-SNAPSHOT + + @project.version@ + 1.8 + UTF-8 + 1.8 + + + + @project.groupId@ + quarkus-resteasy + ${quarkus.version} + + + @project.groupId@ + quarkus-junit5 + ${quarkus.version} + test + + + io.rest-assured + rest-assured + 3.3.0 + test + + + + + + @project.groupId@ + @project.artifactId@ + ${quarkus.version} + + + + build + + + + + + + + + native + + + + @project.groupId@ + @project.artifactId@ + ${quarkus.version} + + + + native-image + + + true + + + + + + + + + diff --git a/integration-tests/maven/src/test/resources/projects/classic-no-undertow/src/main/java/org/acme/HelloResource.java b/integration-tests/maven/src/test/resources/projects/classic-no-undertow/src/main/java/org/acme/HelloResource.java new file mode 100644 index 0000000000000..64675366c9153 --- /dev/null +++ b/integration-tests/maven/src/test/resources/projects/classic-no-undertow/src/main/java/org/acme/HelloResource.java @@ -0,0 +1,35 @@ +package org.acme; + +import org.eclipse.microprofile.config.inject.ConfigProperty; + +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; + +@Path("/hello") +public class HelloResource { + + @Inject + @ConfigProperty(name = "greeting") + String greeting; + + @GET + @Produces(MediaType.TEXT_PLAIN) + public String hello() { + return "hello"; + } + + @GET + @Path("/greeting") + @Produces(MediaType.TEXT_PLAIN) + public String greeting() { + return greeting; + } + + + public static class Blah { + + } +} diff --git a/integration-tests/maven/src/test/resources/projects/classic-no-undertow/src/main/resources/META-INF/resources/index.html b/integration-tests/maven/src/test/resources/projects/classic-no-undertow/src/main/resources/META-INF/resources/index.html new file mode 100644 index 0000000000000..ab969caa08e3a --- /dev/null +++ b/integration-tests/maven/src/test/resources/projects/classic-no-undertow/src/main/resources/META-INF/resources/index.html @@ -0,0 +1,153 @@ + + + + + acme - 1.0-SNAPSHOT + + + + + + +
+
+

Congratulations, you have created a new Quarkus application.

+ +

Why do you see this?

+ +

This page is served by Quarkus. The source is in + src/main/resources/META-INF/resources/index.html.

+ +

What can I do from here?

+ +

If not already done, run the application in dev mode using: mvn compile quarkus:dev. +

+
    +
  • Add REST resources, Servlets, functions and other services in src/main/java.
  • +
  • Your static assets are located in src/main/resources/META-INF/resources.
  • +
  • Configure your application in src/main/resources/application.properties. +
  • +
+ +

How do I get rid of this page?

+

Just delete the src/main/resources/META-INF/resources/index.html file.

+
+
+
+

Application

+
    +
  • GroupId: org.acme
  • +
  • ArtifactId: acme
  • +
  • Version: 1.0-SNAPSHOT
  • +
  • Quarkus Version: 999-SNAPSHOT
  • +
+
+
+

Next steps

+ +
+
+
+ + + + \ No newline at end of file diff --git a/integration-tests/maven/src/test/resources/projects/classic-no-undertow/src/main/resources/application.properties b/integration-tests/maven/src/test/resources/projects/classic-no-undertow/src/main/resources/application.properties new file mode 100644 index 0000000000000..9f58e0badff94 --- /dev/null +++ b/integration-tests/maven/src/test/resources/projects/classic-no-undertow/src/main/resources/application.properties @@ -0,0 +1,10 @@ +# Configuration file +key = value +greeting=bonjour +quarkus.live-reload.password=secret +quarkus.live-reload.url=http://localhost:8080/ +quarkus.log.level=INFO +quarkus.log.file.enable=false +quarkus.log.console.format=%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%c{3.}] (%t) %s%e%n +quarkus.log.file.format=%d{yyyy-MM-dd HH:mm:ss,SSS} %h %N[%i] %-5p [%c{3.}] (%t) %s%e%n +quarkus.log.category."io.quarkus".level=INFO diff --git a/integration-tests/maven/src/test/resources/projects/classic-no-undertow/src/test/java/org/acme/HelloResourceTest.java b/integration-tests/maven/src/test/resources/projects/classic-no-undertow/src/test/java/org/acme/HelloResourceTest.java new file mode 100644 index 0000000000000..c2f29e2c9f711 --- /dev/null +++ b/integration-tests/maven/src/test/resources/projects/classic-no-undertow/src/test/java/org/acme/HelloResourceTest.java @@ -0,0 +1,21 @@ +package org.acme; + +import io.quarkus.test.junit.QuarkusTest; +import org.junit.jupiter.api.Test; + +import static io.restassured.RestAssured.given; +import static org.hamcrest.CoreMatchers.is; + +@QuarkusTest +public class HelloResourceTest { + + @Test + public void testHelloEndpoint() { + given() + .when().get("/app/hello") + .then() + .statusCode(200) + .body(is("hello")); + } + +} diff --git a/test-framework/maven/src/main/java/io/quarkus/maven/it/MojoTestBase.java b/test-framework/maven/src/main/java/io/quarkus/maven/it/MojoTestBase.java index 3508b83975954..a6fa7e88676bf 100644 --- a/test-framework/maven/src/main/java/io/quarkus/maven/it/MojoTestBase.java +++ b/test-framework/maven/src/main/java/io/quarkus/maven/it/MojoTestBase.java @@ -261,6 +261,27 @@ static boolean getHttpResponse(String path, int expectedStatus) { return code.get(); } + // will fail if it receives any http response except the expected one + static boolean getStrictHttpResponse(String path, int expectedStatus) { + AtomicBoolean code = new AtomicBoolean(); + await() + .pollDelay(1, TimeUnit.SECONDS) + .atMost(5, TimeUnit.MINUTES).until(() -> { + try { + URL url = new URL("http://localhost:8080" + ((path.startsWith("/") ? path : "/" + path))); + HttpURLConnection connection = (HttpURLConnection) url.openConnection(); + // the default Accept header used by HttpURLConnection is not compatible with RESTEasy negotiation as it uses q=.2 + connection.setRequestProperty("Accept", "text/html, *; q=0.2, */*; q=0.2"); + code.set(connection.getResponseCode() == expectedStatus); + //complete no matter what the response code was + return true; + } catch (Exception e) { + return false; + } + }); + return code.get(); + } + public static String get() throws IOException { URL url = new URL("http://localhost:8080"); return IOUtils.toString(url, "UTF-8");